Bug 2054008

Summary: Retain packages on Repository does not synchronize the specified number of packages on Satellite 7
Product: Red Hat Satellite Reporter: Manu Sunil <msunil>
Component: RepositoriesAssignee: Samir Jha <sajha>
Status: CLOSED ERRATA QA Contact: Cole Higgins <chiggins>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.11.0CC: pcreech, sajha, spusater
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.3.0.9-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:33:17 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 Manu Sunil 2022-02-13 22:59:13 UTC
Description of problem:

- Retain package versions option on the repository does not retain the specified number of package versions after synchronization.

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

- satellite-7.0.0-0.5.beta.el7sat.noarch
- foreman-3.1.1.4-1.el7sat.noarch

How reproducible:

- Always

Steps to Reproduce:

1. Create a repository to sync a custom product.

2. On the upstream location, add one package and create the repodata.

3. Sync the repository on the Satellite with the following settings.

   Retain Package: 1
   Mirroring Policy: Additive

4. Add another package to the upstream location and recreate the repodata again.

5. Sync the repository on the Satellite with the following settings.

   Retain Package: 2
   Mirroring Policy: Additive


Actual results:

1. First Sync

   The upstream repository:

   ~~~
   # ls 
   kernel-4.18.0-80.el8.x86_64.rpm  repodata
   ~~~

   ~~~
   # hammer repository info --id 27
   Id:                      27
   Name:                    CUSTOM_REPO_3
   Label:                   CUSTOM_REPO_3
   Description:             
   Organization:            RedHat
   Red Hat Repository:      no
   Content Type:            yum
   Mirror on Sync:          no
   Url:                     http://upstreamrepo.example.com/repos/satellite_custom_test_repo/
   Publish Via HTTP:        yes
   Published At:            https://satellite.example.com/pulp/content/RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3/
   Relative Path:           RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3
   Download Policy:         on_demand
   Ignorable Content Units: 
   HTTP Proxy:              
       HTTP Proxy Policy: global_default_http_proxy
   Product:                 
       Id:   294
       Name: CUSTOM_REPOSITORIES
   GPG Key:                 
   
   Sync:                    
       Status:         Success
       Last Sync Date: 1 minute
   Created:                 2022/02/13 06:02:55
   Updated:                 2022/02/13 06:02:58
   Content Counts:          
       Packages:       1
       Source RPMS:    0
       Package Groups: 0
       Errata:         0
       Module Streams: 0
   ~~~


   ~~~
            name         |                        base_path                        |                                        relative_path          

   ----------------------+---------------------------------------------------------+---------------------------------------------------------------
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.el8.x86_64.rpm                     
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.el8.x86_64.rpm                     
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.el8.x86_64.rpm                     
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.el8.x86_64.rpm                     
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.el8.x86_64.rpm                     
   ~~~

2. Second Sync after increasing the Retain Package versions to 2.


   ~~~
   hammer> repository info --id 27
   Id:                      27
   Name:                    CUSTOM_REPO_3
   Label:                   CUSTOM_REPO_3
   Description:             
   Organization:            RedHat
   Red Hat Repository:      no
   Content Type:            yum
   Mirror on Sync:          no
   Url:                     http://upstreamrepo.example.com/repos/satellite_custom_test_repo/
   Publish Via HTTP:        yes
   Published At:            https://satellite.example.com/pulp/content/RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3/
   Relative Path:           RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3
   Download Policy:         on_demand
   Ignorable Content Units: 
   HTTP Proxy:              
       HTTP Proxy Policy: global_default_http_proxy
   Product:                 
       Id:   294
       Name: CUSTOM_REPOSITORIES
   GPG Key:                 
   
   Sync:                    
       Status:         Success
       Last Sync Date: 8 minutes
   Created:                 2022/02/13 06:02:55
   Updated:                 2022/02/13 06:09:52
   Content Counts:          
       Packages:       1       <-------- Package count is still one.     
       Source RPMS:    0
       Package Groups: 0
       Errata:         0
       Module Streams: 0
   ~~~

   The package changed to the newest version from the upstream repository and the old version was removed. 


           name         |                        base_path                        |                                        relative_path                                     
   ----------------------+---------------------------------------------------------+------------------------------------------------------
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.1.2.el8_0.x86_64.rpm        
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.1.2.el8_0.x86_64.rpm        
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.1.2.el8_0.x86_64.rpm        
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.1.2.el8_0.x86_64.rpm        
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.1.2.el8_0.x86_64.rpm        


