Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 1343108 - Candlepin removes OwnerResource even when deleting the Organization fails in Satellite
Summary: Candlepin removes OwnerResource even when deleting the Organization fails in ...
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Organizations and Locations
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: Unspecified
Assignee: Partha Aji
QA Contact: Roman Plevka
: 1336004 1340578 1348325 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2016-06-06 13:59 UTC by Roman Plevka
Modified: 2019-09-26 16:19 UTC (History)
8 users (show)

Fixed In Version: foreman-
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2016-07-27 11:25:04 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 15336 0 Normal Closed Org/Location removal results in a ISE 2020-10-27 18:58:33 UTC

Description Roman Plevka 2016-06-06 13:59:52 UTC
Description of problem:
The organization removal task is not atomic:
If the organization has some managed resources associated, its removal will fail:

# hammer -u admin -p changeme organization delete --id 3
[............  ] [95%]
foo is being used by a hidden Host::Managed resource

However, Candlepin manages to remove the Owner:

[candlepin.log - hashes truncated]

2016-06-06 09:34:43,813 [thread=http-8443-2] [req=83f71be1, org=] INFO  org.candlepin.common.filter.LoggingFilter - Request: verb=DELETE, uri=/candlepin/owners/foo
2016-06-06 09:34:43,831 [thread=http-8443-2] [req=83f71be1, org=] INFO  org.candlepin.resource.OwnerResource - Cleaning up owner: Owner [id: 8a90c0b855, key: foo]
2016-06-06 09:34:43,890 [thread=http-8443-2] [req=83f71be1, org=] INFO  org.candlepin.resource.OwnerResource - Deleting owner: Owner [id: 8a90c0b855, key: foo]
2016-06-06 09:34:43,897 [thread=http-8443-2] [req=83f71be1, org=] INFO  org.candlepin.audit.HornetqEventDispatcher - Sending event: Event [id=null, target=OWNER, type=DELETED, time=Mon Jun 06 09:34:43 EDT 2016, entity=8a90c0b855]


This leaves satellite in inconsistent state, where candlepin no longer recognizes the org while it still exists in the DB. Any action involving this organization (even uploading a manifest for other org) ends up in error:

2016-06-06 09:35:00,643 [thread=http-8443-2] [req=1ad875b0, org=] INFO  org.candlepin.common.filter.LoggingFilter - Request: verb=GET, uri=/candlepin/owners/foo
2016-06-06 09:35:00,663 [thread=http-8443-2] [req=1ad875b0, org=] INFO  org.candlepin.resteasy.interceptor.AuthInterceptor - No such entity: Organization id: foo
2016-06-06 09:35:00,664 [thread=http-8443-2] [req=1ad875b, org=] INFO  org.candlepin.common.filter.LoggingFilter - Response: status=404, content-type="application/json", time=21

Version-Release number of selected component (if applicable):
6.2.0 bet (GA14.1)

How reproducible:

Steps to Reproduce:
1. create an organization
2. have a host assigned to this org (you can use the satellite host itself)
3. try to delete this organization (this should fail)
4. try to create a new org and upload a manifest to it (this fails due to missing org above))

Actual results:
- candlepin removes the Org

Expected results:
- candlepin does not remove anything if the removal results in error in satellite (the removal task should be atomic)

Additional info:

Comment 1 sthirugn@redhat.com 2016-06-06 14:13:32 UTC
This error leaves satellite unusable.  This is a blocker for GA.

Comment 2 Roman Plevka 2016-06-06 14:45:45 UTC
To get to a consistent state again, re-assign the host to other organization and resume the `remove organization` task.

Comment 3 Brad Buckingham 2016-06-06 15:23:59 UTC
This bug is related to bug 1336004 and bug 1340578.

Comment 5 Partha Aji 2016-06-07 20:11:07 UTC
Created redmine issue http://projects.theforeman.org/issues/15336 from this bug

Comment 6 Partha Aji 2016-06-07 20:29:43 UTC
being tracked in https://github.com/theforeman/foreman/pull/3576

Comment 7 Roman Plevka 2016-06-07 21:09:08 UTC
(In reply to Partha Aji from comment #6)
> being tracked in https://github.com/theforeman/foreman/pull/3576

Not sure whether this also addresses a scenario, where Organization contains some Lifecycle Environments.
If LCE is assigned to an Organization, this Organization fails to be deleted. Looks like your PR only ensures there are no Hosts assigned to it.

Comment 8 Bryan Kearney 2016-06-07 22:15:52 UTC
Upstream bug component is Provisioning

Comment 9 Bryan Kearney 2016-06-08 08:16:37 UTC
Upstream bug component is Organizations and Locations

Comment 10 Andrii Balakhtar 2016-06-21 10:42:02 UTC
*** Bug 1348325 has been marked as a duplicate of this bug. ***

Comment 11 Mike McCune 2016-06-21 17:52:14 UTC

This bug also requires:


which cleans up the LCE and other objects.

Comment 12 Mike McCune 2016-06-21 17:53:20 UTC
which is tracked here:


Comment 13 Bryan Kearney 2016-06-30 16:15:51 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/15336 has been closed

Comment 14 Partha Aji 2016-07-07 16:51:32 UTC
*** Bug 1336004 has been marked as a duplicate of this bug. ***

Comment 15 Partha Aji 2016-07-07 16:52:25 UTC
*** Bug 1340578 has been marked as a duplicate of this bug. ***

Comment 16 Roman Plevka 2016-07-11 12:07:51 UTC
on sat6.2 snap19.1

This still fails but on different AR:

2016-07-11 07:29:05 [foreman-tasks/action] [E] Cannot delete record because of dependent content_facets (ActiveRecord::DeleteRestrictionError)

- i created a new org and simply assigned a host (which has Default Content View and ) to it.
The only way i was able to resume the Org removal task was to remove the content host.

Comment 17 Partha Aji 2016-07-12 14:09:07 UTC
The failed test is a different scenario handled in https://bugzilla.redhat.com/show_bug.cgi?id=1343795

Comment 18 Mike McCune 2016-07-12 15:04:36 UTC
can we re-test the original scenario in this bug and handle the other scenario outlined in 1343795 separately?

1343795 is aligned to 6.2.z

Comment 19 Roman Plevka 2016-07-12 15:26:57 UTC
on sat6.2 snap19.1

# hammer -u admin -p changeme organization list
ID | NAME                 | LABEL                | DESCRIPTION
1  | Default Organization | Default_Organization |            
4  | foo_org_2            | foo_org_2            |            
6  | org_bz1343108        | org_bz1343108        |            
[root@mysat6 var]# hammer -u admin -p changeme host info --id 1
Id:                 1
Name:               my-host-1.com
Organization:       org_bz1343108
Environment:        production

[root@mysat6 var]# hammer -u admin -p changeme organization delete --id 6
[.............................] [100%]
[root@mysat6 var]# hammer -u admin -p changeme task list --search="4edd4453-698b-4098-adb6-70909f46101d"
ID                                   | NAME | OWNER | STARTED AT          | ENDED AT            | STATE   | RESULT  | TASK ACTION | TASK ERRORS
4edd4453-698b-4098-adb6-70909f46101d |      | admin | 2016/07/12 15:25:26 | 2016/07/12 15:25:27 | stopped | success | Destroy     |            

Comment 20 Bryan Kearney 2016-07-27 11:25:04 UTC
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, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.