Bug 1300211 - capsule-certs-generate failed to increment release number when generating certificate rpm for foreman-proxy
capsule-certs-generate failed to increment release number when generating cer...
Status: NEW
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Installer (Show other bugs)
6.1.4
All Linux
medium Severity medium (vote)
: Unspecified
: --
Assigned To: satellite6-bugs
Katello QA List
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-20 04:30 EST by Nagoor Shaik
Modified: 2017-08-12 01:48 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 15932 None None None 2016-08-01 10:00 EDT

  None (edit)
Description Nagoor Shaik 2016-01-20 04:30:59 EST
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-26 23:44:17 EDT
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 10:00:13 EDT
Created redmine issue http://projects.theforeman.org/issues/15932 from this bug
Comment 9 Alexey Masolov 2017-02-03 01:19:03 EST
The bug still exists in v.6.2.7/
Comment 10 hprakash 2017-05-31 02:05:12 EDT
results seems the same in v 6.2.9 as well
Comment 13 Ivan Necas 2017-08-01 06:54:25 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.