Resolve packages exporter sign key deterministically - #1251
Open
anfimovdm wants to merge 1 commit into
Open
Conversation
The exporter picked the platform's signing key with next() over get_sign_keys(), taking the first match and dropping the rest. Platforms 50 (AlmaLinux-10) and 83 (AlmaLinux-Kitten-10) each have two keys attached - the main distribution key and the EPEL AltArch one - so the key used to sign repodata depended on the order the API returned them. Add -sw/--sign-with to pick a key explicitly, mirroring the flag the products exporter already has. Replace both next() lookups with a shared helper that falls back to the default AlmaLinux 10 key when a platform has several and warns about it, and raises when the ambiguity cannot be resolved that way. Exported platforms are validated right after export so an unresolvable key fails before post-processing and errata generation. Fixes AlmaLinux/build-system#547
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes AlmaLinux/build-system#547
Problem
packages_exporter.pyresolved the repodata signing key withnext(...)overget_sign_keys(), which returns the first match and silently drops the rest.platforms_sign_keysis many-to-many, and platforms 50 (AlmaLinux-10) and 83 (AlmaLinux-Kitten-10) each have two keys attached:DEE5C11CC2A1E572B620C02335D447A6So repodata for those platforms got signed with whichever key came back first — order-dependent, unlogged, and with no way for the operator to override it.
Changes
scripts/exporters/packages_exporter.py:-sw/--sign-with <keyid>— mirrors the flagproducts_exporter.pyalready has. Validated againstget_sign_keys()before any export work; when set it overrides the per-platform lookup for every exported repo, so signing the AltArch repos withB620C02335D447A6is now expressible. An unknown keyid aborts up front.get_platform_sign_key_id()replaces bothnext(...)lookups (the per-repo one insign_repodata()and the--release-idone inmain()):None, as before;DEFAULT_SIGN_KEY_ID(DEE5C11CC2A1E572) → the default, plus a warning naming every candidate;AmbiguousSignKeyErrorpointing at--sign-with.export_repos_from_pulp(), so an unresolvable key surfaces before post-processing, errata, OVAL and RSS generation instead of at the very end of the run. Platforms with no exported repos are skipped, sinceexport_repos_from_pulp()seedsplatforms_dictwith an entry for every non-reference platform.Behaviour
DEE5C11CC2A1E572+ warning naming both--sign-with--sign-withTesting
Key-resolution logic exercised directly against the four-key fixture matching production's
platforms_sign_keysrows: platform 50 and 83 →DEE5C11CC2A1E572with the warning, single-key platform → its own key, unknown platform →None, and a synthetic two-key platform without the default →AmbiguousSignKeyError.The exporter itself was not run end to end — that needs a live DB and sign server. Worth a manual
--platform-names AlmaLinux-10run against staging before merge to confirm the signed repodata carriesDEE5C11CC2A1E572.Note for reviewers
--sign-withapplies to the whole run. Exporting several platforms at once and wanting a different key per platform isn't expressible — that needs separate runs today. Happy to add a per-platform mapping if that's a real workflow.