Unable to remove stale / unused systems in Satellite 6
Issue
When removing stale / old / unused systems in Satellite 6.1 using foreman-rake
, a error is thrown and the delete operation fails:
[root@server ~]# foreman-rake katello:clean_backend_objects --trace
** Invoke katello:clean_backend_objects (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute katello:clean_backend_objects
"exception when destroying candlepin consumer 0669b3b7-8f7b-4047-8638-8e7a8c0144ae:Katello::Resources::Candlepin::Consumer: 500 Internal Server Error {\"displayMessage\":\"Runtime Error ERROR: update or delete on table \\\"cp_consumer\\\" violates foreign key constraint \\\"fk_sourcestack_consumer\\\" on table \\\"cp_pool_source_stack\\\"\\n Detail: Key (id)=(9a9c949856492d1401570a11010455c0) is still referenced from table \\\"cp_pool_source_stack\\\". at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse:2,157\",\"requestUuid\":\"b29751e8-05bd-4013-94f4-a4d4c43601ca\"} (DELETE /candlepin/consumers/0669b3b7-8f7b-4047-8638-8e7a8c0144ae): {\"displayMessage\":\"Runtime Error ERROR: update or delete on table \\\"cp_consumer\\\" violates foreign key constraint \\\"fk_sourcestack_consumer\\\" on table \\\"cp_pool_source_stack\\\"\\n Detail: Key (id)=(9a9c949856492d1401570a11010455c0) is still referenced from table \\\"cp_pool_source_stack\\\". at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse:2,157\",\"requestUuid\":\"b29751e8-05bd-4013-94f4-a4d4c43601ca\"}"
The system is also not found when deleting it using its name or UUID:
irb(main):001:0> Katello::System.find_by_name("client01.example.com")
2016-12-27 17:00:13 [D] Katello::System Load (8.9ms) SELECT "katello_systems".* FROM "katello_systems" WHERE "katello_systems"."name" = 'ctmm1prod-compute-40.localdomain' LIMIT 1
=> nil
irb(main):002:0> Katello::System.find_by_uuid("0669b3b7-8f7b-4047-8638-8e7a8c0144ae")
2016-12-27 17:00:26 [D] Katello::System Load (11.6ms) SELECT "katello_systems".* FROM "katello_systems" WHERE "katello_systems"."uuid" = '0669b3b7-8f7b-4047-8638-8e7a8c0144ae' LIMIT 1
=> nil
Environment
- Red Hat Satellite 6.1
- Red Hat Satellite 6.2
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.