Description of problem: The organization removal task is not atomic: If the organization has some managed resources associated, its removal will fail: <pre> # 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] </pre> 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: <pre> 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 </pre> Version-Release number of selected component (if applicable): 6.2.0 bet (GA14.1) How reproducible: always 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:
This error leaves satellite unusable. This is a blocker for GA.
WORKAROUND: To get to a consistent state again, re-assign the host to other organization and resume the `remove organization` task.
This bug is related to bug 1336004 and bug 1340578.
Created redmine issue http://projects.theforeman.org/issues/15336 from this bug
being tracked in https://github.com/theforeman/foreman/pull/3576
(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.
Upstream bug component is Provisioning
Upstream bug component is Organizations and Locations
*** Bug 1348325 has been marked as a duplicate of this bug. ***
Roman, This bug also requires: https://github.com/Katello/katello/pull/6108 which cleans up the LCE and other objects.
which is tracked here: https://bugzilla.redhat.com/show_bug.cgi?id=1343795
Moving to POST since upstream bug http://projects.theforeman.org/issues/15336 has been closed
*** Bug 1336004 has been marked as a duplicate of this bug. ***
*** Bug 1340578 has been marked as a duplicate of this bug. ***
FAILED QA: 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.
The failed test is a different scenario handled in https://bugzilla.redhat.com/show_bug.cgi?id=1343795
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
VERIFIED 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 | -------------------------------------|------|-------|---------------------|---------------------|---------|---------|-------------|------------
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. https://access.redhat.com/errata/RHBA-2016:1501