Bug 52029 - Bug in downstream altlinux
Summary: Bug in downstream altlinux
Status: CLOSED FIXED
Alias: None
Product: Branch p11
Classification: Unclassified
Component: cloud-init (show other bugs)
Version: unspecified
Hardware: x86_64 Linux
: P5 normal
Assignee: qa-team@altlinux.org
QA Contact: qa-p11@altlinux.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-12 23:09 MSK by Brett Holman
Modified: 2024-12-16 19:55 MSK (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brett Holman 2024-11-12 23:09:56 MSK
The lxd ci[1] noticed an issue in ALT linux's cloud-init package. The issue is caused by code that does not exist in upstream cloud-init:

```
Traceback (most recent call last):
  File "/usr/lib/python3/site-packages/cloudinit/config/modules.py", line 286, in _run_modules
    ran, _r = cc.run(
              ^^^^^^^
  File "/usr/lib/python3/site-packages/cloudinit/cloud.py", line 71, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/site-packages/cloudinit/helpers.py", line 156, in run
    results = functor(**args)
              ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/site-packages/cloudinit/config/cc_update_hostname.py", line 62, in handle 
    cloud.distro.update_hostname(hostname, fqdn, prev_fn)
  File "/usr/lib/python3/site-packages/cloudinit/distros/__init__.py", line 546, in update_hostname
    prev_hostname = self._read_hostname(prev_hostname_fn)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/site-packages/cloudinit/distros/altlinux.py", line 154, in _read_hostname
    return util.load_file(filename).strip()
           ^^^^^^^^^^^^^^ 
AttributeError: module 'cloudinit.util' has no attribute 'load_file'
```

It looks like ALT's distro never made it into upstream, so a recent change in upstream util.py broke ALT's distro definition. It should be easy to update to use the new function name. If you're interested in getting the distro defintion into upstream, that would help prevent future breakage like this.

[1] https://github.com/canonical/lxd-ci/pull/344
Comment 1 Brett Holman 2024-11-12 23:19:52 MSK
I was able to reproduce the issue by undoing the change in the PR linked below. 

To reproduce, basically just undo the effects of the PR in a container, then `cloud-init reboot -h now` to simulate first boot, then reboot the container and see the error. Something like this:

```
$ lxc launch images:alt/p11/cloud alt-p11
[root@alt-p11 ~]# # re-introduce update_hostname to /etc/cloud/cloud.cfg
[root@alt-p11 ~]# # ...
[root@alt-p11 ~]# cloud-init clean --logs --reboot
$ lxc shell alt-p11
[root@alt-p11 ~]# reboot -h now
[root@alt-p11 ~]# # now view the errors
[root@alt-p11 ~]# cloud-init status --long
[root@alt-p11 ~]# # and for more detail:
[root@alt-p11 ~]# vi /var/log/cloud-init.log
```
Comment 2 Alexander Stepchenko 2024-12-16 11:39:18 MSK
cloud-init-24.2-alt2 -> p11

* Fri Nov 22 2024 Alexander Stepchenko <geochip@altlinux.org> 24.2-alt2
- NMU: Fix update_hostname module (Closes: 52029)
Comment 3 Brett Holman 2024-12-16 19:55:01 MSK
Fix confirmed. The workaround was removed from upstream lxd[1].

[1] https://github.com/canonical/lxd-ci/pull/369