Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-18610 Removing CV error's with "Cannot delete record because of dependent content_facet"
  3. SAT-24726

[DEV] Removing CV error's with "Cannot delete record because of dependent content_facet"

XMLWordPrintable

    • Sprint 132, Sprint 133, Sprint 134, Sprint 135, Sprint 136, Sprint 137, Sprint 138, Sprint 139, Sprint 140, Sprint 141

      Description of problem: Removing CV error's with "Cannot delete record because of dependent content_facet"

      How reproducible:

      Steps to Reproduce:
      1. Move all Hosts from CV to another
      2. Delete CV
      3.

      Actual results:
      Will not allow deleting the CV with the error "Cannot delete record because of dependent content_facet"

      Expected results:
      Delete the CV

      Additional info:
      Workaround was as below:

      1. foreman-rake console
        > pp ::Katello::ContentView.find_by(name: 'GEL-PROD-8_2-DevSuite').content_facets.first

      Note. The name of your CV is "GEL-PROD-8_2-DevSuite" and it should be empty. However, we can see an entry over there

      #<Katello::Host::ContentFacet:0x00005640b91e8778
      id: 464,
      host_id: 498,
      uuid: "aaed8122-84da-4b1f-afa2-1a03944079a2",
      content_view_id: 4,
      lifecycle_environment_id: 1,
      kickstart_repository_id: nil,
      content_source_id: nil,
      installable_security_errata_count: 0,
      installable_enhancement_errata_count: 0,
      installable_bugfix_errata_count: 0,
      applicable_rpm_count: 0,
      upgradable_rpm_count: 0,
      applicable_module_stream_count: 0,
      upgradable_module_stream_count: 0,
      applicable_deb_count: 0,
      upgradable_deb_count: 0>

      We can see that the host_id is 498 and id is 464, another way to confirm that this is not anymore in your environment, it's trying to access the link below

      https://your_satellite_fqdn_here/content_hosts/498

      Note. This will return "Danger alert:Resource host not found by id '498'"

      In order to fix, yet on "foreman-rake console"

      > ::Katello::Host::ContentFacet.find(464)
      > ::Katello::Host::ContentFacet.find(464).destroy!
      > ::Katello::Host::ContentFacet.find(464)

      Once we got more than one object lost in your content facet, we created a rake that will do the cleanup for you. Just follow as below

      1. Create the file cleanup.rake with the content below

      ::Katello::ContentView.find_by(name: 'GEL-PROD-8_2-DevSuite').content_facets.each do |h|
      puts "#

      {h.id}

      "
      ::Katello::Host::ContentFacet.find(h.id).destroy
      end

      2. Call the foreman-rake passing the file

      1. foreman-rake console < cleanup.rake

      DEV Tracker for https://issues.redhat.com/browse/SAT-18610
      Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2150371

            rhn-engineering-sajha Samir Jha
            satellite-focaccia-bot Focaccia Bot
            Chris Roberts Chris Roberts
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: