Applicability issue with Katello 4.5.0

Problem:
Applicability doesn’t seem to work properly on the server. For instance, there are two updates available according the check-update:

[root@foreman8 ~]# dnf check-update
...
python39-django.noarch        3.2.14-2.el8 ORG_katello_pulpcore_3_18_el8_x86_64
python39-pulp-container.noarch
                              2.10.9-1.el8 ORG_katello_pulpcore_3_18_el8_x86_64
[root@foreman8 ~]# rpm -q python39-django.noarch python39-pulp-container.noarch
python39-django-3.2.13-4.el8.noarch
python39-pulp-container-2.10.7-1.el8.noarch

However, foreman/katello shows 0 installable or applicable updates.

If I search for the packages I can see the current and new version listed, but again with 0 applicable or upgradable hosts.

python39-django-3.2.13-4.el8.noarch 	A high-level Python Web framework that encourages rapid development and clean, pragmatic design 	0 Applicable, 0 Upgradable
python39-django-3.2.14-2.el8.noarch 	A high-level Python Web framework that encourages rapid development and clean, pragmatic design 	0 Applicable, 0 Upgradable

Checking the details for both packages I can see that it correctly shows “Installed On: 2 Host(s)” for the current version.

For the new version it only shows

Installed On:      0 Host(s) 
Applicable To:     0 Host(s) 
Upgradable For:    0 Host(s) 

So why does katello not consider python39-django-3.2.14-2.el8.noarch and applicable and upgradable package for python39-django-3.2.13-4.el8.noarch?

Expected outcome:
Correct applicability.

Foreman and Proxy versions:
foreman-3.3.0-1.el8.noarch
katello-4.5.0-1.el8.noarch

Distribution and version:
AlmaLinux 8…6

Hey @gvde,

I’d recommend first checking the bound_repositories for your host. Those are the repositories that your host is consuming from (that Katello knows about at least):

Host.find(<host_id>).content_facet.bound_repositories

If the repositories make sense, try:

ForemanTasks.sync_task(::Actions::Katello::Applicability::Hosts::BulkGenerate, host_ids: [<host_id>])
Host.find(<host_id>).content_facet.update_applicability_counts
# Does the following return anything now?
Host.find(<host_id>).applicable_rpms

Are you only seeing this on Katello 4.5?

O.K. The repositories from

are correct. It shows the same repositories as dnf repolist on the host.

Then ran the task (successful) and update_applicability_counts shows true.

However, the applicable_rpms shown are those, which are also shown now on the Content-Packages page when I check the Applicable box. Those are rpms from epel8 like rubygem-net-ssh which are actually filtered out in the content view on the host (it has access to a few rpms from epel8).

The list of applicable rpms does not include the two available for update on the host.

So basically, it’s still not correct. It’s still not showing those two rpms as applicable and upgradable.

Okay, so it sounds like some RPMs are making it through as applicable.

If you’re up for an experiment, I’m curious what happens if you switch the host to Default Org + Library. Do those missing RPMs then show up as installable?

This is the method by the way with the applicable RPMs query in case you’re curious: katello/applicable_content_helper.rb at master · Katello/katello · GitHub

Another thing I thought of – modularity might be involved. If you load up your python39-django-3.2.13-2.el8.noarch and python39-django-3.2.14-2.el8.noarch RPMs in the UI, are they listed as modular? And your content host lists the correct python39-django-related module stream as enabled? (I’ll take a wild guess that these django packages are coming from the Pulpcore 3.18 repo?)

Okay I may be onto the issue. Can you try the following?

host=Host.find(id)

bound_repos = host.bound_repositories.collect do |repo|
  repo.library_instance_id.nil? ? repo.id : repo.library_instance_id
end

::Katello::Applicability::ApplicableContentHelper.new(host.content_facet, ::Katello::Rpm, bound_repos).fetch_enabled_
module_stream_ids

I reproduced the issue and I think it’s because this is empty for me. I’m curious if it’s the same for you.

In my case, my ::Katello::AvailableModuleStream.find(83) has a nil context, which is wrong. It looks like the modular profile is getting mangled somehow…

Yes. They are both. It’s from the pulpcore 3.18 repo. The pulpcore module is enabled. It’s listed as enabled on the host

pulpcore 3.18: Fetch, Upload, Organize, and Distribute Software Packages. el8
Name               Stream            Profiles           Summary                 
pulpcore           el8 [e]                              Pulpcore module         

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

It’s also shown as Enabled on the Module Streams tab for the content host. So that’s all correct and matching.

No. I have switched to Library - Default Organization View, ran dnf upload-profile --force-upload to get it updated and have applicability calculated. I see applicable rpms, but those are some epel rpms which my content view usually filters out and some other due to simple content access. But the pulpcore updates are still not listed as applicable.

O.K.:

irb(main):001:0> host=Host.find(1)
=> #<Host::Managed id: 1, name: "foreman8.example.com", last_compile: "2022-09-...
irb(main):002:1* bound_repos = host.bound_repositories.collect do |repo|
irb(main):003:1*   repo.library_instance_id.nil? ? repo.id : repo.library_instan
ce_id
irb(main):004:0> end
=> [128, 96, 9, 6, 86, 102, 105, 80, 7, 69, 10, 76, 61]
irb(main):006:0> ::Katello::Applicability::ApplicableContentHelper.new(host.content_facet, ::Katello::Rpm, bound_repos).fetch_enabled_module_stream_ids
=> #<ActiveRecord::Relation []>

Yes. Seems to be empty for me, too…

The nil context you mention seems to be the case for all my module stream:

irb(main):068:0> ::Katello::AvailableModuleStream.find(11)
=> #<Katello::AvailableModuleStream id: 11, name: "pki-core", stream: "10.6", context: nil>
irb(main):069:0> ::Katello::AvailableModuleStream.find(12)
=> #<Katello::AvailableModuleStream id: 12, name: "pki-deps", stream: "10.6", context: nil>
irb(main):070:0> ::Katello::AvailableModuleStream.find(13)
=> #<Katello::AvailableModuleStream id: 13, name: "postgresql", stream: "12", context: nil>
irb(main):071:0> ::Katello::AvailableModuleStream.find(14)
=> #<Katello::AvailableModuleStream id: 14, name: "pulpcore", stream: "el8", context: nil>

Well, I found the cause. Somehow, this single line is missing from the Katello 4.5.0 gem: katello/app/models/katello/concerns/host_managed_extensions.rb at KATELLO-4.5 · Katello/katello · GitHub

I’m guessing it was removed somehow right before building the gem. I’m in the midst of releasing 4.5.1, so I’ll consider that the fix for this issue.

Same problem as I reported here I guess?
https://community.theforeman.org/t/more-updates-available-from-dnf-then-seen-from-content-hosts-view/30072

I have added the line to /usr/share/gems/gems/katello-4.5.0/app/models/katello/concerns/host_managed_extensions.rb, restarted foreman, run dnf upload-profile --force-upload on the content host to force profile upload and a new applicability run. Now the host has two applicable rpms…

Dumb question: how it is possible that the line got lost?

@tedevil My educated guess is that it’s the same issue.

@gvde I asked around and our guess is that a line was deleted accidentally right before the gem was built and pushed to the delivery team. We haven’t seen that before so I’m as confused as you :upside_down_face:

I took a diff of the gem’s code versus the actual 4.5 branch and that seemed to be the only difference.