Bug 1241923

Summary: Unable to delete 3 provisioned hosts: Cannot delete record because of dependent content_host (ActiveRecord::DeleteRestrictionError)
Product: Red Hat Satellite Reporter: John Matthews <jmatthew>
Component: RegistrationAssignee: Lukas Zapletal <lzap>
Status: CLOSED DUPLICATE QA Contact: Katello QA List <katello-qa-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: bbuckingham, bkearney, cwelton, jmatthew, lzap
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-21 14:46:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1212602    
Attachments:
Description Flags
foreman-debug info none

Description John Matthews 2015-07-10 12:25:34 UTC
Created attachment 1050667 [details]
foreman-debug info

Description of problem:

Provisioned 3 hosts with discovery, then I selected all 3 hosts and did a bulk delete.


Actions::BulkAction
Input:
{"action_class"=>"Actions::Katello::System::HostDestroy",
 "target_ids"=>[2, 3, 4],
 "target_class"=>"Host::Managed",
 "args"=>[],
 "current_user_id"=>3,
 "locale"=>"en"}
Output:
{"total_count"=>3, "failed_count"=>1, "success_count"=>2}
Exception:
RuntimeError: A sub task failed
Backtrace:
/opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.7.7.7/lib/dynflow/action/with_sub_plans.rb:158:in `check_for_errors!'


2015-07-10 08:14:14 [I] Delete the DNS PTR record for 192.168.252.15/mac5254009536eb.example.com
2015-07-10 08:14:14 [I] Delete the DNS A record for mac5254009536eb.example.com/192.168.252.15
2015-07-10 08:14:14 [I] Delete DHCP reservation for mac5254009536eb.example.com-52:54:00:95:36:eb/192.168.252.15
2015-07-10 08:14:14 [I] Delete the TFTP configuration for mac5254009536eb.example.com
2015-07-10 08:14:14 [I] Remove puppet certificate for mac5254009536eb.example.com
2015-07-10 08:14:15 [I] Delete the autosign entry for mac5254009536eb.example.com
2015-07-10 08:14:15 [E] Cannot delete record because of dependent content_host (ActiveRecord::DeleteRestrictionError)
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_one.rb:58:in `block in define_restrict_dependency_method'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:649:in `_run__3594044184734710221__destroy__76214477243478740__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/callbacks.rb:254:in `destroy'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:236:in `block in destroy'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:236:in `destroy'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.51/app/lib/actions/katello/system/host_destroy.rb:33:in `finalize'



Version-Release number of selected component (if applicable):
# rpm -qa | grep katello
katello-server-ca-1.0-1.noarch
katello-debug-2.2.0.11-1.el7sat.noarch
pulp-katello-0.5-1.el7sat.noarch
katello-certs-tools-2.2.1-1.el7sat.noarch
katello-common-2.2.0.11-1.el7sat.noarch
katello-service-2.2.0.11-1.el7sat.noarch
katello-installer-base-2.3.12-1.el7sat.noarch
katello-2.2.0.11-1.el7sat.noarch
rubygem-hammer_cli_katello-0.0.7.15-1.el7sat.noarch
katello-installer-2.3.12-1.el7sat.noarch
ruby193-rubygem-katello-2.2.0.51-1.el7sat.noarch
katello-default-ca-1.0-1.noarch


# rpm -qa | grep foreman
ruby193-rubygem-foreman_docker-1.2.0.14-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.7-1.el7sat.noarch
foreman-selinux-1.7.2.13-1.el7sat.noarch
foreman-discovery-image-2.1.0-29.el7sat.noarch
foreman-proxy-1.7.2.5-1.el7sat.noarch
sat61fusor.example.com-foreman-proxy-client-1.0-1.noarch
ruby193-rubygem-foreman_discovery-2.0.0.15-1.el7sat.noarch
rubygem-hammer_cli_foreman_docker-0.0.3.7-1.el7sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el7sat.noarch
foreman-vmware-1.7.2.27-1.el7sat.noarch
ruby193-rubygem-foreman-tasks-0.6.12.8-1.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.14-1.el7sat.noarch
foreman-libvirt-1.7.2.27-1.el7sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.13-1.el7sat.noarch
sat61fusor.example.com-foreman-client-1.0-1.noarch
sat61fusor.example.com-foreman-proxy-1.0-1.noarch
foreman-compute-1.7.2.27-1.el7sat.noarch
foreman-gce-1.7.2.27-1.el7sat.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el7sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.10-1.el7sat.noarch
foreman-debug-1.7.2.27-1.el7sat.noarch
foreman-1.7.2.27-1.el7sat.noarch
ruby193-rubygem-foreman-redhat_access-0.2.0-8.el7sat.noarch
foreman-postgresql-1.7.2.27-1.el7sat.noarch
foreman-ovirt-1.7.2.27-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.4-1.el7sat.noarch


How reproducible:

Unsure



Steps to Reproduce:
1.  Provision 3 hosts from discovery
2.  Do a bulk delete of the 3 hosts
3.

Comment 1 RHEL Program Management 2015-07-10 12:55:23 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Lukas Zapletal 2015-07-20 06:48:25 UTC
John,

can you give me please reproduce steps for Satellite 6.1? Because Discovery itself never associate Content Host, have you assigned it manually somehow?

Also if we manage to unassociate it manually, this is not a blocker bug.

Thanks!

Comment 4 John Matthews 2015-07-20 15:17:15 UTC
Lukas,

I don't have exact steps to recreate this and when I say we provisioned 3 hosts with discovery I meant we provisioned 3 discovered hosts, the provisioning is triggered by RHCI.  

I've seen the delete of the provisioned hosts work for the past few runs I've done (same release of Sat 6.1 RPMs)

The steps I've followed have been provisioning RHEV with RHCI.

1) Bring up 3 discovered hosts (VMs for my case)
2) Select the hosts in RHCI webui and provision to RHEV
   The 3 hosts are subscribed to red hat content repositories with an activation key during their provisioning.
   The provisioning is triggered by the fusor_server plugin
3) Sometime later perform a bulk delete on the hosts


Last time I saw this problem occur the hosts that did not delete said they were "Out Of Sync".  I'm not sure if that is related to the problem.  


Question:
Is there any other information that would be helpful for me to grab if I see this occur again?

Comment 5 John Matthews 2015-07-20 18:34:31 UTC
I think BZ 1232013 is a duplicate of this.

Comment 6 Lukas Zapletal 2015-07-21 14:31:46 UTC
Ok now I understand, you are not deleting Discovered Host, but Managed Host. Flipping over to Katello guys, I have no clue how delete orchestration are made there.

Comment 7 Bryan Kearney 2015-07-21 14:46:28 UTC
Closnig as dupe per Comment 5.

*** This bug has been marked as a duplicate of bug 1232013 ***