Skip to content

Commit

Permalink
Add guest hostname test
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Harding <kyle@balena.io>
  • Loading branch information
klutchell committed Oct 18, 2023
1 parent b3bc56d commit 89f2028
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ services:
build:
context: .
target: alpine-test
environment:
- GUEST_HOSTNAME=alpine-test
command: /usr/local/bin/healthcheck.sh

debian-test:
Expand All @@ -60,6 +62,8 @@ services:
build:
context: .
target: debian-test
environment:
- GUEST_HOSTNAME=debian-test
command: /usr/local/bin/healthcheck.sh

ubuntu-test:
Expand All @@ -69,6 +73,8 @@ services:
build:
context: .
target: ubuntu-test
environment:
- GUEST_HOSTNAME=ubuntu-test
command: /usr/local/bin/healthcheck.sh

dind-test:
Expand All @@ -80,4 +86,5 @@ services:
target: dind-test
environment:
- DOCKER_TLS_CERTDIR=
- GUEST_HOSTNAME=dind-test
command: /usr/local/bin/dockerd-entrypoint.sh
2 changes: 2 additions & 0 deletions overlay/usr/local/bin/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ uname -a
df -h
lsblk

test "${GUEST_HOSTNAME}" = "$(hostname)"

ip link list
ip route

Expand Down
12 changes: 8 additions & 4 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ network_config() {
local _client_ip="${1}"
local _server_ip=""
local _gw_ip="${2}"
local _netmask
local _hostname="${3:-${HOSTNAME}}"
local _device="${4:-eth0}"
local _netmask=""
local _hostname="${3}"
local _device="${4}"
local _autoconf=off

# normalize addresses to remove cidr suffix
Expand Down Expand Up @@ -259,6 +259,10 @@ if [ -z "${GUEST_MAC:-}" ]; then
GUEST_MAC="$(ip_to_mac "${GUEST_IP}")"
fi

if [ -z "${GUEST_HOSTNAME:-}" ]; then
GUEST_HOSTNAME="$(hostname)"
fi

if [ -z "${KERNEL_BOOT_ARGS:-}" ]; then
KERNEL_BOOT_ARGS="console=ttyS0 reboot=k panic=1 pci=off random.trust_cpu=on"

Expand All @@ -267,7 +271,7 @@ if [ -z "${KERNEL_BOOT_ARGS:-}" ]; then
fi
fi

KERNEL_BOOT_ARGS="${KERNEL_BOOT_ARGS} $(network_config "${GUEST_IP}" "${TAP_IP}" "$(hostname)" eth0)"
KERNEL_BOOT_ARGS="${KERNEL_BOOT_ARGS} $(network_config "${GUEST_IP}" "${TAP_IP}" "${GUEST_HOSTNAME}" eth0)"

echo "Virtual CPUs: ${VCPU_COUNT}"
echo "Memory: ${MEM_SIZE_MIB}M"
Expand Down

0 comments on commit 89f2028

Please sign in to comment.