Bug 1300211

Summary: capsule-certs-generate failed to increment release number when generating certificate rpm for foreman-proxy
Product: Red Hat Satellite Reporter: Nagoor Shaik <nshaik>
Component: CertificatesAssignee: satellite6-bugs <satellite6-bugs>
Status: VERIFIED --- QA Contact: Devendra Singh <desingh>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1.4CC: ahumbe, amasolov, chrobert, ehelms, ekohlvan, hprakash, inecas, lpurcell, mmccune, stbenjam, sthirugn
Target Milestone: 6.8.0Keywords: GSSTriaged, PrioBumpField, PrioBumpQA, Reopened, Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: katello-certs-tools-2.7.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-01 18:35:39 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:

Description Nagoor Shaik 2016-01-20 09:30:59 UTC
Description of problem:
capsule-certs-generate failed to increment release number when generating certificate rpm for foreman-proxy

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

How reproducible:
100% 

Steps to Reproduce:
1. Execute capsule-certs-generate command for the fist time and extract the contents of the 
    # capsule-certs-generate --capsule-fqdn capsule.example.com --certs-tar /tmp/capsule.tar.gz
    # tar -xvzf /tmp/capsule.tar.gz
ssl-build/katello-default-ca-1.0-1.noarch.rpm
ssl-build/katello-server-ca-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-apache-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-apache-1.0-2.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-foreman-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-foreman-proxy-1.0-2.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-foreman-proxy-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-puppet-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-broker-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-client-cert-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-router-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-router-server-1.0-1.noarch.rpm

2. Re-run the capsule installer with the --certs-update-server option Which would only update the apache package, but not the foreman-proxy

    # capsule-certs-generate --capsule-fqdn capsule.example.com --certs-tar /tmp/capsule.tar.gz --certs-update-server
    # tar -xvzf capsule.tar.gz
ssl-build/katello-default-ca-1.0-1.noarch.rpm
ssl-build/katello-server-ca-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-apache-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-apache-1.0-3.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-foreman-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-foreman-proxy-1.0-2.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-foreman-proxy-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-puppet-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-broker-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-client-cert-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-router-client-1.0-1.noarch.rpm
ssl-build/capsule.example.com/capsule.example.com-qpid-router-server-1.0-1.noarch.rpm
  
  
Actual results:
foreman-proxy related RPMs gets updated correctly with the new CA, but fails to update the version that gets appended to the RPM causing the confusion.

Expected results:
RPMs should be appened with correct version

Additional info:
Problem seems to from the code of /bin/katello-ssl-tool
    #find RPMs in the directory as well.
    filenames = glob.glob("%s-*.noarch.rpm" % server_rpm)
    if filenames:
        filename = sortRPMs(filenames)[-1]
        h = get_package_header(filename)
        if hdr is None:
            hdr = h
        else:
            comp = hdrLabelCompare(h, hdr)
            if comp > 0:
                hdr = h

It grabs rpms like this "capsule.example.com-foreman-proxy-*.noarch.rpm" in that dir, sort it, and reckons the last one is the latest one.

But the satellite also has a rpm called "capsule.example.com-foreman-proxy-client-1.0-*.noarch.rpm" in the same directory!!

glob.glob("%s-*.noarch.rpm" % server_rpm) matches that perfectly as well. Since it always sits at the bottom of the sorted list:

(i.e.)
...
xxx-foreman-proxy-1.xxx
xxx-foreman-proxy-client-1.xxx

the release # the code fetched is always wrong.

As a result, the capsule.example.com-foreman-proxy rpm is generated with the right content, but wrong release number. 

Since we have a capsule.example.com-foreman-proxy-client-1.0-1.noarch.rpm in the same folder,  the generated capsule.example.com-foreman-proxy rpm will always be 1.0-2.

Comment 2 Neil Miao 2016-04-27 03:44:17 UTC
Any movement on this bug at all?

The issue still exist in v6.1.8 and v6.2 beta

katello-certs-tools-2.2.1-1.el7sat.noarch
katello-certs-tools-2.4.0-1.el7sat.noarch

/usr/lib/python2.7/site-packages/katello_certs_tools/katello_ssl_tool.py

 826     #find RPMs in the directory as well.
 827     filenames = glob.glob("%s-*.noarch.rpm" % server_rpm)
 828     if filenames:
 829         filename = sortRPMs(filenames)[-1]
 830         h = get_package_header(filename)
 831         if hdr is None:
 832             hdr = h
 833         else:
 834             comp = hdrLabelCompare(h, hdr)
 835             if comp > 0:
 836                 hdr = h

Comment 6 Stephen Benjamin 2016-08-01 14:00:13 UTC
Created redmine issue http://projects.theforeman.org/issues/15932 from this bug

Comment 9 Alexey Masolov 2017-02-03 06:19:03 UTC
The bug still exists in v.6.2.7/

Comment 10 hprakash 2017-05-31 06:05:12 UTC
results seems the same in v 6.2.9 as well

Comment 13 Ivan Necas 2017-08-01 10:54:25 UTC
The is difference between --certs-update-server and --certs-update-server-ca. 

