Bug 1223860 - subscription-manager config --rhsmcertd.autoattachinterval adds configuration with incorrect case.
Summary: subscription-manager config --rhsmcertd.autoattachinterval adds configuration...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: subscription-manager
Version: 6.6
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: William Poteat
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-21 14:46 UTC by Dylan Gross
Modified: 2019-07-11 09:13 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
When configuration options in camelCase are removed from the /etc/rhsm/rhsm.conf file and then restored with the "subscription-manager config" command, they are restored in lowercase. For example, the "subscription-manager config --rhsmcertd.autoattachinterval" command fails to restore the "autoAttachInterval" option in camelCase and, as a consequence, the entry is ignored by the rhsmcertd daemon. However, an existing value can be successfully changed by using such a command. With this update, the "subscription-manager config --remove" command no longer deletes the option from the configuration file but restores its default value instead. As a result, the described problem occurs only when configuration options are manually deleted from /etc/rhsm/rhsm.conf and not reset with the "--remove" option, which is recommended.
Clone Of:
Environment:
Last Closed: 2015-07-22 06:54:15 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1345 normal SHIPPED_LIVE subscription-manager and python-rhsm bug fix and enhancement update 2015-07-20 17:59:53 UTC
Red Hat Knowledge Base (Solution) 1456593 None None None Never

Description Dylan Gross 2015-05-21 14:46:02 UTC
Description of problem:

If autoAttachInterval is absent from /etc/rhsm/rhsm.conf, The following command adds a configuration parameter to the /etc/rhsm/rhsm.conf that is ignored by the daemon, presumably due to the case of the argument.

  # subscription-manager config --rhsmcertd.autoattachinterval=<n>   


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

    subscription-manager-1.12.14-7.el6.x86_64

How reproducible:  Always.


Steps to Reproduce:

1.   First Verify the correct behaviour: observe the default interval in a setup where /etc/rhsm/rhsm.conf already contains an autoAttachInterval=1440 parameter

    # grep -i autoAttachInterval /etc/rhsm/rhsm.conf 
    autoAttachInterval = 1440

  Change the argument using the man-page-documented config option (using absurd values here for reproduction).  
 
   # subscription-manager config --rhsmcertd.autoattachinterval=2

 Parameter has changed....
 
   # grep -i autoAttachInterval /etc/rhsm/rhsm.conf 
   autoAttachInterval = 2

 And the service obeys...

  # service rhsmcertd restart ; tail -10 /var/log/rhsm/rhsmcertd.log | grep "Auto-attach interval"
   Stopping rhsmcertd...                                      [  OK  ]
   Starting rhsmcertd...                                      [  OK  ]

   Thu May 21 14:33:12 2015 [INFO] Auto-attach interval: 2.0 minute(s) [120 second(s)]

   

2.  Now ..  Remove or comment any explicit "autoAttachInterval" settings in /etc/rhsm/rhsm.conf

    # grep -i autoAttachInterval /etc/rhsm/rhsm.conf 
    # 

   ... observe that the rhsmcertd service is using the built in 1440 default

   # service rhsmcertd restart ; tail -10 /var/log/rhsm/rhsmcertd.log | grep "Auto-attach interval"
   Stopping rhsmcertd...                                      [  OK  ]
   Starting rhsmcertd...                                      [  OK  ]

   Thu May 21 14:35:24 2015 [INFO] Auto-attach interval: 1440.0 minute(s) [86400 second(s)]


3.   Add the configuration using the subscription-manager config command

  # subscription-manager config --rhsmcertd.autoattachinterval=2

  ...  Notice that the case is not as it was before:  autoattachinterval versus autoAttachInterval

  # grep -i autoAttachInterval /etc/rhsm/rhsm.conf 
   autoattachinterval = 2

  ... See the service ignore the new setting and continue using the default 

  # service rhsmcertd restart ; tail -10 /var/log/rhsm/rhsmcertd.log | grep     "Auto-attach interval"

    Stopping rhsmcertd...                                      [  OK  ]
    Starting rhsmcertd...                                      [  OK  ]

    Thu May 21 14:38:23 2015 [INFO] Auto-attach interval: 1440.0 minute(s) [86400 second(s)]


Actual results:

   Expect the "subscription-manager config --rhsmcertd.autoattachinterval=<n>" to add the parameter to the /etc/rhsm/rhsm.conf file with the case matching:  autoAttachInterval

Expected results:

  The command adds the parameter to the case with all lower-case as autoattachinterval.

Additional info:


   The help command has the command as all lower case:

   # subscription-manager config --help | grep -i autoattach
  --rhsmcertd.autoattachinterval=RHSMCERTD.AUTOATTACHINTERVAL
                        Section: rhsmcertd, Name: autoattachinterval

  And attempts to specify it with a different case fail because it is unrecognized....

  # subscription-manager config --rhsmcertd.autoAttachInterval=2
  Usage: subscription-manager config [OPTIONS]

  subscription-manager: error: no such option: --rhsmcertd.autoAttachInterval


I have not discovered why the autoAttachInterval would be absent yet, as this is only reported to be a small percentage of the customer's server population.   

I suspect the fix would be just for the config tool to add the parameter with the correct case, as opposed to making the rhsmcertd case-agnostic, but others may certainly know better.

