Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 953345

Summary: [PATCH] post scriptlet in RHUI client config rpms should not warn even if /etc/yum/pluginconf.d/rhnplugin.conf does not exists (as yum-rhn-plugin is not installed)
Product: Red Hat Update Infrastructure for Cloud Providers Reporter: Satoru SATOH <ssato>
Component: ToolsAssignee: James Slagle <jslagle>
Status: CLOSED ERRATA QA Contact: Radek Bíba <rbiba>
Severity: low Docs Contact:
Priority: unspecified    
Version: 2.1.1CC: bizhang, bkearney, cduryee, igulina, pcreech, tsanders, whayutin
Target Milestone: ---   
Target Release: 3.0.0   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-01 22:07:52 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:
Attachments:
Description Flags
The console log during installation of RHUI client config RPM none

Description Satoru SATOH 2013-04-18 01:46:06 UTC
Description of problem:

The post scriptlet in RHUI client config rpms will fail if 
/etc/yum/pluginconf.d/rhnplugin.conf does not exist
as yum-rhn-plugin is not installed, and warning will be printed
during installation of the client config rpms such like:

  sed: can't read /etc/yum/pluginconf.d/rhnplugin.conf: No such file or directory

  (I'll attach more detailed log in this bz also.)

But, RHUI clients should only use RHUI (CDS) repos in most cases
and it's not strange that yum-rhn-plugin is not installed because
it never be used in such systems, I think.


Version-Release number of selected component (if applicable):
I confirmed this issue in client config rpms built w/
rh-rhui-tools-2.1.17-1.el6_3.noarch.


How reproducible: This should happen always in any
RHEL systems in which yum-rhn-plugin is not installed.


Steps to Reproduce:
1. Build client config rpms
2. Install it into the systems in which yum-rhn-plugin is not installed
  

Actual results: The warning message will be printed.


Expected results: No warnings.


Additional info:

It's not difficult to fix this problem; the change to 
/etc/rhui/templates/rh-client-config.spec in rh-rhui-tools like
the following should be sufficient, I guess:

[root@rhua ~]# diff -u /etc/rhui/templates/rh-client-config.spec.save /etc/rhui/templates/rh-client-config.spec 
--- /etc/rhui/templates/rh-client-config.spec.save      2013-04-18 10:32:13.323003015 +0900
+++ /etc/rhui/templates/rh-client-config.spec   2013-04-18 10:34:10.238003008 +0900
@@ -55,8 +55,8 @@
 
 %post
 # Disable RHN plugin
-sed -e 's/^enabled.*/enabled = 0/g' /etc/yum/pluginconf.d/rhnplugin.conf > /tmp/rhnplugin.conf
-mv /tmp/rhnplugin.conf /etc/yum/pluginconf.d/
+f=/etc/yum/pluginconf.d/rhnplugin.conf
+test -f $f && sed -i.rhuisave -e 's/^enabled.*/enabled = 0/g' $f || :
 
 
 %clean
[root@rhua ~]#

Comment 1 Satoru SATOH 2013-04-18 01:49:47 UTC
Created attachment 737104 [details]
The console log during installation of RHUI client config RPM

This is the console log of RHEL 6.4 x86_64 guest during installation of
RHUI client config RPM named rhel-6-config built w/ 
rh-rhui-tools-2.1.17-1.el6_3.noarch.

yum-rhn-plugin is not installed in this guest.

Comment 2 Satoru SATOH 2013-04-18 12:31:37 UTC
Sorry that I didn't think cases of rhui client config updates carefully.
This should be better than previous one:

[root@rhua ~]# diff -u /etc/rhui/templates/rh-client-config.spec.save  /etc/rhui/templates/rh-client-config.spec
--- /etc/rhui/templates/rh-client-config.spec.save      2013-04-18 10:32:13.323003015 +0900
+++ /etc/rhui/templates/rh-client-config.spec   2013-04-18 21:24:35.201003004 +0900
@@ -54,9 +54,11 @@
 
 
 %post
-# Disable RHN plugin
-sed -e 's/^enabled.*/enabled = 0/g' /etc/yum/pluginconf.d/rhnplugin.conf > /tmp/rhnplugin.conf
-mv /tmp/rhnplugin.conf /etc/yum/pluginconf.d/
+if [ $1 = 1 ]; then   # 1: install (http://fedoraproject.org/wiki/Packaging:ScriptletSnippets)
+    # Disable RHN plugin if yum-rhn-plugin is installed:
+    f=/etc/yum/pluginconf.d/rhnplugin.conf
+    test -f $f && sed -i.rhuisave -e 's/^enabled.*/enabled = 0/g' $f || :
+fi
 
 
 %clean
[root@rhua ~]#

Comment 5 Irina Gulina 2016-08-04 12:24:45 UTC
Currently, I can't check if it's applicable to RHUI3 because of BZ1308349

Comment 6 Patrick Creech 2016-11-15 14:34:36 UTC
It appears code exists now in the specfile template to handle this case.

Comment 7 Radek Bíba 2016-11-16 15:13:26 UTC
This must have been fixed a long time ago, and even in RHUI 2. Anyway, here's how the scriptlet looks now:

%post
if [ "$1" = "1" ]; then  # 'install', not 'upgrade'
  # Disable RHN plugin
  if [ -f /etc/yum/pluginconf.d/rhnplugin.conf ]; then
   grep -iP "enabled = (0|false|off)"  /etc/yum/pluginconf.d/rhnplugin.conf  || sed -i.save -e 's/^enabled.*/enabled = 0/g' /etc/yum/pluginconf.d/rhnplugin.conf || :
  fi
fi

So, as one can expect, the actual tweaking of 'enabled' is only performed if the rhnplugin.conf file exists. In practice:

# yum remove yum-rhn-plugin-2.0.1-6.el7.noarch
...
Complete!
# ls /etc/yum/pluginconf.d/rhnplugin.conf
ls: cannot access /etc/yum/pluginconf.d/rhnplugin.conf: No such file or directory
# rpm -ivh /tmp/rhui-7-1.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:rhui-7-1                         ################################# [100%]
#

The tweaking is performed if the file exists and the plugin is enabled:

# ls /etc/yum/pluginconf.d/rhnplugin.conf
/etc/yum/pluginconf.d/rhnplugin.conf
# grep ^enabled /etc/yum/pluginconf.d/rhnplugin.conf
enabled = 1
# rpm -ihv /tmp/rhui-7-1.noarch.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:rhui-7-1                         ################################# [100%]
# grep ^enabled /etc/yum/pluginconf.d/rhnplugin.conf
enabled = 0
# diff /etc/yum/pluginconf.d/rhnplugin.conf{.save,}
2c2
< enabled = 1
---
> enabled = 0

If the plugin is disabled to begin with, 'enabled = 0' is printed after the config RPM is installed, but that's another bug (already filed).

Comment 9 errata-xmlrpc 2017-03-01 22:07:52 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:0367