The --certs-update-server updates only the SSL certificate of the server, while keeping the CA untouched. The --certs-update-server-ca is additional to update the CA of the server itself. The documentation mentions both commands.

https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html/installation_guide/installing_satellite_server#run_the_satellite_installer_with_custom_certificate_parameters

We could try to detect, if the ca cert provided by customer is different than that is already installed. The reason why we didn't go this way was preventing accidental update of the ca cert. On the other hand, there is probably low chance it would happen. We need to take a look at this in context of other bugs to see how it goes in terms of prioritization.

Comment 14 Mike McCune 2018-04-24 18:10:29 UTC
This bug can cause downstream effects that make debugging more difficult and add to the already complicated condition induced by Satellite's multiple certificates required for operations.

Comment 15 Bryan Kearney 2018-09-04 18:01:12 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.

Comment 16 Chris Roberts 2019-04-03 08:43:41 UTC
This needs to be fixed, reopening. This causes a lot of issues with failed capsule SSL deployments.

Comment 17 Bryan Kearney 2019-05-02 19:07:00 UTC
The Satellite Team is attempting to provide an accurate backlog of bugzilla requests which we feel will be resolved in the next few releases. We do not believe this bugzilla will meet that criteria, and have plans to close it out in 1 month. This is not a reflection on the validity of the request, but a reflection of the many priorities for the product. If you have any concerns about this, feel free to contact Red Hat Technical Support or your account team. If we do not hear from you, we will close this bug out. Thank you.

Comment 18 Bryan Kearney 2019-06-03 12:05:53 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this, please do not reopen. Instead, feel free to contact Red Hat Technical Support. Thank you.

Comment 19 Bryan Kearney 2019-07-02 18:02:09 UTC
The Satellite Team is attempting to provide an accurate backlog of bugzilla requests which we feel will be resolved in the next few releases. We do not believe this bugzilla will meet that criteria, and have plans to close it out in 1 month. This is not a reflection on the validity of the request, but a reflection of the many priorities for the product. If you have any concerns about this, feel free to contact Red Hat Technical Support or your account team. If we do not hear from you, we will close this bug out. Thank you.

Comment 20 Bryan Kearney 2019-08-01 18:35:39 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and while we recognize that it is a valid request, we do not expect this to be implemented in the product in the foreseeable future. This is due to other priorities for the product, and not a reflection on the request itself. We are therefore closing this out as WONTFIX. If you have any concerns about this, please do not reopen. Instead, feel free to contact Red Hat Technical Support. Thank you.

Comment 21 Chris Roberts 2020-04-16 22:39:07 UTC
This needs to be fixed, reopening. This causes a lot of issues with failed capsule SSL deployments.

Comment 23 Ewoud Kohl van Wijngaarden 2020-05-19 18:50:45 UTC
Moving it to certificates since this is actually in katello-certs-tools. In https://github.com/Katello/katello-certs-tools/pull/26 I've tried to come up with a reproducer.

Comment 24 Bryan Kearney 2020-05-29 20:03:50 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/15932 has been resolved.

Comment 25 Devendra Singh 2020-09-09 14:22:46 UTC
Verfied on 6.8 Snap14

Verification points:

1- updated katello-certs-tools version is available.
# rpm -q katello-certs-tools
katello-certs-tools-2.7.1-1.el7sat.noarch

2- Run capsule-certs-generate command first time.
# capsule-certs-generate --foreman-proxy-fqdn XYZ.com --certs-tar /tmp/XYZ.com.tar.gz

# tar -xvzf /tmp/XYZ.com.tar.gz 
ssl-build/katello-default-ca-1.0-1.noarch.rpm
ssl-build/katello-server-ca-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-apache-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-puppet-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-broker-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-client-cert-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-router-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-router-server-1.0-1.noarch.rpm

Run capsule-certs-generate command second time.
#capsule-certs-generate --foreman-proxy-fqdn XYZ.com --certs-tar /tmp/XYZ.com.tar.gz --certs-update-server

ssl-build/katello-default-ca-1.0-1.noarch.rpm
ssl-build/katello-server-ca-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-apache-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-apache-1.0-2.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-1.0-2.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-puppet-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-broker-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-client-cert-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-router-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-router-server-1.0-1.noarch.rpm

Run capsule-certs-generate command third time.
#capsule-certs-generate --foreman-proxy-fqdn XYZ.com --certs-tar /tmp/XYZ.com.tar.gz --certs-update-server

# tar -xvzf /tmp/XYZ.com.tar.gz 
ssl-build/katello-default-ca-1.0-1.noarch.rpm
ssl-build/katello-server-ca-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-apache-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-apache-1.0-2.noarch.rpm
ssl-build/XYZ.com/XYZ.com-apache-1.0-3.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-1.0-2.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-1.0-3.noarch.rpm
ssl-build/XYZ.com/XYZ.com-foreman-proxy-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-puppet-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-broker-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-client-cert-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-router-client-1.0-1.noarch.rpm
ssl-build/XYZ.com/XYZ.com-qpid-router-server-1.0-1.noarch.rpm

Each time the version of foreman-proxy and apache rpm gets incremented