Project

General

Profile

Actions

Bug #15336

closed

Org/Location removal results in a ISE

Added by Partha Aji almost 8 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1343108
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:
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:


Related issues 3 (2 open1 closed)

Related to Foreman - Tracker #10022: Taxonomies related issuesNew04/05/2015

Actions
Related to Foreman - Bug #15552: Org deletion needs to show a page listing the hosts attached to the orgNew06/30/2016Actions
Is duplicate of Katello - Bug #15149: Missing warning when trying to delete organization with assigned hostsDuplicatePartha Aji05/23/2016Actions
Actions #1

Updated by Partha Aji almost 8 years ago

  • Project changed from Katello to Foreman
  • Subject changed from Candlepin removes OwnerResource even when deleting the Organization fails in Satellite to Org/Location removal results in a ISE
  • Category deleted (Organizations and Locations)

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))

Error Encountered:


] <Org> is used by <Host> (RuntimeError)
 | /home/vagrant/katello/app/models/katello/concerns/organization_extensions.rb:116:in `destroy!'
 | /home/vagrant/katello/app/lib/actions/katello/organization/destroy.rb:29:in `block in finalize'
 | /home/vagrant/foreman/app/models/concerns/foreman/thread_session.rb:72:in `as'
 | /home/vagrant/foreman/app/models/concerns/foreman/thread_session.rb:78:in `as_anonymous_admin'
 | /home/vagrant/katello/app/lib/actions/katello/organization/destroy.rb:28:in `finalize'
 | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/dynflow-0.8.11/lib/dynflow/action.rb:528:in `block (2 levels) in execute_finalize'
 | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/dynflow-0.8.11/lib/dynflow/middleware/stack.rb:26:in `call'


Basic error is these 2 areas

https://github.com/theforeman/foreman/blob/develop/app/models/taxonomies/organization.rb#L8 and https://github.com/theforeman/foreman/blob/develop/app/models/taxonomy.rb#L2

before_destroy EnsureNotUsedBy.new(:hosts)

The above code is in the super class Taxonomy. This checks to make sure no associations are there for the organization before destroying.

has_many_hosts :dependent => :nullify

The above code is in the sub class Organization/Location. This nullifies the host association on the deletion of organization/location object.

We basically need ```has_many_hosts :dependent => :nullify``` to run before ```before_destroy EnsureNotUsedBy.new(:hosts)```

For the proper ordering of these checks

Actions #2

Updated by The Foreman Bot almost 8 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3576 added
Actions #3

Updated by Marek Hulán almost 8 years ago

Actions #4

Updated by Marek Hulán almost 8 years ago

  • Category set to Organizations and Locations
Actions #5

Updated by The Foreman Bot almost 8 years ago

  • Pull request https://github.com/theforeman/foreman/pull/3616 added
Actions #6

Updated by Dominic Cleal almost 8 years ago

  • Related to Bug #15552: Org deletion needs to show a page listing the hosts attached to the org added
Actions #7

Updated by Partha Aji almost 8 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #8

Updated by Dominic Cleal almost 8 years ago

  • translation missing: en.field_release set to 160
Actions #9

Updated by Justin Sherrill over 7 years ago

  • Is duplicate of Bug #15149: Missing warning when trying to delete organization with assigned hosts added
Actions

Also available in: Atom PDF