-
Notifications
You must be signed in to change notification settings - Fork 908
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
fix(apt_configure): disable source.list if rendering deb822 #4699
Conversation
3f7a6f9
to
d9d9fad
Compare
I'm not certain this is the fix we want. In noble, cloud-init doesn't appear to actually be writing |
That is true and has been like that for previous Ubuntu releases, I believe. Cloud-init did and is overwriting
|
Agreed here, we know that there is work in progress to make sure CPC image builds do not leave this config artifact around on images with cloud-init installed. But, that would only cover the Ubuntu cloud image case for migration to an APT deb822 compatible system. Since we know cloud-init needs to support any debian derivative, we still need to cover the case where new cloud-init which wants to write deb822 format is running in some debian image which contains an old As you mentioned, we don't want to perform We also should rule out |
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.
@aciba90 thank you for clarifying the use-cases we want to cover here. I think a minor adjustment to the file suffix we use when renaming, and a breadcrumb comment in the file to notify that cloud-init migrated it would be helpful.
Thanks for covering the more generic cases outside of Ubuntu cloud image builds.
cloudinit/config/cc_apt_configure.py
Outdated
util.write_file(aptsrc_file, disabled, mode=0o644) | ||
if disable_apt_sources_list: | ||
LOG.debug("Disabling %s", apt_sources_list) | ||
util.rename(apt_sources_list, f"{apt_sources_list}.old") |
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.
I think we want to rename this .disabled
instead of .old
as a best practice for preserved and ignored apt sources files as we see apt ignores these files by default `
$ apt-config dump | grep disable
Dir::Ignore-Files-Silently:: "\.disabled$";
I think we may also want to add a header line # disabled by cloud-init
to this file to leave a breadcrumb for why this rename happened
General idea looks good, i think we need unittest coverage for this case and a minor addition to the existing integration test tests/integration_tests/modules/test_apt_functionality.py to assert that we don't see warnings about duplicate apt sources being found on any series as well as that we see the |
d9d9fad
to
d345aca
Compare
Thanks, @blackboxsw, for the comments and suggestions! I have addressed them and this PR is ready to be re-reviewed. |
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.
Thanks for the integration test and unittest coverage. +1 with a minor nit in integration test.
I'll apply it and land it. it'd be good to get an upload from main into noble to help out customers affected by this warning.
assert ( | ||
class_client.execute(f"ls {ORIG_SOURCES_FILE}").return_code | ||
!= 0 | ||
) |
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.
Just a minor improvement to error message traceback.
assert ( | |
class_client.execute(f"ls {ORIG_SOURCES_FILE}").return_code | |
!= 0 | |
) | |
assert class_client.execute( | |
f"test -f {ORIG_SOURCES_FILE}" | |
).failed, f"Found unexpected {ORIG_SOURCES_FILE}" |
If deb822 sources format is used and a preexistent /etc/apt/sources.list exists, then disable the old sources file. This prevents user-facing warnings while operating with apt or apt-get and other possible conflicts. This is safe to do as cloud-init owns the base APT configuration which tipically/historically involved overwriting /etc/apt/sources.list
cc4864c
to
198c190
Compare
Proposed Commit Message
Additional Context
I think it is safe to disable
/etc/apt/source.list
, because previously cloud-init override it, before #4437, or now if features.APT_DEB822_SOURCE_LIST_FILE is false or if the provided sources config has the classic style.#4691
Test Steps
Checklist
Merge type