-
Notifications
You must be signed in to change notification settings - Fork 284
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
Fixes #36638 - Allow metadata regenerate with --force flag on API/Hammer #10681
Conversation
Issues: #36638 |
57745f3
to
fe62c64
Compare
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 @sjha4
Everything works as advertised, except this:
Seems the hammer error message here includes all mirror-complete repos:
Could not republish the Content View:
Metadata republishing is dangerous on content view versions with repositories with the 'Complete Mirroring' mirroring policy.
Update mirroring policies on these repositories ["Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8", "Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8", "JustinComplete"] or Use 'force' parameter to stop mirroring upstream metadata and regenerate metadata locally.
But I don't have the RHEL ones included in the content view:
mirror_complete_repos = @content_view_version.repositories.joins(:root).where(root: { mirroring_policy: ::Katello::RootRepository::MIRRORING_POLICY_COMPLETE }) | ||
if mirror_complete_repos.size > 0 && !::Foreman::Cast.to_bool(params[:force]) | ||
fail HttpErrors::BadRequest, _("Metadata republishing is dangerous on content view versions with repositories with the 'Complete Mirroring' mirroring policy. | ||
Update mirroring policies on these repositories #{mirror_complete_repos.pluck(:name)} or Use 'force' parameter to stop mirroring upstream metadata and regenerate metadata locally.") |
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.
Update mirroring policies on these repositories #{mirror_complete_repos.pluck(:name)} or Use 'force' parameter to stop mirroring upstream metadata and regenerate metadata locally.") | |
Update mirroring policies on these repositories #{mirror_complete_repos.pluck(:name)}, or use the 'force' parameter to stop mirroring upstream metadata and regenerate metadata locally.") |
fail HttpErrors::BadRequest, _("Metadata republishing is not allowed on repositories with the 'Complete Mirroring' mirroring policy.") | ||
if @repository.mirroring_policy == Katello::RootRepository::MIRRORING_POLICY_COMPLETE && !::Foreman::Cast.to_bool(params[:force]) | ||
fail HttpErrors::BadRequest, _("Metadata republishing is dangerous on repositories with the 'Complete Mirroring' mirroring policy. | ||
Change mirroring policy on the repository and try again or use 'force' parameter via hammer/API to stop mirroring upstream metadata and regenerate metadata locally.") |
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.
Change mirroring policy on the repository and try again or use 'force' parameter via hammer/API to stop mirroring upstream metadata and regenerate metadata locally.") | |
Change the mirroring policy on the repository and try again, or use the 'force' parameter to stop mirroring upstream metadata and regenerate metadata locally.") |
fe62c64
to
528b503
Compare
app/controllers/katello/api/v2/content_view_versions_controller.rb
Outdated
Show resolved
Hide resolved
528b503
to
2108375
Compare
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.
ACK 👍
What are the changes introduced in this pull request?
The plan for Regenerating metadata on "complete_mirroring" is as follows:
a) Disallowed on the UI : Republishing on UI on repos and cv versions with complete_mirroring repos will not be allowed.
b) Allowed in hammer : only with
--force true
Considerations taken when implementing this change?
We want to discourage users from republishing metadata locally on Pulp for repositories with complete mirroring. Disallowing on UI and only allowing via hammer/api with --force flag makes it so.
What are the testing steps for this pull request?
Check
hammer -r repository republish --id $REPO_ID --force false
vshammer -r repository republish --id $REPO_ID --force true
hammer -r content-view version republish-repositories --id $VERSION_ID --force 1
andhammer -r content-view version republish-repositories --id $VERSION_ID --force 0