Bug 2075673
Summary: | Attempt to disable a Red Hat Repository fails with error "Cannot delete record because of dependent library_instances_inverse" if the repository is part of any CV versions in Satellite 6.10 | |||
---|---|---|---|---|
Product: | Red Hat Satellite | Reporter: | Sayan Das <saydas> | |
Component: | Repositories | Assignee: | satellite6-bugs <satellite6-bugs> | |
Status: | CLOSED ERRATA | QA Contact: | Cole Higgins <chiggins> | |
Severity: | high | Docs Contact: | ||
Priority: | high | |||
Version: | 6.10.4 | CC: | ahumbe, dhjoshi, hyu, iballou, jpasqual, juwatts, osousa, rcavalca, sajha, tasander | |
Target Milestone: | 6.11.1 | Keywords: | PrioBumpGSS, Triaged | |
Target Release: | Unused | |||
Hardware: | All | |||
OS: | All | |||
Whiteboard: | ||||
Fixed In Version: | tfm-rubygem-katello-4.3.0.43-1 | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 2103106 (view as bug list) | Environment: | ||
Last Closed: | 2022-07-27 17:27:09 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: |
Description
Sayan Das
2022-04-14 20:14:41 UTC
I am able to reproduce it with simple steps below: 1) Enable a repository and sync it. 2) Create a content view and add the repository to it, and then publish the first version. 3) Remove the repository from the content view. 4) Disable the repository. Actual: Id: 1fc34c83-a653-41c9-9789-6e849e4a54c5 Label: Actions::Katello::RepositorySet::DisableRepository Status: paused Resume Result: error Started at: 2022-06-16 04:52:27 UTC In Finalize tab: 10: Actions::Katello::Repository::Destroy (error) [ 0.11s / 0.11s ] Skip Queue: default Started at: 2022-06-16 04:52:43 UTC Ended at: 2022-06-16 04:52:44 UTC Real time: 0.11s Execution time (excluding suspended state): 0.11s Input: --- repository: id: 285 name: Red Hat Satellite Tools 6.10 for RHEL 7 Desktop RPMs x86_64 label: Red_Hat_Satellite_Tools_6_10_for_RHEL_7_Desktop_RPMs_x86_64 <snip> Output: --- {} Error: ActiveRecord::DeleteRestrictionError Cannot delete record because of dependent library_instances_inverse --- - "/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/associations/has_many_association.rb:16:in `handle_dependency'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/associations/builder/association.rb:129:in `block in add_destroy_callbacks'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:428:in `instance_exec'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:428:in `block in make_lambda'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:604:in `catch'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:604:in `block in default_terminator'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:201:in `block in halting'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:513:in `block in invoke_before'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:513:in `each'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:513:in `invoke_before'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:134:in `run_callbacks'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:825:in `_run_destroy_callbacks'" - "/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/callbacks.rb:309:in `destroy'" <snip> Expected: Should give "Repository cannot be deleted since it has already been included in a published Content View" message and don't run "Actions::Katello::RepositorySet::DisableRepository" task. Demonstrate in foreman-rake console --------------------------------------- foreman-rake console irb(main):050:0> repo = Katello::Repository.find(285) => #<Katello::Repository id: 285, pulp_id: "df009c0e-2352-40c1-b0e8-788d046cb99d", library_instance_id: nil, content_view_version_i... irb(main):051:0> repo.library_instances_inverse.map(&:relative_path) => ["redhat/content_views/cv_clone_test_1/1.0/content/dist/rhel/client/7/7Client/x86_64/sat-tools/6.10/os", "redhat/Library/cv_clone_test_1/content/dist/rhel/client/7/7Client/x86_64/sat-tools/6.10/os"] irb(main):052:0> repo.destroy Traceback (most recent call last): 2: from lib/tasks/console.rake:5:in `block in <top (required)>' 1: from (irb):52 ActiveRecord::DeleteRestrictionError (Cannot delete record because of dependent library_instances_inverse) exit --------------------------------------- @hyu , At step 3: 3) Remove the repository from the content view. We simply remove the repo but don't republish the CV right and that is what triggers the error during disable the action of the repo? This means whichever user faced this issue with a repo, At some point, they must have removed the affected repo from CV but a republish of CV was not done but straightaway it was attempted to disable the repo ? -- Sayan This is the issue. The "self.content_views.generated_for_none.exists?" is false, so the "deletable?" method will return true even the "self.promoted?" is true. ---------------------------------- module Katello module Authorization::Repository extend ActiveSupport::Concern delegate :editable?, to: :product def deletable? product.editable? && (!promoted? || !self.content_views.generated_for_none.exists?) <============ end def redhat_deletable? (!self.promoted? || !self.content_views.generated_for_none.exists?) && self.product.editable? <============ end ---------------------------------- Code in Satellite 6.9 ---------------------------------- module Katello module Authorization::Repository extend ActiveSupport::Concern delegate :editable?, to: :product def deletable? product.editable? && !promoted? end def redhat_deletable? !self.promoted? && self.product.editable? end ---------------------------------- (In reply to Sayan Das from comment #12) > @hyu , > > At step 3: > > 3) Remove the repository from the content view. > > We simply remove the repo but don't republish the CV right and that is what > triggers the error during disable the action of the repo? > > I think this doesn't matter as long as you don't delete the first published version which is still associating with the repo. Created redmine issue https://projects.theforeman.org/issues/35073 from this bug Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/35073 has been resolved. *** Bug 2102260 has been marked as a duplicate of this bug. *** Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Satellite 6.11.1 Async Bug Fix Update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2022:5742 |