Bug 1712811

Summary: /katello/api/repository_sets/:id returns too many repositories
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: API - ContentAssignee: Ian Ballou <iballou>
Status: CLOSED ERRATA QA Contact: Jitendra Yejare <jyejare>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: pcreech
Target Milestone: 6.6.0Keywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.12.0.4-11.master Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-22 19:48:51 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 Evgeni Golov 2019-05-22 09:52:24 UTC
Description of problem:
When calling the /katello/api/repository_sets/:id API endpoint, Katello (in 6.5) will return every version/copy of a repository when it is published to multiple contentviews/environments:

GET /katello/api/repository_sets/2456
[DEBUG] Params: {
    "organization_id" => 3
}
[DEBUG] Headers: {
    :params => {
        "organization_id" => 3
    }
}
[DEBUG] Response: {
         "enabled" => true,
         "product" => {
          "id" => 9,
        "name" => "Red Hat Enterprise Linux Server"
    },
    "repositories" => [
        [   0] {
                    "id" => 86206,
                  "name" => "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server",
                  "arch" => "x86_64",
            "releasever" => "7Server"
        },
        [   1] {
                    "id" => 86216,
                  "name" => "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server",
                  "arch" => "x86_64",
            "releasever" => "7Server"
        },
        …
        [1544] {
                    "id" => 23549,
                  "name" => "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server",
                  "arch" => "x86_64",
            "releasever" => "7Server"
        },
        [1545] {
                    "id" => 1,
                  "name" => "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server",
                  "arch" => "x86_64",
            "releasever" => "7Server"
        }
    ],
            "name" => "Red Hat Enterprise Linux 7 Server (RPMs)",
          "vendor" => "Red Hat",
           "label" => "rhel-7-server-rpms",
              "id" => "2456",
            "type" => "yum",
          "gpgUrl" => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
      "contentUrl" => "/content/dist/rhel/server/7/$releasever/$basearch/os"
}


In 6.4, the response only lists the "real" repository:

[DEBUG 2019-05-22T09:35:50 API] Params: {}
[DEBUG 2019-05-22T09:35:50 API] Headers: {
    :params => {}
}
[DEBUG 2019-05-22T09:35:50 API] Response: {
         "enabled" => false,
         "product" => {
          "id" => 23,
        "name" => "Red Hat Ansible Engine"
    },
    "repositories" => [
        [0] {
                    "id" => 1,
                  "name" => "Red Hat Ansible Engine 2.6 RPMs for Red Hat Enterprise Linux 7 Server x86_64",
                  "arch" => "x86_64",
            "releasever" => nil
        }
    ],
            "name" => "Red Hat Ansible Engine 2.6 RPMs for Red Hat Enterprise Linux 7 Server",
          "vendor" => "Red Hat",
           "label" => "rhel-7-server-ansible-2.6-rpms",
              "id" => "7387",
            "type" => "yum",
          "gpgUrl" => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
      "contentUrl" => "/content/dist/rhel/server/7/7Server/$basearch/ansible/2.6/os"
}

This "breaks" Foreman Ansible Modules/Nailgun as Nailgun will query repository information for each of the 1545 repositories listed, which takes a lot of time

Version-Release number of selected component (if applicable):
Satellite 6.5

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 4 Ian Ballou 2019-06-05 21:02:41 UTC
Created redmine issue https://projects.theforeman.org/issues/26967 from this bug

Comment 5 John Mitsch 2019-06-06 15:16:04 UTC
Created redmine issue https://projects.theforeman.org/issues/26981 from this bug

Comment 6 Bryan Kearney 2019-06-13 14:05:12 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26981 has been resolved.

Comment 8 Jitendra Yejare 2019-07-09 12:23:05 UTC
Verified!

@ Satellite 6.6 snap 10

Steps:
-------------
1. Enable RHEL7 Server repository
2. Create 2 content views and add above repository in both content views.
3. Publish content views
4. Get repository Set details of RHEL7 server reposioty
# curl -u admin:changeme -X GET https://satellite.com/katello/api/v2/repository_sets/2456 -d 'organization_id=2' --insecure


Observation:
------------------

{
  "enabled": true,
  "product": {
    "id": 67,
    "name": "Red Hat Enterprise Linux Server"
  },
  "repositories": [
    {
      "id": 8,
      "name": "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server",
      "arch": "x86_64",
      "releasever": "7Server"
    }
  ],
  "name": "Red Hat Enterprise Linux 7 Server (RPMs)",
  "vendor": "Red Hat",
  "label": "rhel-7-server-rpms",
  "id": "2456",
  "type": "yum",
  "gpgUrl": "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
  "contentUrl": "/content/dist/rhel/server/7/$releasever/$basearch/os"
}

Comment 9 Bryan Kearney 2019-10-22 19:48:51 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, 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-2019:3172