Bug 2280574
| Summary: | CV promote fails with undefined method `get_status' for nil:NilClass when deleting a Host in the CV during Finalize phase of the Promote task | ||
|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | Pavel Moravec <pmoravec> |
| Component: | Hosts - Content | Assignee: | satellite6-bugs <satellite6-bugs> |
| Status: | CLOSED MIGRATED | QA Contact: | Satellite QE Team <sat-qe-bz-list> |
| Severity: | medium | Docs Contact: | |
| Priority: | high | ||
| Version: | 6.14.4 | CC: | ramsingh, rlavi |
| Target Milestone: | Unspecified | Keywords: | EasyFix, MigratedToJIRA, Triaged |
| Target Release: | Unused | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2024-06-06 17:39:17 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there. Due to differences in account names between systems, some fields were not replicated. Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information. To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer. You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like: "Bugzilla Bug" = 1234567 In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information. |
Description of problem: When promoting a CV to a LE (maybe also during other scenarios, not sure now), the task can fail during Finalize step Actions::Katello::ContentView::PromoteToEnvironment . The reason is in code: /usr/share/gems/gems/katello-4.9.0.25/app/models/katello/content_view.rb new line 437: ~~~ def update_host_statuses(environment) # update errata applicability counts for all hosts in the CV & LE Location.no_taxonomy_scope do User.as_anonymous_admin do ::Katello::Host::ContentFacet.in_content_views_and_environments( content_views: [self], lifecycle_environments: [environment] ).each do |facet| facet.update_applicability_counts facet.update_errata_status end end end end ~~~ where: 1) ContentFacet list is generated 2) for each facet, applicability is being recalculated 3) some Host for such a facet is deleted 4) the facet for the deleted Host is being recalculated Then, the 4) fails with backtrace: NoMethodError undefined method `get_status' for nil:NilClass --- - "/usr/share/gems/gems/katello-4.9.0.25/app/models/katello/host/content_facet.rb:331:in `update_errata_status'" - "/usr/share/gems/gems/katello-4.9.0.25/app/models/katello/content_view.rb:438:in `block (3 levels) in update_host_statuses'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/delegation.rb:88:in `each'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/delegation.rb:88:in `each'" - "/usr/share/gems/gems/katello-4.9.0.25/app/models/katello/content_view.rb:436:in `block (2 levels) in update_host_statuses'" - "/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'" - "/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'" - "/usr/share/gems/gems/katello-4.9.0.25/app/models/katello/content_view.rb:432:in `block in update_host_statuses'" - "/usr/share/foreman/app/models/taxonomy.rb:73:in `block in no_taxonomy_scope'" - "/usr/share/foreman/app/models/taxonomy.rb:80:in `block (2 levels) in as_taxonomy'" - "/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:195:in `as_location'" - "/usr/share/foreman/app/models/taxonomy.rb:79:in `block in as_taxonomy'" - "/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:154:in `as_org'" - "/usr/share/foreman/app/models/taxonomy.rb:78:in `as_taxonomy'" - "/usr/share/foreman/app/models/taxonomy.rb:72:in `no_taxonomy_scope'" - "/usr/share/gems/gems/katello-4.9.0.25/app/models/katello/content_view.rb:431:in `update_host_statuses'" - "/usr/share/gems/gems/katello-4.9.0.25/app/lib/actions/katello/content_view/promote_to_environment.rb:49:in `finalize'" Because we call "host.get_status(::Katello::ErrataStatus).refresh!" for a removed Host. Version-Release number of selected component (if applicable): Sat 6.14, but applicable to any version, I think How reproducible: 100% Steps to Reproduce: 1. Have Satellite with a bigger CV (promoted to non-Library LE) and many Hosts associated to the CV/LE. To populate fake Hosts, you can run below script in a loop: ~~~ domain=YOUR.HOST.DOMAIN ak=YOUR.ACTIVATION.KEY org=YOUR.ORGANIZATION uuid=$(uuidgen) short=$(hostname -s) echo "{\"dmi.system.uuid\": \"${uuid}\"}" > /etc/rhsm/facts/uuid.facts hostnamectl set-hostname ${short}.${uuid%%-*}.${domain} subscription-manager clean subscription-manager register --activationkey ${ak} --org ${org} ~~~ (a few hundreds of Hosts is sufficient) 2. Create a new version of the CV and promote it to the LE associated with the Hosts. 3. *During* the promote, regularly delete some Hosts - you must catch the time when Finalize phase is running. One can mimic 2. even for already promoted CV/LE by running (customize own CV id and LE id): (within foreman-rake console) ::Katello::ContentView.find(54).update_host_statuses(Katello::KTEnvironment.find(2)) (once you run this, delete a Host) Actual results: 2. fails in Actions::Katello::ContentView::PromoteToEnvironment step in Finalize phase with above backtrace. Optionally, foreman-rake mimicking reproducer fails with: irb(main):138:0> ::Katello::ContentView.find(54).update_host_statuses(Katello::KTEnvironment.find(2)) Traceback (most recent call last): 16: from lib/tasks/console.rake:5:in `block in <top (required)>' 15: from (irb):138 14: from katello (4.9.0.25) app/models/katello/content_view.rb:431:in `update_host_statuses' 13: from app/models/taxonomy.rb:72:in `no_taxonomy_scope' 12: from app/models/taxonomy.rb:78:in `as_taxonomy' 11: from app/models/concerns/foreman/thread_session.rb:154:in `as_org' 10: from app/models/taxonomy.rb:79:in `block in as_taxonomy' 9: from app/models/concerns/foreman/thread_session.rb:195:in `as_location' 8: from app/models/taxonomy.rb:80:in `block (2 levels) in as_taxonomy' 7: from app/models/taxonomy.rb:73:in `block in no_taxonomy_scope' 6: from katello (4.9.0.25) app/models/katello/content_view.rb:432:in `block in update_host_statuses' 5: from app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin' 4: from app/models/concerns/foreman/thread_session.rb:108:in `as' 3: from katello (4.9.0.25) app/models/katello/content_view.rb:436:in `block (2 levels) in update_host_statuses' 2: from katello (4.9.0.25) app/models/katello/content_view.rb:439:in `block (3 levels) in update_host_statuses' 1: from katello (4.9.0.25) app/models/katello/host/content_facet.rb:331:in `update_errata_status' NoMethodError (undefined method `get_status' for nil:NilClass) irb(main):139:0> Expected results: No such exception. Additional info: Potential fix: add "if content.host" twice: def update_host_statuses(environment) # update errata applicability counts for all hosts in the CV & LE Location.no_taxonomy_scope do User.as_anonymous_admin do ::Katello::Host::ContentFacet.in_content_views_and_environments( content_views: [self], lifecycle_environments: [environment] ).each do |facet| facet.update_applicability_counts if facet.host # here it is optional facet.update_errata_status if facet.host # here it is crucial end end end end