Bug #22143
closedWebUI doesn't allow to delete a host provisioned via bootdisk from satellite, when same host has already been deleted from rhev
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1330549
Description of problem:
I accidentally deleted a host provisioned via boot disk from rhev CR and later when I tried to delete same host registered with satellite, satellite webUI raises error:
Failed to destroy a compute rhevm1.satellite.lab.eng.rdu2.redhat.com (RHEV) instance bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com: ActiveRecord::RecordNotFound
2016-04-26 08:05:45 [app] [I] Started DELETE "/hosts/bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com" for 10.65.193.53 at 2016-04-26 08:05:45 -0400
2016-04-26 08:05:45 [app] [I] Processing by HostsController#destroy as HTML
2016-04-26 08:05:45 [app] [I] Parameters: {"authenticity_token"=>"D+B+2DjOjAjlQYBvoNLLBaYz+oYHRDoqXmoSeAKx1xs=", "id"=>"bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com"}
2016-04-26 08:05:46 [app] [I] Delete the DNS A record for bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com/10.8.111.51
2016-04-26 08:05:46 [app] [I] Delete the DNS PTR record for 10.8.111.51/bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com
2016-04-26 08:05:46 [app] [I] Delete DHCP reservation for bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com-00:1a:4a:3e:a6:1d/10.8.111.51
2016-04-26 08:05:49 [app] [W] Failed to destroy a compute rhevm1.satellite.lab.eng.rdu2.redhat.com (RHEV) instance bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com: ActiveRecord::RecordNotFound
| ActiveRecord::RecordNotFound: ActiveRecord::RecordNotFound
| /usr/share/foreman/app/models/compute_resources/foreman/model/ovirt.rb:26:in `rescue in find_vm_by_uuid'
| /usr/share/foreman/app/models/compute_resources/foreman/model/ovirt.rb:24:in `find_vm_by_uuid'
| /usr/share/foreman/app/models/compute_resources/foreman/model/ovirt.rb:188:in `destroy_vm'
| /usr/share/foreman/app/models/concerns/orchestration/compute.rb:161:in `delCompute'
| /usr/share/foreman/app/models/concerns/orchestration.rb:162:in `execute'
| /usr/share/foreman/app/models/concerns/orchestration.rb:107:in `block in process'
| /usr/share/foreman/app/models/concerns/orchestration.rb:99:in `each'
| /usr/share/foreman/app/models/concerns/orchestration.rb:99:in `process'
| /usr/share/foreman/app/models/concerns/orchestration.rb:43:in `on_destroy'
| /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:424:in `block in make_lambda'
this leaves a stale entry in satellite and there s no way to remove this host from satellite itself.
Steps to Reproduce:
1. provision a host via generic bootdisk on rhev
2. delete the host from rhev first
3. delete the host from satellite
Actual results:
Failed to destroy a compute rhevm1.satellite.lab.eng.rdu2.redhat.com (RHEV) instance bootdiskgen2.katello-latest.satellite.lab.eng.rdu2.redhat.com: ActiveRecord::RecordNotFound
Expected results:
host should be deleted from sat6 too
Additional info:
If I provision a host on libvirt and remove it from libvirt first, later I can successfully remove it from satellite.
Similarly, if I remove host provisioned via discovery first from CR and then later try to remove from satellite, I don't see any issue.