canonical / canonical/cloud-init

boot-finished file not created when using power_state to turn off vm after cloud-init finishes

Open
#6,744 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
when i add `power_state` from [here](https://cloudinit.readthedocs.io/en/stable/reference/yaml_examples/power_state_change.html) to my config, the boot-finished file fails to be created, and so it is not possible to tell if cloud-init succeeded

## Steps to reproduce the problem

```yaml
#cloud-config
runcmd:
- |
bash -c "
trap 'shutdown now' ERR
true
"

# https://cloudinit.readthedocs.io/en/stable/reference/yaml_examples/power_state_change.html
power_state:
delay: 1
mode: poweroff
message: Bye Bye
timeout: 30
condition: true
```

process:

```shell
tmp=$(mktemp)
tmp1=$(mktemp)
echo "instance-id: test-true" > $tmp1
xorriso, -as, mkisofs, -output, $tmp, -volid, cidata, -joliet, -rock, -graft-points, user-data=src/test/resources/true.cloud-config.yaml, meta-data=$tmp1

noble="path to qemu-img overlay of noble image from ubuntu cloudimages"
qemu-system-aarch64, -cpu, host, -accel, hvf, -machine, virt,highmem=on, -m, 3072, -smp, 2, -drive, file=$noble,format=qcow2,if=virtio, -drive, file=$tmp,format=raw,if=virtio, -bios, /opt/homebrew/share/qemu/edk2-aarch64-code.fd, -netdev, user,id=net0,hostfwd=tcp::51656-:22, -device, virtio-net-pci,netdev=net0, -display, none, -serial, mon:stdio, -device, virtio-rng-pci
```

then launch again with this cloud-init:

```yaml
#cloud-config
ssh_pwauth: true
chpasswd:
list: |
ubuntu:ubuntu
expire: false
```

now ssh because you can:

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@127.0.0.1 -p 51656

and observe that you only see one boot-finished file:

find /var/lib/cloud/instances -name boot-finished

## Environment details
- Cloud-init version: presumably latest? im using the latest cloudimages
- Operating System Distribution: ubuntu
- Cloud provider, platform or installer type: ubuntu, using the one already built into cloud images

## cloud-init logs
there are a lot but i think this is the most relevant part:

```
[ 8.954317] cloud-init[928]: Cloud-init v. 25.1.4-0ubuntu0~24.04.1 running 'modules:config' at Wed, 11 Feb 2026 07:30:41 +0000. Up 8.92 seconds.
[ OK ] Started ModemManager.service - Modem Manager.
[ OK ] Started snapd.service - Snap Daemon.
Starting systemd-timedated.service - Time & Date Service...
[ OK ] Started systemd-timedated.service - Time & Date Service.
[ OK ] Finished pollinate.service - Polli…the pseudo random number generator.
[ OK ] Finished cloud-config.service - Cloud-init: Config Stage.
[ OK ] Finished snapd.seeded.service - Wait until snapd is fully seeded.
[ OK ] Reached target multi-user.target - Multi-User System.
[ OK ] Reached target graphical.target - Graphical Interface.
Starting cloud-final.service - Cloud-init: Final Stage...
Starting systemd-update-utmp-runle…- Record Runlevel Change in UTMP...
[ OK ] Finished systemd-update-utmp-runle…e - Record Runlevel Change in UTMP.
[ 10.276450] cloud-init[984]: Cloud-init v. 25.1.4-0ubuntu0~24.04.1 running 'modules:final' at Wed, 11 Feb 2026 07:30:42 +0000. Up 10.26 seconds.
ci-info: no authorized SSH keys fingerprints found for user ubuntu.
<14>Feb 11 07:30:42 cloud-init: #############################################################
<14>Feb 11 07:30:42 cloud-init: -----BEGIN SSH HOST KEY FINGERPRINTS-----
<14>Feb 11 07:30:42 cloud-init: 256 SHA256:nA0slaF+QOlVPu9fzrTd2VCaiDSSm0zWg5EJF/uwN7w root@ubuntu (ECDSA)
<14>Feb 11 07:30:42 cloud-init: 256 SHA256:PhmR0+Rme5UIYeq3TpuZT18lst7U+dFGIFwnlIb3JXc root@ubuntu (ED25519)
<14>Feb 11 07:30:42 cloud-init: 3072 SHA256:/BFFNPC/V/L3wmt5957JNZfrTZgpoiNagcDBe/zzM/c root@ubuntu (RSA)
<14>Feb 11 07:30:42 cloud-init: -----END SSH HOST KEY FINGERPRINTS-----
<14>Feb 11 07:30:42 cloud-init: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHFYUYj/Zig/3UL/MDDLxKh5aIiVdYdH06qGXuukL8oOZY1zWxaikc+G6PJFTDEQIWa00Sq0s64cZTwhO1EytcM= root@ubuntu
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK7LQSagUxs9UWK0vzDTRq5zMLJSSn/y7tuH/B/FTXbY root@ubuntu
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCka59DA9ON190abLyzDMcV4vOOHY5OU4Bk4d5yykzVNmH3zXVyC4rCxVIFkC2rlV8J8jUv7G7HOcPxewSKbL3iiYJKUqtemjBXg/U/DlU/Ula1Z7Zw3Fwv9Xq5W/5U3CWJrUtPxo61j4PAztcMGQjjoxMxb6RwyDlt9GHqhxGsiULdyleBxGm2ujKm5bC8JG6fO4Op+aScNbUl3lbautdBfseXs35dkK1MwDI6nB5Atrj6P4YoUlEhAJq5gEQgG0O+lzV46jBgYzQ7j48A35uvY7QOJSu3zLO0miiWeFZ7mLXBvHwRCyRcEhuiVx5DIlQqDudwqvCTZheeVEIfsQ1Q8OKZPHtEmiMX9AqaWTWbBG+6GWhMSodgzeFSkaHXRFqnLMTfFWpiQcngpoWVZM3dDf3ilY3/QV2NRZSkXPERr25L7GXk/4N4CAtl52PVCVLsCNvwpvsmOoCU28w9GtOMoCXRkE+IvqPMpx+IUWW6rN8/42S5KfHsmtwdnbqYScs= root@ubuntu
-----END SSH HOST KEY KEYS-----
[ 10.319150] cloud-init[984]: Cloud-init v. 25.1.4-0ubuntu0~24.04.1 finished at Wed, 11 Feb 2026 07:30:42 +0000. Datasource DataSourceNoCloud [seed=/dev/vdb]. Up 10.31 seconds
[ OK ] Finished cloud-final.service - Cloud-init: Final Stage.
[ OK ] Reached target cloud-init.target - Cloud-init target.
[ OK ] Removed slice system-modprobe.slice - Slice /system/modprobe.
[ OK ] Stopped target cloud-init.target - Cloud-init target.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.