Bug 1414793

Summary: numeric priority expected error seen for alternatives after chkconfig downgrade
Product: Red Hat Enterprise Linux 7 Reporter: Deepu K S <dkochuka>
Component: chkconfigAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.3CC: dkochuka, fkrska, lnykryn, pandrade, rhack
Target Milestone: rcKeywords: Reopened, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: chkconfig-1.7.3-1.el7 Doc Type: Bug Fix
Doc Text:
Cause: There was a feature in alternatives that changed the format of alternative state files. This change was not forward-compatible, which means that you can't use a state file modified with new alternatives with old alternatives binary. Consequence: This is a problem during the downgrade of alternatives. The new version changed the file and after downgrade the old version is not able to read them. Fix: During downgrade of new version we alter the state files to match the old format. Result: Working downgrade.
Story Points: ---
Clone Of:
: 1448444 (view as bug list) Environment:
Last Closed: 2017-08-01 19:35:25 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:
Bug Depends On:    
Bug Blocks: 1448444    

Description Deepu K S 2017-01-19 13:07:50 UTC
Description of problem:
After downgrading chkconfig to RHEL 7.2 version [chkconfig-1.3.61-5.el7.x86_64], alternatives commands fail with "numeric priority expected" error.

# alternatives --display java
numeric priority expected in /var/lib/alternatives/java
unexpected line in /var/lib/alternatives/java: @java-1.8.0-openjdk.x86_64@1800111

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 7.3
chkconfig-1.7.2-1.el7.x86_64

How reproducible:
Always.

Steps to Reproduce:
1. # yum update java-1.8.0-openjdk
2. # yum downgrade java-1.8.0-openjdk-1.8.0.102-1.b14.el7_2.x86_64 java-1.8.0-openjdk-devel-1.8.0.102-1.b14.el7_2.x86_64 java-1.8.0-openjdk-headless-1.8.0.102-1.b14.el7_2.x86_64 chkconfig-1.3.61-5.el7.x86_64 ntsysv-1.3.61-5.el7.x86_64
3. # alternatives --display java
numeric priority expected in /var/lib/alternatives/java
unexpected line in /var/lib/alternatives/java: @java-1.8.0-openjdk.x86_64@1800111


Actual results:
The /var/lib/alternatives/* files are not rolled back to the numeric priority values.

# alternatives --display java
numeric priority expected in /var/lib/alternatives/java
unexpected line in /var/lib/alternatives/java: @java-1.8.0-openjdk.x86_64@1800111

# alternatives --config java
numeric priority expected in /var/lib/alternatives/java
unexpected line in /var/lib/alternatives/java: @java-1.8.0-openjdk.x86_64@1800111


Expected results:
At downgrade, chkconfig should strip the the @family@ part from /var/lib/alternatives/* files.

Additional info:

Comment 1 Lukáš Nykrýn 2017-01-20 11:58:14 UTC
This is not something that should be done in chkconfig package. The java packages that use the --family option should have a dependency for new chkconfig and when you removed them this alternative should be removed.

Comment 3 Paulo Andrade 2017-02-01 14:05:41 UTC
  My first idea of how to fix it, only in the newer java package
would be to have a:

%triggerin -- chkconfig < 1.7

followed by a scriptlet to rerun all alternatives commands, but
not using the --family option (or a really ugly 's/@[^@]+@//'
in the alternatives file).

  Do you have a different suggestion? I mean, to be able to
downgrade in the same transaction java-1.8.0-openjdk and chkconfig.

Comment 4 Lukáš Nykrýn 2017-02-06 12:55:45 UTC
Ok so what we could do is to add this trigger in chkconfig spec file:

diff --git a/chkconfig.spec b/chkconfig.spec
index 4e08ff4..15eccca 100644
--- a/chkconfig.spec
+++ b/chkconfig.spec
@@ -79,6 +79,11 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/ntsysv
 %{_mandir}/*/ntsysv.8*
 
+%triggerin -- chkconfig < 1.7
+for i in  /var/lib/alternatives/* ; do
+    sed -i -e 's/^@.*@\([0-9]*\)$/\1/' $i
+done
+
 %changelog
 * Wed Jun 29 2016 Lukáš Nykrýn <lnykryn> - 1.7.2-1
 - alternatives: introduce --keep-missing

Comment 8 Lukáš Nykrýn 2017-03-03 13:28:36 UTC
Yep, devel_ack for the spec file change.

Comment 16 errata-xmlrpc 2017-08-01 19:35:25 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, 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/RHBA-2017:2164