3. Added another package to the upstream repository and synced again with Retain Package Versions package value 5

   Upstream Repository.

   ~~~
   # ll 
   total 1228 
   -rw-r--r--. 1 root root 415364 May 14  2019 kernel-4.18.0-80.1.2.el8_0.x86_64.rpm 
   -rw-r--r--. 1 root root 419436 Jun 17  2019 kernel-4.18.0-80.4.2.el8_0.x86_64.rpm 
   -rw-r--r--. 1 root root 409836 Mar 21  2019 kernel-4.18.0-80.el8.x86_64.rpm
   drwxr-xr-x. 2 root root   4096 Feb 13 12:03 repodata
   ~~~

   # zgrep metadata repodata/*primary*
   repodata/caa37f79857badc4a11db3de3451b146364ebb76390c6b9e879ad6e6943800a9-primary.xml.gz:<metadata xmlns="http://linux.duke.edu/metadata/common" xmlns:rpm="http://linux.duke.edu/metadata/rpm" packages="3">


   ~~~
   hammer> repository info --id 27
   Id:                      27
   Name:                    CUSTOM_REPO_3
   Label:                   CUSTOM_REPO_3
   Description:             
   Organization:            RedHat
   Red Hat Repository:      no
   Content Type:            yum
   Mirror on Sync:          no
   Url:                     http://upstreamrepo.example.com/repos/satellite_custom_test_repo/
   Publish Via HTTP:        yes
   Published At:            https://satellite.example.com/pulp/content/RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3/
   Relative Path:           RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3
   Download Policy:         on_demand
   Ignorable Content Units: 
   HTTP Proxy:              
       HTTP Proxy Policy: global_default_http_proxy
   Product:                 
       Id:   294
       Name: CUSTOM_REPOSITORIES
   GPG Key:                 
   
   Sync:                    
       Status:         Success
       Last Sync Date: 3 minutes
   Created:                 2022/02/13 06:02:55
   Updated:                 2022/02/13 06:37:24
   Content Counts:          
       Packages:       1
       Source RPMS:    0
       Package Groups: 0
       Errata:         0
       Module Streams: 0
   ~~~

  
   Similarly like before the package changed to the newer version but the older versions were removed even though the Retain Package Versions option is set to 5


            name         |                        base_path                        |                                        relative_path    
   ----------------------+---------------------------------------------------------+---------------------------------------------------------
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.4.2.el8_0.x86_64.rpm         
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.4.2.el8_0.x86_64.rpm         
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.4.2.el8_0.x86_64.rpm         
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.4.2.el8_0.x86_64.rpm         
    CUSTOM_REPO_3-271771 | RedHat/Library/custom/CUSTOM_REPOSITORIES/CUSTOM_REPO_3 | Packages/k/kernel-4.18.0-80.4.2.el8_0.x86_64.rpm         

- Each time the repository is synced after adding new packages, the old packages are removed and the specified count of versions is not retained.

Expected results:

- The specified count of package versions should be synced.

Comment 2 Samir Jha 2022-02-17 17:17:46 UTC
Created redmine issue https://projects.theforeman.org/issues/34469 from this bug

Comment 5 Bryan Kearney 2022-02-23 20:05:38 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34469 has been resolved.

Comment 8 Silas Pusateri 2022-05-03 17:49:49 UTC
Verified.

Version tested: Sat 6.11 snap 18.5

Steps:
1. Create a repo with a negative 'retain_package_versions_count'
2. Try to save the repo
3. After it fails, set the 'retain_package_versions_count' to a positive number
4. Save the repo 
5. Ensure the correct 'retain_package_versions_count' is set 
6. Sync the repo

Expected result:
The repo should sync the correct number of packages based on 'retain_package_versions_count'

Result:
The repo syncs the correct number of packages based on 'retain_package_versions_count'

Comment 11 errata-xmlrpc 2022-07-05 14:33:17 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