Skip to content

chore(apt): remove unused apt key listing code - #7113

Merged
holmanb merged 1 commit into
canonical:mainfrom
wak327:chore/remove-unused-apt-key-list
Oct 7, 2026
Merged

holmanb merged 1 commit into
canonical:mainfrom
wak327:chore/remove-unused-apt-key-list

Conversation

@wak327

@wak327 wak327 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Commit Message

chore(apt): remove unused apt key listing code

apt_key() implemented 'list' and 'finger' commands next to 'add', but
nothing calls them: add_apt_key_raw() is the only caller of apt_key()
and it only ever adds keys. Rather than fix the listing logic, which
assumes every file under /etc/apt/trusted.gpg.d/ is a keyring, drop it
together with GPG.list_keys(), which only existed to serve it.

Fixes GH-5333

Additional Context

Fixes #5333

This follows the suggestion in GH-5333 to delete the code rather than fix it. The only call site of apt_key() passes "add", and nothing else uses GPG.list_keys(). APT_LOCAL_KEYS stays because tests/integration_tests/modules/test_apt_functionality.py still uses it.

apt_key() now raises ValueError for any command other than "add", and a new test covers this. test_kill_gpg_succeeds only called list_keys() to "start" gpg, so it now calls dearmor() for that instead.

Verified with the pinned black, isort, ruff, pylint and mypy, and the full unit suite passes (5,775 tests).

Test Steps

tox -e py3 -- tests/unittests/config/test_apt_key.py tests/unittests/test_gpg.py tests/unittests/config/

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

apt_key() implemented 'list' and 'finger' commands next to 'add', but
nothing calls them: add_apt_key_raw() is the only caller of apt_key()
and it only ever adds keys. Rather than fix the listing logic, which
assumes every file under /etc/apt/trusted.gpg.d/ is a keyring, drop it
together with GPG.list_keys(), which only existed to serve it.

Fixes canonicalGH-5333
@wak327
wak327 force-pushed the chore/remove-unused-apt-key-list branch from 19caaf7 to f2a3348 Compare September 30, 2026 20:10

@nryanl nryanl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! Looks good to me.

@wak327

wak327 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @nryanl! The CI workflows haven't run on this PR yet, they're all waiting for maintainer approval since this is my first contribution to cloud-init. @nryanl @holmanb could one of you approve the workflow runs here and on #7114, #7115, #7116, #7122 and #7123? The CLA check should pass now that I've signed it.

@holmanb holmanb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup work, @wak327!

@holmanb
holmanb merged commit 84319ec into canonical:main Oct 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Listing apt keys doesn't work after apt-file deprecation

3 participants