The BZ is now public. However, there is only one suggestion that is private that might help solving the problem, so I am pasting it here:
```
Firstly, IMO, empty '/var/lib/cloud/data/set-hostname' is indeed an exception/case that cloud-init should handle properly than leave the service failed directly.
Back to this issue, hard reboot during boot or trigger sysrq b immediately when system boot up. The content of set-hostname lost after system boot up.
It seems that the content did not synced to disk when system reset.
Here is the instructions of sysrq b.
``b`` Will immediately reboot the system without syncing or unmounting
your disks.
Below information shows that set-hostname already has content before reset, but it is 0 after boot again.
2022-11-08 01:49:17,759 - util.py[DEBUG]: Reading from /var/lib/cloud/data/set-hostname (quiet=False)
2022-11-08 01:49:17,759 - util.py[DEBUG]: Read 88 bytes from /var/lib/cloud/data/set-hostname
2022-11-08 01:49:17,759 - cc_set_hostname.py[DEBUG]: No hostname changes. Skipping set-hostname
2022-11-08 02:33:58,585 - util.py[DEBUG]: Reading from /var/lib/cloud/data/set-hostname (quiet=False)
2022-11-08 02:33:58,585 - util.py[DEBUG]: Read 0 bytes from /var/lib/cloud/data/set-hostname
Not sure if turn off buffering is helpful to mitigate this, but I did not reproduce this issue after 10+ retry times.
The BZ is now public. However, there is only one suggestion that is private that might help solving the problem, so I am pasting it here:
``` cloud/data/ set-hostname' is indeed an exception/case that cloud-init should handle properly than leave the service failed directly.
Firstly, IMO, empty '/var/lib/
Back to this issue, hard reboot during boot or trigger sysrq b immediately when system boot up. The content of set-hostname lost after system boot up.
It seems that the content did not synced to disk when system reset.
Here is the instructions of sysrq b.
``b`` Will immediately reboot the system without syncing or unmounting
your disks.
Below information shows that set-hostname already has content before reset, but it is 0 after boot again. cloud/data/ set-hostname (quiet=False) cloud/data/ set-hostname hostname. py[DEBUG] : No hostname changes. Skipping set-hostname cloud/data/ set-hostname (quiet=False) cloud/data/ set-hostname
2022-11-08 01:49:17,759 - util.py[DEBUG]: Reading from /var/lib/
2022-11-08 01:49:17,759 - util.py[DEBUG]: Read 88 bytes from /var/lib/
2022-11-08 01:49:17,759 - cc_set_
2022-11-08 02:33:58,585 - util.py[DEBUG]: Reading from /var/lib/
2022-11-08 02:33:58,585 - util.py[DEBUG]: Read 0 bytes from /var/lib/
Not sure if turn off buffering is helpful to mitigate this, but I did not reproduce this issue after 10+ retry times.
# diff -u /usr/lib/ python3. 9/site- packages/ cloudinit/ atomic_ helper. py /usr/lib/ python3. 9/site- packages/ cloudinit/ atomic_ helper. py.orig python3. 9/site- packages/ cloudinit/ atomic_ helper. py 2022-11-08 08:17:56.262679073 +0000 python3. 9/site- packages/ cloudinit/ atomic_ helper. py.orig 2022-11-08 08:17:03.722890860 +0000 NamedTemporaryF ile( path.dirname( filename) , delete=False, mode=omode, buffering=0 path.dirname( filename) , delete=False, mode=omode
--- /usr/lib/
+++ /usr/lib/
@@ -25,7 +25,7 @@
tf = None
try:
tf = tempfile.
- dir=os.
+ dir=os.
)
```