-
Notifications
You must be signed in to change notification settings - Fork 35
update cloud-init clean cmdline remove additional network, machine-id and cloud artifacts #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the clean() method to leverage newer cloud-init clean options (--machine-id and -c all) introduced in cloud-init version 23.1, with a fallback mechanism for older cloud-init versions that don't support these parameters.
Changes:
- Updated
BaseInstance.clean()to usecloud-init clean --logs --machine-id -c allby default - Added fallback logic to retry with
cloud-init clean --logsif the-c alloption is unrecognized - Added comprehensive unit tests covering success, fallback, and edge cases
- Version bumped to 1!10.17.0
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pycloudlib/instance.py | Updated clean method to use new cloud-init options with fallback for older versions |
| tests/unit_tests/test_instance.py | Added TestClean class with unit tests covering various scenarios for the updated clean method |
| VERSION | Bumped version from 1!10.16.0 to 1!10.17.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bb81156 to
fff8d87
Compare
fff8d87 to
a47f483
Compare
9fe8fd7 to
cdd8b05
Compare
| # [1] https://github.com/canonical/cloud-init/commit/abfdf1d83995cc20e | ||
| self.execute("sudo cloud-init clean --logs") | ||
| self.execute("sudo echo 'uninitialized' > /etc/machine-id") | ||
| result = self.execute("sudo cloud-init clean --logs --machine-id -c all") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC: @hammerstefan @uhryniuk. Hello CPC folks, just wanted to raise awareness that this move represents moving toward image support for images with cloud-init > 23.4. This shouldn't break anything CPC side for testing because it falls back to original behavior, but it raises a question or two:
- Does CPC test infra run any tests actively against images earlier than focal with updates?
- Is there any CPC image build operation that invokes
cloud-init cleanwhich could benefit from additional--machine-id -c allparams?
tox -e formatlocally to automatically format my code before submittingtoxlocally ensuring that it passes before submittingDescription
Add functionality to use new cloud-init clean params to remove stale cloud-init artifacts from previous boots.
Retain fallback for older versions of cloud-init which may not yet support the
-c allparam.cloud-init version 23.1 introduced new commandline options to cloud-init clean:
--machine-idto uninitialize /etc/machine-id-c allwhich remove previous boot artifacts such as /etc/netplan/50-cloud-init.yaml and and cloud artifacts (generated by azure)Additional Context and Relevant Issues
Test Steps