ubuntu-18.04-server-cloudimg-arm64.img often fails to set the cloud-localds password under QEMU
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-images |
Invalid
|
Undecided
|
Unassigned | ||
cloud-init |
Expired
|
Medium
|
Unassigned |
Bug Description
On an Ubuntu 18.10 host, QEMU 2.12.0, I try to run the cloudimage with the script shown at the end of this description.
Result: many times, I end up on the user / password prompt, but the password I chose with cloud-localds was not set.
It is not deterministic, but it happens very often. Sometimes password worked. And very rarely, it shows a stack trace on the terminal, but most times just fails silently.
The test script:
```
set -eux
# Parameters.
id=ubuntu-
img="${id}.img"
img_snapshot=
flash0=
flash1=
user_data=
user_data_
# Install dependencies.
pkgs='cloud-
if ! dpkg -s $pkgs >/dev/null 2>&1; then
sudo apt-get install $pkgs
fi
# Get the image.
if [ ! -f "$img" ]; then
wget "https:/
fi
# Create snapshot.
if [ ! -f "$img_snapshot" ]; then
qemu-img \
create \
-b "$img" \
-f qcow2 \
"$img_snapshot" \
1T \
;
fi
# Set the password.
if [ ! -f "$user_data" ]; then
cat >"$user_data" <<EOF
#cloud-config
password: asdfqwer
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds "$user_data_img" "$user_data"
fi
# Firmware.
if [ ! -f "$flash0" ]; then
dd if=/dev/zero of="$flash0" bs=1M count=64
dd if=/usr/
fi
if [ ! -f "$flash1" ]; then
dd if=/dev/zero of="$flash1" bs=1M count=64
fi
# Run.
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a57 \
-device rtl8139,netdev=net0 \
-device virtio-
-drive "if=none,
-drive "file=$
-m 2G \
-netdev user,id=net0 \
-nographic \
-pflash "$flash0" \
-pflash "$flash1" \
-smp 2 \
"$@" \
;
```
A stack trace that I saw once (rare):
```
# [ 113.002366] cloud-init[528]: Cloud-init v. 18.4-0ubuntu1~
# [ 113.020759] cloud-init[528]: ci-info: +++++++
# [ 113.031208] cloud-init[528]: ci-info: +------
# [ 113.041449] cloud-init[528]: ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
# [ 113.051615] cloud-init[528]: ci-info: +------
# [ 113.061778] cloud-init[528]: ci-info: | enp0s1 | False | . | . | . | 52:54:00:12:34:56 |
# [ 113.071307] cloud-init[528]: ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . |
# [ 113.088462] cloud-init[528]: ci-info: | lo | True | ::1/128 | . | host | . |
# [ 113.097037] cloud-init[528]: ci-info: +------
# [ 113.100513] cloud-init[528]: ci-info: +++++++
# [ 113.103872] cloud-init[528]: ci-info: +------
# [ 113.107605] cloud-init[528]: ci-info: | Route | Destination | Gateway | Interface | Flags |
# [ 113.111566] cloud-init[528]: ci-info: +------
# [ 113.115000] cloud-init[528]: ci-info: +------
# [ 113.118441] cloud-init[528]: 2019-01-17 00:22:23,983 - util.py[WARNING]: failed stage init
# [ 113.238277] cloud-init[528]: failed run of stage init
# [ 113.252444] cloud-init[528]: -------
# [ 113.255576] cloud-init[528]: Traceback (most recent call last):
# [ 113.268398] cloud-init[528]: File "/usr/lib/
# [ 113.272674] cloud-init[528]: ret = functor(name, args)
# [ 113.285055] cloud-init[528]: File "/usr/lib/
# [ 113.288945] cloud-init[528]: init.apply_
# [ 113.293122] cloud-init[528]: File "/usr/lib/
# [ 113.304953] cloud-init[528]: return self.distro.
# [ 113.309150] cloud-init[528]: File "/usr/lib/
# [ 113.322181] cloud-init[528]: dev_names = self._write_
# [ 113.327226] cloud-init[528]: File "/usr/lib/
# [ 113.341030] cloud-init[528]: return self._supported
# [ 113.353698] cloud-init[528]: File "/usr/lib/
# [ 113.358591] cloud-init[528]: renderer.
# [ 113.376713] cloud-init[528]: File "/usr/lib/
# [ 113.381516] cloud-init[528]: templates=
# [ 113.385465] cloud-init[528]: File "/usr/lib/
# [ 113.389682] cloud-init[528]: self._netplan_
# [ 113.393637] cloud-init[528]: File "/usr/lib/
# [ 113.397718] cloud-init[528]: util.subp(
# [ 113.401648] cloud-init[528]: File "/usr/lib/
# [ 113.405796] cloud-init[528]: cmd=args)
# [ 113.411233] cloud-init[528]: cloudinit.
# [ 113.416694] cloud-init[528]: Command: ['netplan', 'generate']
# [ 113.420785] cloud-init[528]: Exit code: -11
# [ 113.424647] cloud-init[528]: Reason: -
# [ 113.428686] cloud-init[528]: Stdout:
# [ 113.431914] cloud-init[528]: Stderr:
# [ 113.435345] cloud-init[528]: -------
```
Changed in cloud-images: | |
status: | New → Invalid |
I wonder what the config netplan generate complained about.
If you can set a password on your snapshot image, you'll be able to login even when cloud-init fails.
This will get you a shell inside your image:
sudo mount-image- callback --system-mounts /path/to/ qcow2-snapshot -- chroot _MOUNTPOINT_ /bin/bash
From there, you can run passwd and set the root pw for the image,
Then boot via qemu, and if it fails, you can login on console with the set password.
From there, running: 'cloud-init collect-logs' and attaching the file would be useful for debugging.
If you are in there, looking at /etc/netplan/ 50-cloud- init.yaml and re-running netplan --debug generate to see the error and attach that as well.