cirros-dev / cirros

116 stars 33 forks source link

network is not guaranteed up by user-data process or rc.local #97

Closed smoser closed 1 month ago

smoser commented 1 year ago

I have a 'test-cirros' script (see below) that provides 'nocloud' data that runs ping. By the time /etc/rc3.d/S98-cirros-status executes, the ipv4 network is not up, and cirros-status will show the debug information.

Networking should block, so that user-data or rc.local can assume if everything is functioning correctly, network will be up. In the past this was guaranteed, if networking was not up at that point, then something was wrong. As it is now trying again in a second or two would work.

Script is test-cirros below and log file attached (cirros-0.6.0-test.log).

#!/bin/sh
MEM=${MEM:-128}
HOSTARCH="${HOSTARCH:-x86_64}"
GUESTARCH="${GUESTARCH:-${HOSTARCH}}"
VERSION="0.6.0"
burl="http://download.cirros-cloud.net"

fail() { echo "$@" 1>&2; exit 1; }

imgurl="${burl}/$VERSION/cirros-$VERSION-$GUESTARCH-disk.img" 
imgdist=${1:-${img_url##*/}}

command -v cloud-localds >/dev/null ||
    fail "you need cloud-localds from cloud-utils"

if [ ! -f "$imgdist" ]; then
   wget -O "$imgdist.tmp" "$imgurl" &&
      mv "$imgdist.tmp" "$imgdist"
fi

echo "$HOSTARCH/$GUESTARCH/$MEM [$imgdist]"

: > user-data
echo '{"instance-id": "9068aef2-213e-4e43-830f-accdbadde897"}' > meta-data

cloud-localds seed.img user-data meta-data || fail "cloud-localds failed"

out=$(qemu-img create -f qcow2 -F qcow2 -b "$imgdist" disk1.img 2>&1) ||
    fail "qemu-img create failed: $out"

"qemu-system-$HOSTARCH" -m "$MEM" -enable-kvm \
   -device virtio-net-pci,netdev=net00 \
   -netdev type=user,id=net00,net=10.0.12.0/24,host=10.0.12.2 \
   -drive if=virtio,file=disk1.img \
   -drive if=virtio,file=seed.img \
   -nographic
osfrickler commented 1 month ago

This should be fixed by https://github.com/cirros-dev/cirros/pull/116