Removing a lifecycle environment from Red Hat Satellite 6 fails with error "Cannot delete record because of dependent hostgroups (ActiveRecord::DeleteRestrictionError)"

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.x

Issue

  • Unable to remove thelifecycle environment from Red Hat Satellite 6.

Resolution

  • Ensure that the lifecycle environment is not associated with any host group or activation key before removing the lifecycle environment from Red Hat Satellite 6.

  • Perform the below steps on Red Hat Satellite Web UI to get a list of host groups associated with the particular lifecycle environment.

      On Satellite Web UI →  Configure →  Hostgroup →  Use the filter  lifecycle_environment = <lifecycle environment name>
    
  • Perform the below steps on Red Hat Satellite Web UI to get a list of Activation Keys associated with the particular lifecycle environment.

      On Satellite Web UI →  Content →  Activation Keys →  Use filter  environment = <lifecycle environment name>
    

For more KB articles/solutions related to Red Hat Satellite 6.x Installation/Upgrade/Update Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Installation/Upgrade/Update Issues.

Root Cause

  • The lifecycle environment was associated with a host group on Red Hat Satellite 6.

Diagnostic Steps

  • Following errors were observed in /var/log/foreman/production.log on Red Hat Satellite 6.

      2021-02-15T11:05:28 [I|bac|] Task {label: Actions::Katello::Environment::Destroy, id: d8104d0a-7e66-470a-95a8-f599b82f9529, 
      execution_plan_id: 72c353e2-3b28-40d5-95b9-0a9ec1e6890a} state changed: planned
      2021-02-15T11:05:28 [I|bac|] Task {label: Actions::Katello::Environment::Destroy, id: d8104d0a-7e66-470a-95a8-f599b82f9529, 
      execution_plan_id: 72c353e2-3b28-40d5-95b9-0a9ec1e6890a} state changed: running
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on name xxxxxx-xxxxxx-Environment
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on description For testing puppet modules etc.
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on library false
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on organization_id 3
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on label xxxxxx-xxxxxx-Environment
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on registry_name_pattern
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on registry_unauthenticated_pull false
      2021-02-15T11:05:28 [I|aud|] Katello::Environment (4) destroy event on content_facet_ids []
      2021-02-15T11:05:28 [E|bac|] Cannot delete record because of dependent hostgroups (ActiveRecord::DeleteRestrictionError)
      /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord 6.0.3.1/lib/active_record/associations/has_many_association.rb:16:in 
    
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.