Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #28644 - Repo Mapper prunes unused subs #8551

Merged
merged 1 commit into from
Feb 5, 2020
Merged

Conversation

parthaa
Copy link
Contributor

@parthaa parthaa commented Jan 30, 2020

Prior to this commit any action that did something like
PUT /katello/api/v2/products/572/repository_sets/7441/enable/
-d '{"releasever":"8", "basearch":"x86_64"}'
would set the arch for a repository using the basearch value even if
basearch is an invalid/unused url substitution. This caused weird bugs
with repo enablement unacknowleged etc

This commit clears out unused subtitutions before the url path is mapped
via repo mapper. This sets the correct value for the arch in the
repository object

Prior to this commit any action that did something like
PUT /katello/api/v2/products/572/repository_sets/7441/enable/
-d '{"releasever":"8", "basearch":"x86_64"}'
would set the arch for a repository using the basearch value even if
basearch is an invalid/unused url substitution. This caused weird bugs
with repo enablement unacknowleged etc

This commit clears out unused subtitutions before the url path is mapped
via repo mapper. This sets the correct value for the arch in the
repository object
@theforeman-bot
Copy link

Issues: #28644

@parthaa
Copy link
Contributor Author

parthaa commented Jan 30, 2020

  • Import a manifest with RHEL 8
  • Go to Content-> Redhat Repositories -> content_label=rhel-8-for-x86_64-appstream-rpms
  • Open up webconsole
  • Expand the appstream repository set and enable the 8.0 repo
  • Go to the webconsole -> network and identify the product id and repository set id from the enable call. Might look something like
    http://example.com:3000/katello/api/v2/products/572/repository_sets/7441/enable/ with a payload that looks like '{"releasever":"8"}
  • Now disable the enabled repo
  • Checkout Master
  • Go to the command line and run
$ curl -k -u admin:changeme -H 'Content-Type: application/json' -X PUT  http://example.com:3000/katello/api/v2/products/572/repository_sets/7441/enable/ -d '{"releasever":"8", "basearch":"x86_64"}'
$ yum install jq -y #unless you want to use something else
$  curl -k -u admin:changeme http://example.com:3000/katello/api/products/572/repository_sets/7441/available_repositories?organization_id=4 | jq .

{
...
  "results": [
    {
      "substitutions": {
        "releasever": "8"
      },
      "path": "/content/dist/rhel8/8/x86_64/appstream/os",
      "repo_name": "Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8",
      "pulp_id": "d76590eb-d356-4605-bf01-24cd6b15ba70",
      "name": "Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)",
      "enabled": false,
      "promoted": false,
      "repository_id": 46
    },
 ...
  ]
}
  • Note even though you enabled rhel 8 you see that enabled is marked false
  • Go to the RH Repos page again. You should notice an Enabled repo there
  • Search for content_label=rhel-8-for-x86_64-appstream-rpms and expand that repository set again
  • Notice that 8.0 is still marked 'enableable'
  • Disable the enabled repo
  • Checkout this PR
  • Go to the command line and run
$ curl -k -u admin:changeme -H 'Content-Type: application/json' -X PUT  http://example.com:3000/katello/api/v2/products/572/repository_sets/7441/enable/ -d '{"releasever":"8", "basearch":"x86_64"}'
$ yum install jq -y #unless you want to use something else
$  curl -k -u admin:changeme http://example.com:3000/katello/api/products/572/repository_sets/7441/available_repositories?organization_id=4 | jq .

{
...
  "results": [
    {
      "substitutions": {
        "releasever": "8"
      },
      "path": "/content/dist/rhel8/8/x86_64/appstream/os",
      "repo_name": "Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8",
      "pulp_id": "d76590eb-d356-4605-bf01-24cd6b15ba70",
      "name": "Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)",
      "enabled": true,
      "promoted": false,
      "repository_id": 46
    },
 ...
  ]
}
  • Note even though you enabled is marked true for rhel 8

  • Go to the RH Repos page again. You should notice an Enabled repo there

  • Search for content_label=rhel-8-for-x86_64-appstream-rpms and expand that repository set again

  • You should not see 8.0 in the repository set.

@chris1984 chris1984 self-assigned this Feb 4, 2020
Copy link
Member

@jturel jturel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised and I think it addressed the problem. ACK

@chris1984
Copy link
Member

Ack, works as described.

@parthaa parthaa merged commit 1a440ef into Katello:master Feb 5, 2020
@parthaa parthaa deleted the 28644 branch February 5, 2020 14:40
jturel pushed a commit to jturel/katello that referenced this pull request Feb 28, 2020
Prior to this commit any action that did something like
PUT /katello/api/v2/products/572/repository_sets/7441/enable/
-d '{"releasever":"8", "basearch":"x86_64"}'
would set the arch for a repository using the basearch value even if
basearch is an invalid/unused url substitution. This caused weird bugs
with repo enablement unacknowleged etc

This commit clears out unused subtitutions before the url path is mapped
via repo mapper. This sets the correct value for the arch in the
repository object

(cherry picked from commit 1a440ef)
jturel pushed a commit that referenced this pull request Feb 28, 2020
Prior to this commit any action that did something like
PUT /katello/api/v2/products/572/repository_sets/7441/enable/
-d '{"releasever":"8", "basearch":"x86_64"}'
would set the arch for a repository using the basearch value even if
basearch is an invalid/unused url substitution. This caused weird bugs
with repo enablement unacknowleged etc

This commit clears out unused subtitutions before the url path is mapped
via repo mapper. This sets the correct value for the arch in the
repository object

(cherry picked from commit 1a440ef)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants