Katello 2.4 on CentOS 7.2 server.
When I try to delete a content view that has ZERO HOSTS attached to it, it
fails to delete and gives me the error "Cannot delete record because of
dependent hosts"
Unfortunately, the 300 lines of ruby error code doesn't tell me the one
thing I need to know : what nonexistent ghost hosts are causing these to
not be deleted?
Actions::Katello::ContentView::Destroy
Input:
{"content_view"=>
{"id"=>6, "name"=>"CentOS 6.5 View", "label"=>"Old_GR_CentOS_6_5_View"},
"organization"=>{"id"=>5, "name"=>"My Company", "label"=>"My_Company"},
"remote_user"=>"admin",
"remote_cp_user"=>"admin",
"locale"=>"en"}
Output:
{}
Exception:
ActiveRecord::DeleteRestrictionError: Cannot delete record because of
dependent hosts
Backtrace:
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
block in define_restrict_dependency_method' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
destroy!' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
finalize'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
block (2 levels) in execute_finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
block in finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
block (2 levels) in as_remote_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
pulp_config' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
as_pulp_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
block in as_remote_user' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
cp_config'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
as_cp_user' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
as_remote_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
with_progress_calculation' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
finalize'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
block in finalize'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
with_locale' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
finalize'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
finalize'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
block in execute_finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
execute_finalize'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
block (2 levels) in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
with_meta_calculation'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
block in execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
open_action'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
run_step'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
dispatch' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
block in run_in_sequence'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
each' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
all?'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
run_in_sequence' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
block in finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:16:in
block in rollback_on_error' /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/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/transaction_adapters/active_record.rb:5:in
transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:15:in
rollback_on_error' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:9:in
finalize_phase'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:26:in
finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:18:in
block in on_message'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in
block in assigns' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
tap'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
assigns' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:56:in
match_value'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:36:in
block in match?' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
each'
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
match?' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:23:in
match'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:12:in
on_message' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/context.rb:46:in
on_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/executes_context.rb:7:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/actor.rb:26:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/awaits.rb:15:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:38:in
process_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:31:in
process_envelopes?'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:20:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/termination.rb:55:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/removes_child.rb:10:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:161:in
process_envelope'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:95:in
block in on_envelope' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:118:in
block (2 levels) in schedule_execution'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/synchronization/mri_lockable_object.rb:62:in
block in synchronize' /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/synchronization/mri_lockable_object.rb:62:in
synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:115:in
block in schedule_execution'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:18:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:18:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:96:in
work' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:77:in
block in call_job'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:333:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:333:in
run_task'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:322:in
block (3 levels) in create_worker' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:305:in
loop'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:305:in
block (2 levels) in create_worker' /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:304:in
catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:304:in
block in create_worker' /opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in
call'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in
`block in create_with_logging_context'
The clean_backend_objects rake task might be what you
need: https://github.com/Katello/katello/tree/master/lib/katello/tasks
'foreman-rake -T' will show you a list of available rake tasks.
If that doesn't solve your problem, then you need to run some ActiveRecord
queries from the rake console (foreman-rake console). e.g.
'Katello::System.all' should get you all content hosts, something like
'Katello::System.find_by_content_view("CentOS 6.5 View").destroy should let
you find the offending content hosts and force a cascaded delete on the
object (http://guides.rubyonrails.org/active_record_querying.html). You
need to be careful of course ( take backups / snapshots before trying
anything) but spending some time understanding the relations between
Katello objects is very worthwhile!
Abir
···
On Saturday, February 27, 2016 at 11:10:46 AM UTC+11, Nathan Peters wrote:
>
> Katello 2.4 on CentOS 7.2 server.
>
> When I try to delete a content view that has ZERO HOSTS attached to it, it
> fails to delete and gives me the error "Cannot delete record because of
> dependent hosts"
>
> Unfortunately, the 300 lines of ruby error code doesn't tell me the one
> thing I need to know : what nonexistent ghost hosts are causing these to
> not be deleted?
>
>
>
> Actions::Katello::ContentView::Destroy
>
> Input:
>
> {"content_view"=>
> {"id"=>6, "name"=>"CentOS 6.5 View", "label"=>"Old_GR_CentOS_6_5_View"},
> "organization"=>{"id"=>5, "name"=>"My Company", "label"=>"My_Company"},
> "remote_user"=>"admin",
> "remote_cp_user"=>"admin",
> "locale"=>"en"}
>
> Output:
>
> {}
>
> Exception:
>
> ActiveRecord::DeleteRestrictionError: Cannot delete record because of
> dependent hosts
>
> Backtrace:
>
> /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
> `block in define_restrict_dependency_method'
> /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
> `_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
> `destroy!'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
> `finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
> `block (2 levels) in execute_finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
> `block in finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
> `block (2 levels) in as_remote_user'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
> `pulp_config'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
> `as_pulp_user'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
> `block in as_remote_user'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
> `cp_config'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
> `as_cp_user'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
> `as_remote_user'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
> `finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
> `with_progress_calculation'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
> `finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
> `block in finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
> `with_locale'
> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
> `finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
> `finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
> `execute'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
> `block in execute_finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
> `block in with_error_handling'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
> `catch'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
> `with_error_handling'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
> `execute_finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
> `execute'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
> `block (2 levels) in execute'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
> `with_meta_calculation'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
> `block in execute'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
> `open_action'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
> `execute'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
> `run_step'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
> `dispatch'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
> `block in run_in_sequence'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
> `each'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
> `all?'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
> `run_in_sequence'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
> `dispatch'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
> `block in finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
> `finalize_phase'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
> `finalize_phase'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
> `finalize_phase'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:16:in
> `block in rollback_on_error'
> /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/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/transaction_adapters/active_record.rb:5:in
> `transaction'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:15:in
> `rollback_on_error'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:9:in
> `finalize_phase'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
> `execute'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:26:in
> `finalize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:18:in
> `block in on_message'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in
> `block in assigns'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
> `tap'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
> `assigns'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:56:in
> `match_value'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:36:in
> `block in match?'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
> `each'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
> `match?'
> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:23:in
> `match'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:12:in
> `on_message'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/context.rb:46:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/executes_context.rb:7:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/actor.rb:26:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/awaits.rb:15:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:38:in
> `process_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:31:in
> `process_envelopes?'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:20:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/termination.rb:55:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/removes_child.rb:10:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
> `pass'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
> `on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:161:in
> `process_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:95:in
> `block in on_envelope'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:118:in
> `block (2 levels) in schedule_execution'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/synchronization/mri_lockable_object.rb:62:in
> `block in synchronize'
> /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/synchronization/mri_lockable_object.rb:62:in
> `synchronize'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:115:in
> `block in schedule_execution'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:18:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:18:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:96:in
> `work'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/serialized_execution.rb:77:in
> `block in call_job'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:333:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:333:in
> `run_task'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:322:in
> `block (3 levels) in create_worker'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:305:in
> `loop'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:305:in
> `block (2 levels) in create_worker'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:304:in
> `catch'
> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-1.0.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:304:in
> `block in create_worker'
> /opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in
> `call'
> /opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in
> `block in create_with_logging_context'
>
>
>
I ran 'foreman-rake katello:clean_backend_objects' and it did find and
clean 9 systems, but the content views and lifecycle environments are still
giving the dependent hosts error when I try to delete them.
That function find_by_content_view does not seem to exist. This is what
happens when I run it :
irb(main):002:0> Katello::System.find_by_content_view("CentOS 6.5 View")
NoMethodError: undefined method find_by_content_view' for #<Class:0x0000000adef378> from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:27:in
method_missing'
from (irb):2
from
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in
start' from /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in
start'
from /usr/share/foreman/lib/tasks/console.rake:3:in block in <top (required)>' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
call'
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in block in execute' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
each'
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
execute' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in
block
in invoke_with_call_chain'
from /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
invoke_with_call_chain'
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in
invoke' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in
invoke_task'
from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
block (2 levels) in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
each'
from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
block in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling'
from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in
top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in
block in run'
from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in
run'
from /opt/rh/ruby193/root/usr/bin/rake:32:in
`<main>'irb(main):003:0> exit
···
On Sunday, February 28, 2016 at 4:22:02 AM UTC-8, Abir wrote:
>
> The clean_backend_objects rake task might be what you need:
> https://github.com/Katello/katello/tree/master/lib/katello/tasks
>
> 'foreman-rake -T' will show you a list of available rake tasks.
>
> If that doesn't solve your problem, then you need to run some ActiveRecord
> queries from the rake console (foreman-rake console). e.g.
> 'Katello::System.all' should get you all content hosts, something like
> 'Katello::System.find_by_content_view("CentOS 6.5 View").destroy should let
> you find the offending content hosts and force a cascaded delete on the
> object (http://guides.rubyonrails.org/active_record_querying.html). You
> need to be careful of course ( take backups / snapshots before trying
> anything) but spending some time understanding the relations between
> Katello objects is very worthwhile!
>
> Abir
>
>
>
> On Saturday, February 27, 2016 at 11:10:46 AM UTC+11, Nathan Peters wrote:
>>
>> Katello 2.4 on CentOS 7.2 server.
>>
>> When I try to delete a content view that has ZERO HOSTS attached to it,
>> it fails to delete and gives me the error "Cannot delete record because of
>> dependent hosts"
>>
>> Unfortunately, the 300 lines of ruby error code doesn't tell me the one
>> thing I need to know : what nonexistent ghost hosts are causing these to
>> not be deleted?
>>
>>
>>
>> Actions::Katello::ContentView::Destroy
>>
>> Input:
>>
>> {"content_view"=>
>> {"id"=>6, "name"=>"CentOS 6.5 View", "label"=>"Old_GR_CentOS_6_5_View"},
>> "organization"=>{"id"=>5, "name"=>"My Company", "label"=>"My_Company"},
>> "remote_user"=>"admin",
>> "remote_cp_user"=>"admin",
>> "locale"=>"en"}
>>
>> Output:
>>
>> {}
>>
>> Exception:
>>
>> ActiveRecord::DeleteRestrictionError: Cannot delete record because of
>> dependent hosts
>>
>> Backtrace:
>>
>> /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
>> `block in define_restrict_dependency_method'
>> /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
>> `_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
>> `destroy!'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
>> `finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
>> `block (2 levels) in execute_finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
>> `block in finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
>> `block (2 levels) in as_remote_user'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
>> `pulp_config'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
>> `as_pulp_user'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
>> `block in as_remote_user'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
>> `cp_config'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
>> `as_cp_user'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
>> `as_remote_user'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
>> `finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
>> `with_progress_calculation'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
>> `finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
>> `block in finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
>> `with_locale'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
>> `finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
>> `finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
>> `execute'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
>> `block in execute_finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>> `block in with_error_handling'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>> `catch'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>> `with_error_handling'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
>> `execute_finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
>> `execute'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
>> `block (2 levels) in execute'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
>> `with_meta_calculation'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
>> `block in execute'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
>> `open_action'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
>> `execute'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
>> `run_step'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
>> `dispatch'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>> `block in run_in_sequence'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>> `each'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>> `all?'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>> `run_in_sequence'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
>> `dispatch'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
>> `block in finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>> `finalize_phase'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>> `finalize_phase'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>> `finalize_phase'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:16:in
>> `block in rollback_on_error'
>> /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/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/transaction_adapters/active_record.rb:5:in
>> `transaction'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:15:in
>> `rollback_on_error'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:9:in
>> `finalize_phase'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>> `call'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
>> `execute'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:26:in
>> `finalize'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:18:in
>> `block in on_message'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in
>> `block in assigns'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
>> `tap'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
>> `assigns'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:56:in
>> `match_value'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:36:in
>> `block in match?'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
>> `each'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
>> `match?'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:23:in
>> `match'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:12:in
>> `on_message'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/context.rb:46:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/executes_context.rb:7:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/actor.rb:26:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/awaits.rb:15:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:38:in
>> `process_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:31:in
>> `process_envelopes?'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:20:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/termination.rb:55:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/removes_child.rb:10:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>> `pass'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
>> `on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:161:in
>> `process_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:95:in
>> `block in on_envelope'
>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/core.rb:118:in
>> `block (2 levels) in schedule_e
So… I can't find a manual anywhere the the actual command that should
work to give me a list off all hosts by content view through rake.
Does anyone know?
···
On Sunday, February 28, 2016 at 9:05:26 PM UTC-8, Nathan Peters wrote:
>
> I ran 'foreman-rake katello:clean_backend_objects' and it did find and
> clean 9 systems, but the content views and lifecycle environments are still
> giving the dependent hosts error when I try to delete them.
>
> That function find_by_content_view does not seem to exist. This is what
> happens when I run it :
>
> irb(main):002:0> Katello::System.find_by_content_view("CentOS 6.5 View")
> NoMethodError: undefined method `find_by_content_view' for
> #
> from
> /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:27:in
> `method_missing'
> from (irb):2
> from
> /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in
> `start'
> from
> /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in
> `start'
> from /usr/share/foreman/lib/tasks/console.rake:3:in `block in (required)>'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `call'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
> `block in execute'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `each'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
> `execute'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in
> `block in invoke_with_call_chain'
> from /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in
> `mon_synchronize'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
> `invoke_with_call_chain'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in
> `invoke'
> from
> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in `invoke_task'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
> `block (2 levels) in top_level'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
> `each'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
> `block in top_level'
> from
> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
> `standard_exception_handling'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in
> `top_level'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in
> `block in run'
> from
> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
> `standard_exception_handling'
> from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in
> `run'
> from /opt/rh/ruby193/root/usr/bin/rake:32:in
> `'irb(main):003:0> exit
>
>
> On Sunday, February 28, 2016 at 4:22:02 AM UTC-8, Abir wrote:
>>
>> The clean_backend_objects rake task might be what you need:
>> https://github.com/Katello/katello/tree/master/lib/katello/tasks
>>
>> 'foreman-rake -T' will show you a list of available rake tasks.
>>
>> If that doesn't solve your problem, then you need to run some
>> ActiveRecord queries from the rake console (foreman-rake console). e.g.
>> 'Katello::System.all' should get you all content hosts, something like
>> 'Katello::System.find_by_content_view("CentOS 6.5 View").destroy should let
>> you find the offending content hosts and force a cascaded delete on the
>> object (http://guides.rubyonrails.org/active_record_querying.html). You
>> need to be careful of course ( take backups / snapshots before trying
>> anything) but spending some time understanding the relations between
>> Katello objects is very worthwhile!
>>
>> Abir
>>
>>
>>
>> On Saturday, February 27, 2016 at 11:10:46 AM UTC+11, Nathan Peters wrote:
>>>
>>> Katello 2.4 on CentOS 7.2 server.
>>>
>>> When I try to delete a content view that has ZERO HOSTS attached to it,
>>> it fails to delete and gives me the error "Cannot delete record because of
>>> dependent hosts"
>>>
>>> Unfortunately, the 300 lines of ruby error code doesn't tell me the one
>>> thing I need to know : what nonexistent ghost hosts are causing these to
>>> not be deleted?
>>>
>>>
>>>
>>> Actions::Katello::ContentView::Destroy
>>>
>>> Input:
>>>
>>> {"content_view"=>
>>> {"id"=>6, "name"=>"CentOS 6.5 View",
>>> "label"=>"Old_GR_CentOS_6_5_View"},
>>> "organization"=>{"id"=>5, "name"=>"My Company", "label"=>"My_Company"},
>>> "remote_user"=>"admin",
>>> "remote_cp_user"=>"admin",
>>> "locale"=>"en"}
>>>
>>> Output:
>>>
>>> {}
>>>
>>> Exception:
>>>
>>> ActiveRecord::DeleteRestrictionError: Cannot delete record because of
>>> dependent hosts
>>>
>>> Backtrace:
>>>
>>> /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
>>> `block in define_restrict_dependency_method'
>>> /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
>>> `_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
>>> `destroy!'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
>>> `finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
>>> `block (2 levels) in execute_finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
>>> `block in finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
>>> `block (2 levels) in as_remote_user'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
>>> `pulp_config'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
>>> `as_pulp_user'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
>>> `block in as_remote_user'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
>>> `cp_config'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
>>> `as_cp_user'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
>>> `as_remote_user'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
>>> `finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
>>> `with_progress_calculation'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
>>> `finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
>>> `block in finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
>>> `with_locale'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
>>> `finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
>>> `finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
>>> `execute'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
>>> `block in execute_finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>> `block in with_error_handling'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>> `catch'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>> `with_error_handling'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
>>> `execute_finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
>>> `execute'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
>>> `block (2 levels) in execute'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
>>> `with_meta_calculation'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
>>> `block in execute'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
>>> `open_action'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
>>> `execute'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
>>> `run_step'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
>>> `dispatch'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>> `block in run_in_sequence'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>> `each'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>> `all?'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>> `run_in_sequence'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
>>> `dispatch'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
>>> `block in finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>>> `finalize_phase'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>>> `finalize_phase'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>>> `finalize_phase'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:16:in
>>> `block in rollback_on_error'
>>> /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/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/transaction_adapters/active_record.rb:5:in
>>> `transaction'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:15:in
>>> `rollback_on_error'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:9:in
>>> `finalize_phase'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>> `call'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
>>> `execute'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:26:in
>>> `finalize'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:18:in
>>> `block in on_message'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in
>>> `block in assigns'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
>>> `tap'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
>>> `assigns'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:56:in
>>> `match_value'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:36:in
>>> `block in match?'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
>>> `each'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
>>> `match?'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:23:in
>>> `match'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:12:in
>>> `on_message'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/context.rb:46:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/executes_context.rb:7:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/actor.rb:26:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/awaits.rb:15:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/sets_results.rb:14:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:38:in
>>> `process_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:31:in
>>> `process_envelopes?'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/buffer.rb:20:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/termination.rb:55:in
>>> `on_envelope'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/abstract.rb:25:in
>>> `pass'
>>> /opt/theforeman/tfm/root/usr/share/gems/gems/concurrent-ruby-edge-0.2.0/lib/concurrent/actor/behaviour/removes_child.rb:10:in
>>> `on_env
So to delete the content view the way Abir suggested you can do
Katello::System.where(:content_view_id => Katello::ContentView.where(:name
=> "CentOS 6.5 View").first.id).destroy
and to view the hosts for a content view
Katello::ContentView.where(:name => "CentOS 6.5 View").first.hosts
Be sure to back up everything before destroying objects from the console 
John Mitsch
Red Hat Engineering
(860)-967-7285
irc: jomitsch
···
On Thu, Mar 3, 2016 at 3:06 PM, Nathan Peters wrote:
So… I can’t find a manual anywhere the the actual command that should
work to give me a list off all hosts by content view through rake.
Does anyone know?
On Sunday, February 28, 2016 at 9:05:26 PM UTC-8, Nathan Peters wrote:
I ran ‘foreman-rake katello:clean_backend_objects’ and it did find and
clean 9 systems, but the content views and lifecycle environments are still
giving the dependent hosts error when I try to delete them.
That function find_by_content_view does not seem to exist. This is what
happens when I run it :
irb(main):002:0> Katello::System.find_by_content_view(“CentOS 6.5 View”)
NoMethodError: undefined method find_by_content_view' for #<Class:0x0000000adef378> from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:27:in
method_missing’
from (irb):2
from
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in
start' from /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in
start’
from /usr/share/foreman/lib/tasks/console.rake:3:in block in <top (required)>' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
call’
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
block in execute' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
each’
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
execute' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in
block in invoke_with_call_chain’
from /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
invoke_with_call_chain’
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in
invoke' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in
invoke_task’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in block (2 levels) in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
each’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in block in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in
block in run’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in
run’
from /opt/rh/ruby193/root/usr/bin/rake:32:in
`'irb(main):003:0> exit
On Sunday, February 28, 2016 at 4:22:02 AM UTC-8, Abir wrote:
The clean_backend_objects rake task might be what you need:
https://github.com/Katello/katello/tree/master/lib/katello/tasks
‘foreman-rake -T’ will show you a list of available rake tasks.
If that doesn’t solve your problem, then you need to run some
ActiveRecord queries from the rake console (foreman-rake console). e.g.
‘Katello::System.all’ should get you all content hosts, something like
’Katello::System.find_by_content_view(“CentOS 6.5 View”).destroy should let
you find the offending content hosts and force a cascaded delete on the
object (http://guides.rubyonrails.org/active_record_querying.html). You
need to be careful of course ( take backups / snapshots before trying
anything) but spending some time understanding the relations between
Katello objects is very worthwhile!
Abir
On Saturday, February 27, 2016 at 11:10:46 AM UTC+11, Nathan Peters >>> wrote:
Katello 2.4 on CentOS 7.2 server.
When I try to delete a content view that has ZERO HOSTS attached to it,
it fails to delete and gives me the error “Cannot delete record because of
dependent hosts”
Unfortunately, the 300 lines of ruby error code doesn’t tell me the one
thing I need to know : what nonexistent ghost hosts are causing these to
not be deleted?
Actions::Katello::ContentView::Destroy
Input:
{“content_view”=>
{“id”=>6, “name”=>“CentOS 6.5 View”,
“label”=>“Old_GR_CentOS_6_5_View”},
“organization”=>{“id”=>5, “name”=>“My Company”, “label”=>“My_Company”},
“remote_user”=>“admin”,
“remote_cp_user”=>“admin”,
“locale”=>“en”}
Output:
{}
Exception:
ActiveRecord::DeleteRestrictionError: Cannot delete record because of
dependent hosts
Backtrace:
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
block in define_restrict_dependency_method' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
destroy!' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
block (2 levels) in execute_finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
block in finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
block (2 levels) in as_remote_user’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
pulp_config' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
as_pulp_user’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
block in as_remote_user' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
cp_config’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
as_cp_user' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
as_remote_user’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
with_progress_calculation' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
block in finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
with_locale' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
execute’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
block in execute_finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
catch’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
execute_finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
block (2 levels) in execute’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
with_meta_calculation’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
block in execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
open_action’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
run_step’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
dispatch' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
block in run_in_sequence’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
each' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
all?’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
run_in_sequence' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
dispatch’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
block in finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:16:in
block in rollback_on_error' /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/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/transaction_adapters/active_record.rb:5:in
transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:15:in
rollback_on_error' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:9:in
finalize_phase’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
execute’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:26:in
finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:18:in
block in on_message’
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in
block in assigns' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
tap’
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
assigns' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:56:in
match_value’
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:36:in
block in match?' /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
each’
/opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matching.rb:35:in
`mat
Thank you. That syntax worked for me.
Here is the bigger issue though. I now know how these 'ghost' hosts are
appearing.
Here is how to re-create it:
- Create a host, let Katello build it.
- Decide you want to assign that host to a different lifecycle environment
- Create an activation key that will assign then to the lifecycle
environment and re-register them with the new activation key
- DONE. If you view your host in "Content Hosts" he is in the new
lifecycle environment… but if you view your host through 'all hosts' he
is still assigned to the old lifecycle environment and has no content view
(its blank)
However, the disecrepancy between these 2 records means that because one
set of records lists him as having the old environment and content view you
will now get a crash of katello every time you try to delete the old
content view or activation key…
Is there a fix for this? Has anyone else reported this issue?
It does not seem that there is a "safe" way to update a hosts content
view. If you update it through the host record, it doesn't change on the
host itself and the host doesn't get the new content.
If you update it by re-registering with a new activation key, the host will
get the new content view, but a 'ghost' record will be left behind in the
'hosts' (not content hosts) list with his old content view.
This basically makes it impossible to ever change a content view without
breaking your Katello installation pretty bad…
···
On Thursday, March 3, 2016 at 1:55:40 PM UTC-8, John Mitsch wrote:
>
> So to delete the content view the way Abir suggested you can do
>
> Katello::System.where(:content_view_id => Katello::ContentView.where(:name
> => "CentOS 6.5 View").first.id).destroy
>
> and to view the hosts for a content view
>
> Katello::ContentView.where(:name => "CentOS 6.5 View").first.hosts
>
> Be sure to back up everything before destroying objects from the console :)
>
>
> John Mitsch
> Red Hat Engineering
> (860)-967-7285
> irc: jomitsch
>
> On Thu, Mar 3, 2016 at 3:06 PM, Nathan Peters > wrote:
>
>> So... I can't find a manual anywhere the the actual command that should
>> work to give me a list off all hosts by content view through rake.
>>
>> Does anyone know?
>>
>>
>> On Sunday, February 28, 2016 at 9:05:26 PM UTC-8, Nathan Peters wrote:
>>>
>>> I ran 'foreman-rake katello:clean_backend_objects' and it did find and
>>> clean 9 systems, but the content views and lifecycle environments are still
>>> giving the dependent hosts error when I try to delete them.
>>>
>>> That function find_by_content_view does not seem to exist. This is what
>>> happens when I run it :
>>>
>>> irb(main):002:0> Katello::System.find_by_content_view("CentOS 6.5 View")
>>> NoMethodError: undefined method `find_by_content_view' for
>>> #
>>> from
>>> /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:27:in
>>> `method_missing'
>>> from (irb):2
>>> from
>>> /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in
>>> `start'
>>> from
>>> /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in
>>> `start'
>>> from /usr/share/foreman/lib/tasks/console.rake:3:in `block in
>>> '
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
>>> `call'
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
>>> `block in execute'
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
>>> `each'
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
>>> `execute'
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in
>>> `block in invoke_with_call_chain'
>>> from /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in
>>> `mon_synchronize'
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
>>> `invoke_with_call_chain'
>>> from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in
>>> `invoke'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in `invoke_task'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block (2
>>> levels) in top_level'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `each'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block in
>>> top_level'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
>>> `standard_exception_handling'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in `top_level'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in `block in run'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
>>> `standard_exception_handling'
>>> from
>>> /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
>>> from /opt/rh/ruby193/root/usr/bin/rake:32:in
>>> `'irb(main):003:0> exit
>>>
>>>
>>> On Sunday, February 28, 2016 at 4:22:02 AM UTC-8, Abir wrote:
>>>>
>>>> The clean_backend_objects rake task might be what you need:
>>>> https://github.com/Katello/katello/tree/master/lib/katello/tasks
>>>>
>>>> 'foreman-rake -T' will show you a list of available rake tasks.
>>>>
>>>> If that doesn't solve your problem, then you need to run some
>>>> ActiveRecord queries from the rake console (foreman-rake console). e.g.
>>>> 'Katello::System.all' should get you all content hosts, something like
>>>> 'Katello::System.find_by_content_view("CentOS 6.5 View").destroy should let
>>>> you find the offending content hosts and force a cascaded delete on the
>>>> object (http://guides.rubyonrails.org/active_record_querying.html).
>>>> You need to be careful of course ( take backups / snapshots before trying
>>>> anything) but spending some time understanding the relations between
>>>> Katello objects is very worthwhile!
>>>>
>>>> Abir
>>>>
>>>>
>>>>
>>>> On Saturday, February 27, 2016 at 11:10:46 AM UTC+11, Nathan Peters >>>> wrote:
>>>>>
>>>>> Katello 2.4 on CentOS 7.2 server.
>>>>>
>>>>> When I try to delete a content view that has ZERO HOSTS attached to
>>>>> it, it fails to delete and gives me the error "Cannot delete record because
>>>>> of dependent hosts"
>>>>>
>>>>> Unfortunately, the 300 lines of ruby error code doesn't tell me the
>>>>> one thing I need to know : what nonexistent ghost hosts are causing these
>>>>> to not be deleted?
>>>>>
>>>>>
>>>>>
>>>>> Actions::Katello::ContentView::Destroy
>>>>>
>>>>> Input:
>>>>>
>>>>> {"content_view"=>
>>>>> {"id"=>6, "name"=>"CentOS 6.5 View",
>>>>> "label"=>"Old_GR_CentOS_6_5_View"},
>>>>> "organization"=>{"id"=>5, "name"=>"My Company",
>>>>> "label"=>"My_Company"},
>>>>> "remote_user"=>"admin",
>>>>> "remote_cp_user"=>"admin",
>>>>> "locale"=>"en"}
>>>>>
>>>>> Output:
>>>>>
>>>>> {}
>>>>>
>>>>> Exception:
>>>>>
>>>>> ActiveRecord::DeleteRestrictionError: Cannot delete record because of
>>>>> dependent hosts
>>>>>
>>>>> Backtrace:
>>>>>
>>>>> /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
>>>>> `block in define_restrict_dependency_method'
>>>>> /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
>>>>> `_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
>>>>> `destroy!'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
>>>>> `finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
>>>>> `block (2 levels) in execute_finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
>>>>> `block in finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
>>>>> `block (2 levels) in as_remote_user'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
>>>>> `pulp_config'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
>>>>> `as_pulp_user'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
>>>>> `block in as_remote_user'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
>>>>> `cp_config'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
>>>>> `as_cp_user'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
>>>>> `as_remote_user'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
>>>>> `finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
>>>>> `with_progress_calculation'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
>>>>> `finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
>>>>> `block in finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
>>>>> `with_locale'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
>>>>> `finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
>>>>> `finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
>>>>> `execute'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
>>>>> `block in execute_finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>>>> `block in with_error_handling'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>>>> `catch'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
>>>>> `with_error_handling'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
>>>>> `execute_finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
>>>>> `execute'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
>>>>> `block (2 levels) in execute'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
>>>>> `with_meta_calculation'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
>>>>> `block in execute'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
>>>>> `open_action'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
>>>>> `execute'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
>>>>> `run_step'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
>>>>> `dispatch'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>>>> `block in run_in_sequence'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>>>> `each'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>>>> `all?'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
>>>>> `run_in_sequence'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
>>>>> `dispatch'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
>>>>> `block in finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>>>>> `finalize_phase'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>>>>> `finalize_phase'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
>>>>> `finalize_phase'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
>>>>> `pass'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:16:in
>>>>> `block in rollback_on_error'
>>>>> /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/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/transaction_adapters/active_record.rb:5:in
>>>>> `transaction'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:15:in
>>>>> `rollback_on_error'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/common/transaction.rb:9:in
>>>>> `finalize_phase'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
>>>>> `call'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
>>>>> `execute'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:26:in
>>>>> `finalize'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/worker.rb:18:in
>>>>> `block in on_message'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:74:in
>>>>> `block in assigns'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
>>>>> `tap'
>>>>> /opt/theforeman/tfm/root/usr/share/gems/gems/algebrick-0.7.3/lib/algebrick/matchers/abstract.rb:73:in
>>>>
Thanks for bringing this to our attention, I'll make a note to check if
this is still an issue in the upstream version (there has been alot of
changes around hosts so it may not be an issue anymore) and file a bug if
it is.
-John
John Mitsch
Red Hat Engineering
(860)-967-7285
irc: jomitsch
···
On Thu, Mar 3, 2016 at 7:44 PM, Nathan Peters wrote:
Thank you. That syntax worked for me.
Here is the bigger issue though. I now know how these ‘ghost’ hosts are
appearing.
Here is how to re-create it:
- Create a host, let Katello build it.
- Decide you want to assign that host to a different lifecycle environment
- Create an activation key that will assign then to the lifecycle
environment and re-register them with the new activation key
- DONE. If you view your host in “Content Hosts” he is in the new
lifecycle environment… but if you view your host through ‘all hosts’ he
is still assigned to the old lifecycle environment and has no content view
(its blank)
However, the disecrepancy between these 2 records means that because one
set of records lists him as having the old environment and content view you
will now get a crash of katello every time you try to delete the old
content view or activation key…
Is there a fix for this? Has anyone else reported this issue?
It does not seem that there is a “safe” way to update a hosts content
view. If you update it through the host record, it doesn’t change on the
host itself and the host doesn’t get the new content.
If you update it by re-registering with a new activation key, the host
will get the new content view, but a ‘ghost’ record will be left behind in
the ‘hosts’ (not content hosts) list with his old content view.
This basically makes it impossible to ever change a content view without
breaking your Katello installation pretty bad…
On Thursday, March 3, 2016 at 1:55:40 PM UTC-8, John Mitsch wrote:
So to delete the content view the way Abir suggested you can do
Katello::System.where(:content_view_id =>
Katello::ContentView.where(:name => “CentOS 6.5 View”).first.id).destroy
and to view the hosts for a content view
Katello::ContentView.where(:name => “CentOS 6.5 View”).first.hosts
Be sure to back up everything before destroying objects from the console

John Mitsch
Red Hat Engineering
(860)-967-7285
irc: jomitsch
On Thu, Mar 3, 2016 at 3:06 PM, Nathan Peters nathanp...@gmail.com >> wrote:
So… I can’t find a manual anywhere the the actual command that should
work to give me a list off all hosts by content view through rake.
Does anyone know?
On Sunday, February 28, 2016 at 9:05:26 PM UTC-8, Nathan Peters wrote:
I ran ‘foreman-rake katello:clean_backend_objects’ and it did find and
clean 9 systems, but the content views and lifecycle environments are still
giving the dependent hosts error when I try to delete them.
That function find_by_content_view does not seem to exist. This is
what happens when I run it :
irb(main):002:0> Katello::System.find_by_content_view(“CentOS 6.5 View”)
NoMethodError: undefined method find_by_content_view' for #<Class:0x0000000adef378> from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:27:in
method_missing’
from (irb):2
from
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in
start' from /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in
start’
from /usr/share/foreman/lib/tasks/console.rake:3:in block in <top (required)>' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
call’
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in
block in execute' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
each’
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in
execute' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in
block in invoke_with_call_chain’
from /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize' from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
invoke_with_call_chain’
from /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in
invoke' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in
invoke_task’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in block (2 levels) in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in
each’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in block in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in top_level' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in
block in run’
from
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
standard_exception_handling' from /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in
run’
from /opt/rh/ruby193/root/usr/bin/rake:32:in
`'irb(main):003:0> exit
On Sunday, February 28, 2016 at 4:22:02 AM UTC-8, Abir wrote:
The clean_backend_objects rake task might be what you need:
https://github.com/Katello/katello/tree/master/lib/katello/tasks
‘foreman-rake -T’ will show you a list of available rake tasks.
If that doesn’t solve your problem, then you need to run some
ActiveRecord queries from the rake console (foreman-rake console). e.g.
‘Katello::System.all’ should get you all content hosts, something like
’Katello::System.find_by_content_view(“CentOS 6.5 View”).destroy should let
you find the offending content hosts and force a cascaded delete on the
object (http://guides.rubyonrails.org/active_record_querying.html).
You need to be careful of course ( take backups / snapshots before trying
anything) but spending some time understanding the relations between
Katello objects is very worthwhile!
Abir
On Saturday, February 27, 2016 at 11:10:46 AM UTC+11, Nathan Peters >>>>> wrote:
Katello 2.4 on CentOS 7.2 server.
When I try to delete a content view that has ZERO HOSTS attached to
it, it fails to delete and gives me the error “Cannot delete record because
of dependent hosts”
Unfortunately, the 300 lines of ruby error code doesn’t tell me the
one thing I need to know : what nonexistent ghost hosts are causing these
to not be deleted?
Actions::Katello::ContentView::Destroy
Input:
{“content_view”=>
{“id”=>6, “name”=>“CentOS 6.5 View”,
“label”=>“Old_GR_CentOS_6_5_View”},
“organization”=>{“id”=>5, “name”=>“My Company”,
“label”=>“My_Company”},
“remote_user”=>“admin”,
“remote_cp_user”=>“admin”,
“locale”=>“en”}
Output:
{}
Exception:
ActiveRecord::DeleteRestrictionError: Cannot delete record because of
dependent hosts
Backtrace:
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/associations/builder/has_many.rb:63:in
block in define_restrict_dependency_method' /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:495:in
_run__3391759919488538546__destroy__4105486000336778726__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/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/models/katello/model.rb:7:in
destroy!' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/katello/content_view/destroy.rb:27:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:528:in
block (2 levels) in execute_finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
block in finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:46:in
block (2 levels) in as_remote_user’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:72:in
pulp_config' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:32:in
as_pulp_user’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:45:in
block in as_remote_user' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/katello/util/thread_session.rb:79:in
cp_config’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:27:in
as_cp_user' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:44:in
as_remote_user’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/remote_action.rb:20:in
finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:30:in
with_progress_calculation' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action/progress.rb:22:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
block in finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:22:in
with_locale' /opt/theforeman/tfm/root/usr/share/gems/gems/katello-2.4.0/app/lib/actions/middleware/keep_locale.rb:15:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:38:in
finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/world.rb:30:in
execute’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:527:in
block in execute_finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
catch’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:419:in
with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:526:in
execute_finalize’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/action.rb:260:in
execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:9:in
block (2 levels) in execute’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
call' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract.rb:155:in
with_meta_calculation’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:8:in
block in execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:22:in
open_action’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:7:in
execute' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:68:in
run_step’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:53:in
dispatch' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
block in run_in_sequence’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
each' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
all?’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:60:in
run_in_sequence' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:49:in
dispatch’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/executors/parallel/sequential_manager.rb:27:in
block in finalize' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
pass' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:17:in
pass’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware.rb:46:in
finalize_phase' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:22:in
call’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-0.8.9/lib/dynflow/middleware/stack.rb:26:in
`pass’