How to overcome the dreaded "undefined method `any?' for nil:NilClass" error when mirroring EL8 repos

We find Sat6 to be a little frail and finicky, and we're coming from a Sat5 world with a lot of cobblerd time before that. Let me say: Cobbler is the bomb, and we use mrepo for very little, now.

But, anyway, since sat6 results are inconsistent, we run our repo synchs in cron, with validation. We run in parallel under chronic and a few more things, but we synch 149 repos a night without problems ... except for a few of them. They're all EL8 repos (alma, rocky, springdale, navy, etc) and the error is the same:

undefined method `any?' for nil:NilClass

After a few tickets and pleadings to RH, I just hacked this up myself. It's a tiny fix to hopefully push the variable back into a set where .any?() can work without fear. Initial testing is good but it needs to run the gauntlet tonight.

--- /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.33/app/services/katello/pulp/repository/yum.rb~ 2021-07-06 05:54:49.000000000 -0700
+++ /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.33/app/services/katello/pulp/repository/yum.rb  2021-09-09 13:08:36.456417249 -0700
@@ -152,7 +152,7 @@
         def self.distribution_bootable?(distribution)
           # Not every distribution from Pulp represents a bootable
           # repo. Determine based on the files in the repo.
-          distribution["files"].any? do |file| 
+          [*distribution["files"]].any? do |file|
             if file.is_a? Hash
               filename = file[:relativepath]
             else

I'll pull this post if tonight's run isn't much smoother.

I hope you never see this bug; but, if you do, I hope this tiny patch will help.

Posted Sep 9, 2021, 9:03 PM UTC

20

No comments yet

Nobody commented on this post, or the comments weren't captured.