Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2237999

Summary: promoting a CCV with a docker repo to LE with Registry Name Pattern raises NilClass::Jail exception
Product: Red Hat Satellite Reporter: Pavel Moravec <pmoravec>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.13.0CC: ahumbe, iballou, momran, qjames, rlavi, vdeshpan
Target Milestone: 6.15.0Keywords: EasyFix, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-10-27 15:52:48 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:

Description Pavel Moravec 2023-09-08 10:32:26 UTC
Description of problem:
Having a LE with Registry Name Pattern referring to either repository.* variable, and promoting a CCV with a docker repo to this LE raises exception like:

2023-09-08T11:55:26 [E|bac|e990f9c3] undefined method '#label' for NilClass::Jail (NilClass) (Safemode::NoMethodError)
 e990f9c3 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:22:in `method_missing'
 e990f9c3 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:55:in `initialize'
 e990f9c3 | /usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'
 e990f9c3 | /usr/share/gems/gems/katello-4.7.0.31/app/models/katello/repository.rb:875:in `safe_render_container_name'
 e990f9c3 | /usr/share/gems/gems/katello-4.7.0.31/app/lib/katello/validators/environment_docker_repositories_validator.rb:25:in `block in validate_repositories'
 e990f9c3 | /usr/share/gems/gems/katello-4.7.0.31/app/lib/katello/validators/environment_docker_repositories_validator.rb:24:in `each'
 e990f9c3 | /usr/share/gems/gems/katello-4.7.0.31/app/lib/katello/validators/environment_docker_repositories_validator.rb:24:in `validate_repositories'
 e990f9c3 | /usr/share/gems/gems/katello-4.7.0.31/app/models/katello/content_view.rb:617:in `block in check_docker_repository_names!'


The reason is here in /usr/share/gems/gems/katello-4.7.0.31/app/models/katello/content_view.rb :

    def publish_repositories(override_components = nil)
      repositories = composite? ? repositories_to_publish_by_library_instance(override_components).values : repositories_to_publish
      repositories.each do |repos|
        if repos.is_a? Array
          yield repos
        else
          yield [repos]
        end
      end
    end

or more precisely in:

    def repositories_to_publish_by_library_instance(override_components = nil)
      # retrieve the list of repositories in a hash, where the key
      # is the library instance id, and the value is an array
      # of the repositories for that instance.
      repositories_to_publish(override_components).inject({}) do |result, repo|
        result[repo.library_instance] ||= []
        result[repo.library_instance] << repo
        result
      end
    end

which for CCV returns an Array of Array of Katello::Repository

While "repositories_to_publish" method itself (used for non-composite CVs) returns Katello::Repository::ActiveRecord_Relation .



Version-Release number of selected component (if applicable):
Sat 6.11 till 6.13 (at least)


How reproducible:
100%


Steps to Reproduce:
1. Have a docker repo (optionally synced, that doesnt matter)
2. Have a LE with "Registry Name Pattern:" set to e.g.:

<%= organization.label %>-<%= lifecycle_environment.label %>-<%= content_view.label %>-<%= product.label %>-<%= repository.label %>

(or any other variable from:

repository.name
repository.label
repository.docker_upstream_name

)

3. Have a CV with the docker repo, promoted to that LE
4. Have a CCV with that CV and try promoting it to the LE


Actual results:
4. raises exception as above


Expected results:
4. no exception raised


Additional info:

Comment 1 Ian Ballou 2023-09-25 20:21:48 UTC
This might end up being a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=2153523

Comment 2 Quinn James 2023-10-27 15:52:48 UTC
Hi! I'm closing out this BZ due to no longer being able to reproduce the issue. As Ian mentioned, this behavior was fixed in https://bugzilla.redhat.com/show_bug.cgi?id=2153523. All the mentioned `repository.*` variables seem to work without issue.

*** This bug has been marked as a duplicate of bug 2153523 ***