fix(ug_util): prioritize user-data.users over the default user config#6860
fix(ug_util): prioritize user-data.users over the default user config#6860mostafaCamel wants to merge 11 commits into
Conversation
|
The first commit I pushed is failing as expected as I only added the unit test The expected failure TOTAL 33026 6291 12224 1597 79%
=========================== short test summary info ============================
FAILED tests/unittests/distros/test_user_data_normalize.py::TestUGNormalize::test_users_dict_override_default_attribute - assert True is False
= 1 failed, 5641 passed, 5 skipped, 13 xfailed, 2 xpassed, 84 warnings in 118.45s (0:01:58) =
py3: exit 1 (129.32 seconds) /home/runner/work/cloud-init/cloud-init> .tox/py3/bin/python -m pytest -vv --cov=cloudinit --cov-branch --color=yes pid=2384
py3: FAIL code 1 (135.99=setup[6.67]+cmd[129.32] seconds)
evaluation failed :( (136.04 seconds)
Error: Process completed with exit code 1. |
|
After pushing the code fix, all the unit tests now pass |
holmanb
left a comment
There was a problem hiding this comment.
Please add an integration test.
|
Note to myself about the integration tests (will work on it the weekend):
|
… default user config Signed-off-by: Mostafa Abdelwahab <mostafa.abdelwahab@canonical.com>
Signed-off-by: Mostafa Abdelwahab <mostafa.abdelwahab@canonical.com>
74bc21d to
151d862
Compare
|
Pushed a new commit with the integration tests:
The integration test succeeded locally I ran again the integration test locally qith questing to amtch the CI and the local test still succeeds |
|
I confirmed that the debian package generated in the CI task (link in the comment above) contains my change
So normally this should lead to the code being ingested in the CI tests given that the |
|
Pushed a commit with some additional prints. Confirmed that I am running the debain package |
|
Also, worth noting that this behavior also applies to the override of the password locking. CI failed as well when I commented out the shell assertion |
Signed-off-by: Mostafa Abdelwahab <mostafa.abdelwahab@canonical.com>
|
Still failing with the same error even after I added a commit to cloud-init clean then reboot then starting the test assertions. My guess the only proper way to test the behavior is to have CLOUD_INIT_SOURCE as None (use the code in the image) or IN_PLACE (inject the changes into lxd containers.I filed #6885 |
|
Hi again @holmanb , tldr: I added integration tests. One of them is failing CI (but succeeding locally), I suspect the failure is because default user settings cannot be changed post-first-boot. The CI test is even failing after I added a cloud-init clean then reboot then doing the test assertions. I guess my options are one of:
You can verify that this test works locally by checking out my branch and running |
|
The following commit (where I clean seed before the reboot and the test assertion did not help. Same assertion failure |
|
I will stop trying for now. Could it be that |
|
hopefully final TLDR:
My wild guess at this point that even after I atttached the bug CI logs below because I do not know the retention time of the CI job ------------------------------ Captured log call -------------------------------
2026-05-17 15:04:14 INFO pycloudlib.instance:instance.py:285 executing: sh -c 'sudo cloud-init clean --logs'
2026-05-17 15:04:14 DEBUG pycloudlib.instance:instance.py:289 executing: sh -c 'sudo cloud-init clean --logs'
2026-05-17 15:04:15 INFO pycloudlib.instance:instance.py:285 executing: sh -c 'sudo echo '"'"'uninitialized'"'"' > /etc/machine-id'
2026-05-17 15:04:15 DEBUG pycloudlib.instance:instance.py:289 executing: sh -c 'sudo echo '"'"'uninitialized'"'"' > /etc/machine-id'
2026-05-17 15:04:15 INFO pycloudlib.instance:instance.py:285 executing: sh -c 'sudo rm -rf /var/log/syslog'
2026-05-17 15:04:15 DEBUG pycloudlib.instance:instance.py:289 executing: sh -c 'sudo rm -rf /var/log/syslog'
2026-05-17 15:04:15 INFO integration_testing:instances.py:85 Restarting instance and waiting for boot
2026-05-17 15:04:15 INFO pycloudlib.instance:instance.py:285 executing: sh -c sync
2026-05-17 15:04:15 DEBUG pycloudlib.instance:instance.py:289 executing: sh -c sync
2026-05-17 15:04:18 DEBUG pycloudlib.instance:instance.py:132 Pre-reboot boot_id: de41cf7e-bba2-44bb-965e-8b1f198a11a6
2026-05-17 15:04:18 DEBUG pycloudlib.instance:instance.py:362 restarting cloudinit-0517-150406snkpcmpd
2026-05-17 15:04:22 INFO pycloudlib.instance:instance.py:512 _wait_for_execute to complete
2026-05-17 15:04:22 DEBUG pycloudlib.instance:instance.py:103 Unable to find valid IP. Found network: {'eth0': {'addresses': [{'address': 'fe80::216:3eff:fe22:d3dc', 'family': 'inet6', 'netmask': '64', 'scope': 'link'}], 'counters': {'bytes_received': 272, 'bytes_sent': 266, 'errors_received': 0, 'errors_sent': 0, 'packets_dropped_inbound': 0, 'packets_dropped_outbound': 0, 'packets_received': 2, 'packets_sent': 3}, 'host_name': 'vethed221a87', 'hwaddr': '00:16:3e:22:d3:dc', 'mtu': 1500, 'state': 'up', 'type': 'broadcast'}, 'lo': {'addresses': [{'address': '127.0.0.1', 'family': 'inet', 'netmask': '8', 'scope': 'local'}, {'address': '::1', 'family': 'inet6', 'netmask': '128', 'scope': 'local'}], 'counters': {'bytes_received': 0, 'bytes_sent': 0, 'errors_received': 0, 'errors_sent': 0, 'packets_dropped_inbound': 0, 'packets_dropped_outbound': 0, 'packets_received': 0, 'packets_sent': 0}, 'host_name': '', 'hwaddr': '', 'mtu': 65536, 'state': 'up', 'type': 'loopback'}}
2026-05-17 15:04:23 INFO paramiko.transport:transport.py:1786 Connected (version 2.0, client OpenSSH_10.0p2)
2026-05-17 15:04:23 INFO paramiko.transport:transport.py:1786 Authentication (publickey) successful!
2026-05-17 15:04:24 INFO pycloudlib.instance:instance.py:532 _wait_for_cloudinit to complete
2026-05-17 15:04:24 INFO pycloudlib.instance:instance.py:285 executing: sh -c 'command -v systemctl'
2026-05-17 15:04:24 DEBUG pycloudlib.instance:instance.py:289 executing: sh -c 'command -v systemctl'
2026-05-17 15:04:25 INFO pycloudlib.instance:instance.py:285 executing: cloud-init status --wait --long
2026-05-17 15:04:25 DEBUG pycloudlib.instance:instance.py:287 waiting for start
2026-05-17 15:04:25 INFO pycloudlib.instance:instance.py:285 executing: sudo -- sh -c 'cloud-init status'
2026-05-17 15:04:25 DEBUG pycloudlib.instance:instance.py:289 executing: sudo -- sh -c 'cloud-init status'
2026-05-17 15:04:26 INFO pycloudlib.instance:instance.py:285 executing: sudo -- sh -c 'cloud-init status --wait'
2026-05-17 15:04:26 DEBUG pycloudlib.instance:instance.py:289 executing: sudo -- sh -c 'cloud-init status --wait'
2026-05-17 15:04:26 INFO pycloudlib.instance:instance.py:285 executing: sudo -- getent passwd ubuntu |
|
Silly me. The problem was that I was using |
|
Ok, final comment: tests now succeed locally and github CI. No need for a cloud-init clean then restart.
|
Proposed Commit Message
Additional Context
Test Steps
Unit tests
tox -e py3 -- tests/unittests/distros/test_user_data_normalize.py::TestUGNormalizeIntegration tests
~/.config/pycloudlib.tomlfile and put[lxd]in this fileCLOUD_INIT_OS_IMAGE='noble' CLOUD_INIT_PLATFORM=lxd_container tox -e integration-tests -- tests/integration_tests/modules/test_users_groups.py tests/integration_tests/modules/test_set_password.pyMerge type