Description of problem: Set “Entries per page” to 5 in setting and sync more than 5 repositories on satellite. Now adding repositories into content view using repository name doesn’t work with hammer. Version: Satellite 6.2 Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Set “Entries per page” in Settings to 5 2. Sync more than 5 repositories on satellite 3. Update a content view to add a repository using repository name. satellite ~]# hammer content-view list --name cv1 ----------------|--------------|--------------|-----------|--------------- Cv ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS ----------------|--------------|--------------|-----------|--------------- 26 | cv1 |cv1 | ----------------|--------------|--------------|-----------|--------------- satellite ~]# hammer content-view update --id 26 --repositories 'Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server','Red Hat Enterprise Linux 7 Server - Supplementary RPMs x86_64 7Server' --organization Redhat Content view updated [root@rh-satellite ~]# hammer content-view list --name cv1 ----------------|--------------|--------------|-----------|--------------- CV ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS ----------------|--------------|--------------|-----------|--------------- 26 | cv1 | cv1 | ----------------|--------------|--------------|-----------|--------------- However, using repository-id this seems to work. satellite ~]# hammer content-view update -id 26 --repository-ids 42,27 --organization Redhat Content view updated [root@rh-satellite ~]# hammer content-view list --name cv1 ----------------|--------------|--------------|-----------|--------------- CONTENT VIEW ID | NAME | LABEL | COMPOSITE | REPOSITORY IDS ----------------|--------------|--------------|-----------|--------------- 26 | cv1 | cv1 | | 27, 42 ----------------|--------------|--------------|-----------|--------------- Actual results: While adding a repository using repository id, repositories are successfully added while using repository name it is not possible. Expected results: Repositories should get added using both repository name and repository id. Additional info: Here is debug log [[32m INFO[0m [34m2018-02-08 10:16:13[0m [36mAPI[0m] GET /katello/api/repositories [DEBUG [34m2018-02-08 10:16:13[0m [36mAPI[0m] Params: { "names" => [ [0] "Red Hat OpenStack Platform 10 for RHEL 7 RPMs x86_64 7Server", [1] "Red Hat OpenStack Platform 10 Developer Tools for RHEL 7 RPMs x86_64 7Server" ], "organization_id" => 1 } [DEBUG [34m2018-02-08 10:16:13[0m [36mAPI[0m] Headers: { :params => { "names" => [ [0] "Red Hat OpenStack Platform 10 for RHEL 7 RPMs x86_64 7Server", [1] "Red Hat OpenStack Platform 10 Developer Tools for RHEL 7 RPMs x86_64 7Server" ], "organization_id" => 1 } } [DEBUG [34m2018-02-08 10:16:13[0m [36mAPI[0m] Response: { "total" => 66, "subtotal" => 66, "page" => 1, "per_page" => 20, "error" => nil, "search" => nil, "sort" => { "by" => nil, "order" => nil }, Form the debug logs generated while executing hammer command it seems that customer was having total 66 repositories synced while the per_page setting was set to 20, hence while adding repositories hammer was able to get only 20 repositories and rest were all not considered. Workaround for this issue was changing the per_page size to 20 from satellite GUI "Administer" -> "Settings" and modify "Entries per page" to 70 After performing the above changes customer was able to add repositories through repository name.
This appears to be an issue also on Satellite 6.3; however, the behavior is slightly different. In 6.3, the CV is updated; however, the first repository in the list is added to the content view. E.g. hammer> content-view update --id 4 --repositories 'Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server, Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.4' --organization "Default Organization" Content view updated The above will add "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server" to the CV. The PUT request sent to the server, will only contain the ID of that repository vs an array of IDs. E.g. [I] Started PUT "/katello/api/content_views/4" for 192.168.121.66 at 2018-02-19 19:36:28 +0000 [I] Processing by Katello::Api::V2::ContentViewsController#update as JSON [I] Parameters: {"repository_ids"=>[2], "api_version"=>"v2", "id"=>"4", "content_view"=>{"repository_ids"=>[2]}}
Verified in a test 6.4 environment and a customer 6.3 environment - appears we have two issues that can cause failure using hammer content-view update by name. Issue 1: The original issue described in the description can fail if there are more than 20 repos in an organization. This may appear to succeed with a "Content view updated", but actual fail to add all requested repos. Issue #1 workaround: Increase the entries_per_page value to a sufficiently high number to cover all possible repos. Example: hammer settings set --name=entries_per_page --value=100 Issue 2: If there are multiple organizations with repos sharing the same name (ie "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server") it may with the error "Cannot add a repository from an Organization other than $ORG." It appears the content-view update by name logic builds a list of repository IDs from the repo names provided. When it pulls the list of repository names it does not appear to honor the --organization flag and instead pulls ALL repos for ALL orgs. The repo id map it then creates internally may include repos for other organizations, causing the failure. Issue #2 workaround: It appears you must manually build a list of repository IDs for the specific organization and use content-view update using --repository-ids instead of --repositories by name. ---- It seems it would be recommended to avoid using content-view update with --repositories by name if you have multiple organizations with duplicate repository names.
Connecting redmine issue https://projects.theforeman.org/issues/26091 from this bug
Connecting redmine issue https://projects.theforeman.org/issues/26095 from this bug
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26091 has been resolved.
Ok sounds like there are layers to this but I propose they be separate bugs 1) If you gave a non existent repository name, The Content View update will show up as "updated" and no repositories added. However adding a valid repo seems to work ok """ [vagrant@zeta hammer-cli-katello]$ hammer content-view list ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- 2 | Default Organization View | 0b440a8c-818a-4284-be08-c82705480eba | | 2019/06/12 21:52:06 | 1 | Default Organization View | Default_Organization_View | | 2019/06/08 06:01:49 | 3 | myview | myview | | | 8 ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- [vagrant@zeta hammer-cli-katello]$ hammer content-view update --id=3 --repositories=joy --product=joy --organization-id=1 Content view updated. [vagrant@zeta hammer-cli-katello]$ hammer content-view list ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- 2 | Default Organization View | 0b440a8c-818a-4284-be08-c82705480eba | | 2019/06/12 21:52:06 | 1 | Default Organization View | Default_Organization_View | | 2019/06/08 06:01:49 | 3 | myview | myview | | | 8 ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- [vagrant@zeta hammer-cli-katello]$ hammer content-view update --id=3 --repositories=joylessExistence --product=joy --organization-id=1 Content view updated. [vagrant@zeta hammer-cli-katello]$ hammer content-view list ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- 2 | Default Organization View | 0b440a8c-818a-4284-be08-c82705480eba | | 2019/06/12 21:52:06 | 1 | Default Organization View | Default_Organization_View | | 2019/06/08 06:01:49 | 3 | myview | myview | | | ----------------|---------------------------|--------------------------------------|-----------|---------------------|--------------- """ 2) Repositories are uniquely scoped per product. This means we are stuck with a limitation when repository names are provided. The anomaly in the behavior of this call is that You can do something like hammer content-view update --id=3 --repository-ids=1,2,3,4,5 while using name you are forced to provide a product id hammer content-view update --id=3 --repositories="Foo, Bar" --product-id=1 Which means you can only add repositories belonging to a single product to the content view. I believe both of the above cases need to get solved as separate issues and not be connected with this.
More over there are "hammer content-view add-repository" and "remove-repository" commands for the user if they want fine grained control. So a 3 rd option could be just not supporting the --repositories flag at all.
Created: https://bugzilla.redhat.com/show_bug.cgi?id=1727685 KCS was updated and workaround has been provided here -> https://access.redhat.com/solutions/3365661 Closing this as wontfix. Use the other bz to track deprecation of the --repositories command.