Comment 1 Dylan Gross 2015-05-21 14:54:43 UTC
One more note:   if the /etc/rhsm/rhsm.conf file already contains the correct formatted argument, the config command will update it appropriately.

    # grep -i autoAttachInterval /etc/rhsm/rhsm.conf 
    autoAttachInterval = 1440

    # subscription-manager config --rhsmcertd.autoattachinterval=2

    # grep -i autoAttachInterval /etc/rhsm/rhsm.conf 
    autoAttachInterval = 2

Comment 3 Dylan Gross 2015-05-21 15:35:53 UTC
This behaviour is also present on 
    RHEL 7.1  with subscription-manager-1.13.22-1.el7
    RHEL 5.11 with subscription-manager-1.11.3-14.el5_11

Comment 4 William Poteat 2015-05-21 15:48:52 UTC
  # subscription-manager config --help | grep -i autoattach
  --rhsmcertd.autoattachinterval=RHSMCERTD.AUTOATTACHINTERVAL
                        Section: rhsmcertd, Name: autoattachinterval

  And attempts to specify it with a different case fail because it is unrecognized....

  # subscription-manager config --rhsmcertd.autoAttachInterval=2
  Usage: subscription-manager config [OPTIONS]

  subscription-manager: error: no such option: --rhsmcertd.autoAttachInterval


As shown, the casing for the config flag is all lower. You did not use that. The rhsm.conf file is in camel case, but the config tool help shows the casing to use here.

Comment 5 Dylan Gross 2015-05-21 17:38:51 UTC
Re: Comment #4

I apologize if my initial comment was confusing or unclear.   

The example of the CLI attempt using CamelCase was mostly just an example to  illustrate that it was not a problem with the "subscription-manager config --help" documentation.

The problem is just with the resulting config when the valid case is used on the CLI, but it puts the incorrect case in the config file.

Comment 6 William Poteat 2015-05-21 18:38:18 UTC
Please disregard Comment 1

The issue in general is that the config --remove command takes the entry out of the config file. The entry cannot be replaced in the original casing because the .ini parser will only deal in lowercase.

If the entry has been previously removed, it must be manually inserted into the file. Going forward with the code change associated, the entry will not be removed when the --remove command is called. The entry will be set to the default in the file.

Comment 8 John Sefler 2015-05-26 21:42:02 UTC
Before verifying, I just want to make it clear that using the "subscription-manager config --remove=SECTION.NAME" function was causing trouble when trying to restore the configuration for the camelCased config parameters...
   productCertDir
   entitlementCertDir
   consumerCertDir
   pluginDir
   pluginConfDir
   certCheckInterval
   autoAttachInterval

As stated in comment 6, the problem was that once the camelCased configurations are removed and then restored, they are restored in lowercase which caused problems because the C-based rhsmcertd tools are looking for the camelCase configurations.  If not found, then a default value is used.

The patch that Will implemented in comment 6 was to write the default configurations to /etc/rhsm/rhsm.conf rather than an absolute delete when the remove option is specified.

Beware that if you manually edit /etc/rhsm/rhsm.conf to remove a camelCased configuration, you will resurrect the situation reported in comment 1.  Therefore, do not manually remove configurations from /etc/rhsm/rhsm.conf.  Only use the "subscription-manager config --remove=SECTION.NAME" function.




Verifying Version....
[root@jsefler-os6 RHEL-6]# rpm -q subscription-manager
subscription-manager-1.14.8-1.el6.x86_64

STARTING CONFIG
[root@jsefler-os6 RHEL-6]# subscription-manager config | grep -B1 -i autoAttachInterval
[rhsmcertd]
   autoattachinterval = [1440]
[root@jsefler-os6 RHEL-6]# grep autoAttachInterval /etc/rhsm/rhsm.conf
autoAttachInterval = 1440

SETTING A DIFFERENT CONFIG
[root@jsefler-os6 RHEL-6]# subscription-manager config --rhsmcertd.autoattachinterval=100
[root@jsefler-os6 RHEL-6]# subscription-manager config | grep -B1 -i autoAttachInterval
[rhsmcertd]
   autoattachinterval = 100
[root@jsefler-os6 RHEL-6]# grep autoAttachInterval /etc/rhsm/rhsm.conf
autoAttachInterval = 100

REMOVING THE CONFIG (RESTORES THE DEFAULT)
[root@jsefler-os6 RHEL-6]# subscription-manager config --remove=rhsmcertd.autoattachinterval
You have removed the value for section rhsmcertd and name autoattachinterval.
The default value for autoattachinterval will now be used.
[root@jsefler-os6 RHEL-6]# subscription-manager config | grep -B1 -i autoAttachInterval
[rhsmcertd]
   autoattachinterval = [1440]
[root@jsefler-os6 RHEL-6]# grep autoAttachInterval /etc/rhsm/rhsm.conf
autoAttachInterval = 1440


Remember, DO NOT MANUALLY EDIT /etc/rhsm/rhsm.conf to remove parameters.

Comment 9 errata-xmlrpc 2015-07-22 06:54:15 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://rhn.redhat.com/errata/RHBA-2015-1345.html


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