Project

General

Profile

Actions

Bug #35073

closed

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

Added by Samir Jha over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Repositories
Target version:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2075673

Description of problem:

If an RH repository is part if one or more CV versions, then an attempt to disable the same should actually not trigger any deletion but show the message "Repository cannot be deleted since it has already been included in a published Content View".

The standard guideline here is that follow https://access.redhat.com/solutions/3180551 to identify the affected CV versions, remove them and then disable the repo.

But in certain customer environments of Satellite 6.10, That message never appears but instead, the deletion of the repo gets started and after 70% progress the task will go to Paused state with the error:
~
Cannot delete record because of dependent library_instances_inverse
~

Version-Release number of selected component (if applicable):

Red Hat Satellite 6.10.4

How reproducible:

In customer environment

Steps to Reproduce:
1.
2.
3.

Actual results:

No such messages like "Repository cannot be deleted since it has already been included in a published Content View" neither in UI nor in the tasl.

Repo disable task in paused state with error "Cannot delete record because of dependent library_instances_inverse"

2022-04-13T14:32:06 [I|bac|319bca91] Task {label: Actions::Katello::RepositorySet::DisableRepository, id: bd4b4830-a2d7-4873-b82b-08930303d0d5, execution_plan_id: 651c0ff7-dcd2-43d6-bd46-d0efeac1d261} state changed: running
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on pulp_id 344d38ae-0cf2-40e8-a4ba-82dad873005e
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on library_instance_id
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on content_view_version_id 1
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on relative_path Crown_Equipment_Corporation/Library/content/dist/rhel/server/7/7Server/x86_64/ansible/2.6/os
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on environment_id 1
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on saved_checksum_type
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on distribution_version
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on distribution_arch
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on distribution_bootable
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on distribution_family
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on distribution_variant
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on container_repository_name
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on root_id 40
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on remote_href /pulp/api/v3/remotes/rpm/rpm/a1ee81ac-ef79-4f9e-9fcf-1fae9d28c386/
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on publication_href /pulp/api/v3/publications/rpm/rpm/657df4a7-3ac8-48b0-96ca-db109912ece2/
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on version_href /pulp/api/v3/repositories/rpm/rpm/a2345c38-2b09-4a96-bf87-692f432e6d07/versions/1/
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on last_contents_changed 1969-12-31 19:00:00 -0500
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on last_applicability_regen 1969-12-31 19:00:00 -0500
2022-04-13T14:32:07 [I|aud|319bca91] Katello::Repository (258) destroy event on last_indexed 1969-12-31 19:00:00 -0500
2022-04-13T14:32:07 [E|bac|319bca91] Cannot delete record because of dependent library_instances_inverse (ActiveRecord::DeleteRestrictionError)
319bca91 | /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'
319bca91 | /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'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/callbacks.rb:428:in `instance_exec'

..
..
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:310:in `destroy'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/models/katello/model.rb:23:in `destroy!'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/katello/repository/destroy.rb:67:in `delete_record'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/katello/repository/destroy.rb:41:in `finalize'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action.rb:594:in `block (2 levels) in execute_finalize'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware/stack.rb:27:in `pass'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware.rb:19:in `pass'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/middleware/remote_action.rb:20:in `block in finalize'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/middleware/remote_action.rb:40:in `block in as_remote_user'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/models/katello/concerns/user_extensions.rb:21:in `cp_config'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/middleware/remote_action.rb:27:in `as_cp_user'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/middleware/remote_action.rb:39:in `as_remote_user'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/middleware/remote_action.rb:20:in `finalize'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware/stack.rb:23:in `call'
319bca91 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/middleware/stack.rb:27:in `pass'

Expected results:

Repo disable task should show "Repository cannot be deleted since it has already been included in a published Content View" and should not initiate the plan for deletion.

Additional info:

I was able to reproduce the behavior but not the error "Cannot delete record because of dependent library_instances_inverse".

The behavior can only be reproduced by commenting out "check_destroyable!(repository)" from /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.52/app/lib/actions/katello/repository/destroy.rb , restart of satellite services and then try to disable the repo from Content --> Red Hat Repositories page.

Even though the behavior remains the same i.e. The plan executes till 70% and then the task goes into the paused state, The error message is not the same. Instead, i can only see "Repository cannot be deleted since it has already been included in a published Content View".

Anyways, this is really dangerous. The expectation is that if a repo is part of any CV, then trying to disable the repo from the Content --> Red Hat Repositories page, should not execute any deletion plan but simply show the message from https://access.redhat.com/solutions/3180551. But if the plan is getting executed without showing this error, then we have a bug problem gere.

Actions #1

Updated by The Foreman Bot over 2 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Samir Jha
  • Pull request https://github.com/Katello/katello/pull/10168 added
Actions #2

Updated by Chris Roberts over 2 years ago

  • Subject changed from 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 to 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
  • Target version set to Katello 4.5.0
  • Triaged changed from No to Yes
Actions #3

Updated by The Foreman Bot over 2 years ago

  • Fixed in Releases Katello 4.5.1 added
Actions #4

Updated by Samir Jha over 2 years ago

  • Status changed from Ready For Testing to Closed
Actions #5

Updated by The Foreman Bot about 2 years ago

  • Pull request https://github.com/Katello/katello/pull/10186 added
Actions

Also available in: Atom PDF