Bug 1683835 - Upgrading from one katello-ca-consumer version to another breaks rhsm.conf
Summary: Upgrading from one katello-ca-consumer version to another breaks rhsm.conf
Keywords:
Status: CLOSED DUPLICATE of bug 1619533
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Installer
Version: 6.4
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: 6.8.0
Assignee: satellite6-bugs
QA Contact: Devendra Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-27 23:20 UTC by Gary Scarborough
Modified: 2020-02-18 15:08 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-28 13:35:42 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Gary Scarborough 2019-02-27 23:20:52 UTC
Description of problem:
The default rhsm.conf file points to redhat.com and has a prefix of /subscription.  Installing a katello-ca-consumer file changes that file to point to the satellite and have a prefix of /rhsm.  If you use rpm -Uvh to install a new katello-ca-consumer file such as changing your certs, the rhsm.conf file ends up pointing to redhat.com and having a subscription of /subscription.  

Removing the katello file and doing a straight install works as expected.  Only the upgrade seems to be broken.  

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

Sat 6.4 but probably an issue in 6.3 as well.

How reproducible:

Always

Steps to Reproduce:
1. INstall older katello-ca-consumer file on host.

2. Use rpm -Uvh to install a new one.

3. Examine rhsm.conf and see it point to redhat.com instead of satellite.

Actual results:

rhsm.conf file is corrupted.

Expected results:

rhsm.conf pointing to satellite with the correct prefix.


Additional info:

Comment 3 Vincent S. Cojot 2019-03-13 20:55:45 UTC
Looking at the src.rpm's SPEC file that Mathieu uploaded, I think the following section:
======================= CUT HERE =======================
%post
/bin/bash /usr/bin/katello-rhsm-consumer

%postun
test -f /etc/rhsm/rhsm.conf.kat-backup && command cp /etc/rhsm/rhsm.conf.kat-backup /etc/rhsm/rhsm.conf
======================= CUT HERE =======================

should be changed to something like this:
======================= CUT HERE =======================
%post
if [ "$1" = "1" ]; then
# this is an initial install, not an upgrade.
/bin/bash /usr/bin/katello-rhsm-consumer
fi

%postun
if [ $1 -eq 0 ]; then
# this is an uninstall, not an upgrade.
test -f /etc/rhsm/rhsm.conf.kat-backup && command cp /etc/rhsm/rhsm.conf.kat-backup /etc/rhsm/rhsm.conf
fi
======================= CUT HERE =======================

Comment 4 Vincent S. Cojot 2019-03-13 20:57:40 UTC
I did rebuild both rpms and made two versions with the SPEC file changes.

[root@rh7x64 noarch]# rpm -ivh katello-ca-consumer-w0575.example.com-1.0-170.noarch.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:katello-ca-consumer-w0575stipsnms################################# [100%]
[root@rh7x64 noarch]# grep prefix /etc/rhsm/rhsm.conf
# Server prefix:
prefix = /rhsm

[root@rh7x64 noarch]# rpm -Uvh katello-ca-consumer-w0575.example.com-1.0-180.noarch.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:katello-ca-consumer-w0575stipsnms################################# [ 50%]
Cleaning up / removing...
   2:katello-ca-consumer-w0575stipsnms################################# [100%]

[root@rh7x64 noarch]# grep prefix /etc/rhsm/rhsm.conf
# Server prefix:
prefix = /rhsm

Comment 5 Vincent S. Cojot 2019-03-14 13:56:58 UTC
Btw, i am not even sure the %post should be skipped in the case of an upgrade.
The %postun makes sense but if the satellite script called in %post (/usr/bin/katello-rhsm-consumer) truly is idempotent then perhaps it shouldn't be skipped when in an upgrade.
I've not read /usr/bin/katello-rhsm-consumer so I cannot tell if it will be future-proof and sufficient to skip it (what happens if Satellite gets upgraded from 6.4 to 6.5, does that script need to be re-evaluated?)


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