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 2025494 - Capsule sync task failed to refresh repo that doesn't have feed url with "bad argument (expected URI object or URI string)" error
Summary: Capsule sync task failed to refresh repo that doesn't have feed url with "bad...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Capsule - Content
Version: 6.10.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.11.0
Assignee: satellite6-bugs
QA Contact: Vladimír Sedmík
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-22 11:27 UTC by Hao Chang Yu
Modified: 2024-12-20 21:38 UTC (History)
13 users (show)

Fixed In Version: katello-4.3.0-1.el7sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2030448 (view as bug list)
Environment:
Last Closed: 2022-07-05 14:30:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 33893 0 Normal Closed smart proxy syncing a repository that has no upstream url set error with '"bad argument (expected URI object or URI stri... 2021-11-29 18:35:30 UTC
Github Katello katello pull 9803 0 None open Fixes #33966 - Capsule sync task failed to refresh repos 2021-11-23 01:13:59 UTC
Red Hat Knowledge Base (Solution) 6560221 0 None None None 2021-12-02 22:25:18 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:30:39 UTC

Description Hao Chang Yu 2021-11-22 11:27:55 UTC
Description of problem:

There are 2 issues here:
1) The "needs_updates?" will always be "true" so Satellite will always try to refresh the repos in the Capsule.
2) Capsule sync task failed to refresh custom repository without feed url:
---------------------------------------------
5: Actions::Pulp3::Orchestration::Repository::RefreshRepos (skipped) [ 6.90s / 6.41s ]

Error:

ArgumentError

bad argument (expected URI object or URI string)
---
- "/opt/rh/rh-ruby27/root/usr/share/ruby/uri/common.rb:739:in `URI'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository/yum.rb:15:in
  `remote_options'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository.rb:197:in
  `compute_remote_options'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository_mirror.rb:37:in
  `needs_updates?'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository.rb:167:in
  `mirror_needs_updates?'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/lib/actions/katello/capsule_content/refresh_repos.rb:43:in
  `block in invoke_external_task'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in
  `each'"
- "/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in
  `each'"
--------------------------------------------

Below should be the offending lines

In /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository_mirror.rb
      def needs_updates?
        remote = fetch_remote
        return true if remote.blank?
        options = repo_service.compute_remote_options   <=============== It seems like "self.compute_remote_options" should be used here
        options.keys.any? { |key| remote.send(key) != options[key] }
      end


In "/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.39/app/services/katello/pulp3/repository/yum.rb", 

        def remote_options
          options = common_remote_options
          uri = URI(root.url)   <==========================  This will gives error if root repo has no feed.
          unless root.upstream_authentication_token.blank?
            options.merge!(sles_auth_token: root.upstream_authentication_token)
          end
          options.merge!(url: uri.to_s, policy: root.download_policy)
        end


Steps to Reproduce:
1. Create a custom repo without feed and manually upload content to it.
2. Create a CV add the custom repo to the CV.
3. Publish and Promote the CV which should trigger a capsule sync task.
4. The capsule sync task should finish without error.
5. Upload new content to the custom repo.
6. Publish and Promote the CV again.

Actual results:
Capsule sync task failed to refresh repos with "bad argument (expected URI object or URI string)" error.


Expected results:
No error. Only refresh repos as needed

Comment 2 Justin Sherrill 2021-12-01 20:27:03 UTC
As a workaround for this bug, you could either:

1.  For any repository being synced to a capsule that does not have a url, navigate to products > click a product > click a repository

set some dummy url such as "http://example.com/repo".  Note you do not need to sync the repository, just having the url set should workaround the bug


OR

2.  Apply this patch:  https://github.com/Katello/katello/pull/9803.patch

restart all satellite services

Comment 3 Sayan Das 2021-12-02 21:00:42 UTC
(In reply to Justin Sherrill from comment #2)
> As a workaround for this bug, you could either:
> 
> 1.  For any repository being synced to a capsule that does not have a url,
> navigate to products > click a product > click a repository
> 
> set some dummy url such as "http://example.com/repo".  Note you do not need
> to sync the repository, just having the url set should workaround the bug
> 
> 
> OR
> 
> 2.  Apply this patch:  https://github.com/Katello/katello/pull/9803.patch
> 
> restart all satellite services



If the dummy URL workaround is being used, then any CV that contains that repo, should be republished and promoted or else the sync will fail with this error:


"undefined method `pulp_href' for nil:NilClass"


A solution article is on it's way but meanwhile, I dropped the note here.

Comment 5 wclark 2022-01-17 14:35:48 UTC
There is a hotfix available for Satellite 6.10.1, attached to the clone of this BZ for that version at https://bugzilla.redhat.com/show_bug.cgi?id=2030448#c4

Comment 6 Vladimír Sedmík 2022-02-24 13:09:01 UTC
Verified on 7.0 snap 10 - Capsule synced successfully without any errors, packages are present on the capsule side.

Comment 12 errata-xmlrpc 2022-07-05 14:30:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498


Note You need to log in before you can comment on or make changes to this bug.