View Issue Details

IDProjectCategoryView StatusLast Update
0017760CentOS-7subscription-managerpublic2020-10-01 16:37
Reporterjberanek 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version7.8-2003 
Target VersionFixed in Version 
Summary0017760: Error thrown in /etc/cron.daily/rhsmd (regression)
DescriptionSo, with subscription-manager-1.24.26-4.el7 when /etc/cron.daily/rhsmd runs, the following error is thrown:

/etc/cron.daily/rhsmd:

sleep: missing operand
Try 'sleep --help' for more information.
/etc/cron.daily/rhsmd: line 19: 238512 Terminated /usr/libexec/rhsmd -s

This was fixed in subscription-manager-1.24.26-3.1.el7 but appears to have regressed in subscription-manager-1.24.26-4.el7. It is caused by this syntax in the cron file:

config=$(grep -E "^processTimeout" /etc/rhsm/rhsm.conf | grep -Po "[0-9]+")
if [ -n $config ]; then
  rhsmd_timeout=$config
else
  rhsmd_timeout=300
fi

in 1.24.26-3.1.el7 this became:

config=$(grep -iE "^processTimeout" /etc/rhsm/rhsm.conf | grep -Po "[0-9]+")
if [ -n "$config" ]; then
  rhsmd_timeout=$config
else
  rhsmd_timeout=300
fi
Steps To ReproduceInstall subscription-manager-1.24.26-4.el7
Run /etc/cron.daily/rhsmd as root, when there is no "processTimeout" line in /etc/rhsmd.conf
TagsNo tags attached.
abrt_hash
URL

Activities

ManuelWolfshant

ManuelWolfshant

2020-09-29 11:20

manager   ~0037747

leaving aside that as far as I know subscription manager is useless in centos ( where the concept of entitlement does not exist ) , I cannot reproduce your problem.
1) stock install, no changes whatsoever
[wolfy@wolfy tmp]$ sudo sh -x /etc/cron.daily/rhsmd
++ grep -E '^processTimeout' /etc/rhsm/rhsm.conf
++ grep -Po '[0-9]+'
+ config=300
+ '[' -n 300 ']'
+ rhsmd_timeout=300
+ sleep 300
+ /usr/libexec/rhsmd -s
^C
[wolfy@wolfy tmp]$ file /etc/rhsmd.conf
/etc/rhsmd.conf: cannot open (No such file or directory)

2) same, after creating an empty /etc/rhsmd.conf ( thus not containing any "processTimeout" line in /etc/rhsmd.conf )
[wolfy@wolfy tmp]$ sudo touch /etc/rhsmd.conf
[wolfy@wolfy tmp]$ sudo sh -x /etc/cron.daily/rhsmd
++ grep -E '^processTimeout' /etc/rhsm/rhsm.conf
++ grep -Po '[0-9]+'
+ config=300
+ '[' -n 300 ']'
+ rhsmd_timeout=300
+ sleep 300
+ /usr/libexec/rhsmd -s

As a sidenote, "-i" in grep would make it ignore casing in the processTimeout line, thus allowing it to match a more liberal spelling of the keyword. Worst case scenario ( i.e. no match ) the "else" branch following the grep should still be triggered. However in your case the "if" branch is followed so the problem is in the value following the "processTimeout" keyword. My bet is that you do have a processTimeout line, the value from that line is evaluated to a non-empty string but still there are no digits provided as argument.
jberanek

jberanek

2020-09-29 11:27

reporter   ~0037748

But the upstream version has the fixed quoting on the 'if' line, whereas the CentOS version does not.

Upstream, fully patched:
config=$(grep -iE "^processTimeout" /etc/rhsm/rhsm.conf | grep -Po "[0-9]+")
if [ -n "$config" ]; then

CentOS, fully patched:
config=$(grep -E "^processTimeout" /etc/rhsm/rhsm.conf | grep -Po "[0-9]+")
if [ -n $config ]; then

When /etc/rhsm/rhsm.conf contains no processtimeout or processTimeout line the cron ends following the if like:

if -n [ ]; then
  rhsmd_timeout=
fi

and then running:

sleep

which gives the error:

sleep: missing operand
Try 'sleep --help' for more information.

Instead it should have followed the 'else' and ended up doing:

rhsmd_timeout=300
jberanek

jberanek

2020-09-29 11:30

reporter   ~0037749

Apologies for the red herring in my "Steps to reproduce", the correct config file is /etc/rhsm/rhsm.conf.

By the way, subscription-manager is very useful for CentOS systems, if Katello is being used, as in our case.
jberanek

jberanek

2020-09-29 11:31

reporter   ~0037750

The end outcome if this if 100 CentOS 7 systems are patched to this version of subscription-manager is 100 cron emails a day.
ManuelWolfshant

ManuelWolfshant

2020-09-29 13:17

manager   ~0037751

I did some more testing and the real culprit is that in the absence of a timeout line, the else branch is never followed, independent of the presence of "-i" as argument for grep.

Since CentOS is a rebuild of the sources used to create RHEL and aims to reproduce RHEL bug for bug and feature for feature, please submit your request to Redhat via bugzilla.redhat.com and if/when RH accepts it and incorporates it into RHEL and releases a patched version, then CentOS will pick it up automatically.
For easier tracking, please crosslink this bug with the one opened at bugzilla.redhat.com.
jberanek

jberanek

2020-09-29 13:20

reporter   ~0037752

Except the upstream version is incorrect, and CentOS's version is using the wrong sources. I've diagnosed this previously for this package, but not fully this time. I expect the source tarball to be a different version from upstream.
jberanek

jberanek

2020-09-29 13:20

reporter   ~0037753

The upstream version is **correct**.
jberanek

jberanek

2020-09-29 13:32

reporter   ~0037754

Enough evidence?

/tmp/subscription-manager/centos $ rpm2cpio ../subscription-manager-1.24.26-4.el7.centos.src.rpm|cpio -i
6615 blocks

/tmp/subscription-manager/rhel $ rpm2cpio ../subscription-manager-1.24.26-4.el7_8.src.rpm| cpio -i
6615 blocks

/tmp/subscription-manager $ ls -l rhel centos
centos:
total 3.3M
-rw-rw-r--. 1 _johnbadm domain users 622 Sep 29 14:28 subscription-manager-1.24.13-centos-remove-redhat.repo.patch
-rw-rw-r--. 1 _johnbadm domain users 2.1M Sep 29 14:28 subscription-manager-1.24.26.tar.gz
-rw-rw-r--. 1 _johnbadm domain users 905K Sep 29 14:28 subscription-manager-cockpit-1.24.26.tar.gz
-rw-rw-r--. 1 _johnbadm domain users 268K Sep 29 14:28 subscription-manager.spec

rhel:
total 3.3M
-rw-rw-r--. 1 _johnbadm domain users 2.1M Sep 29 14:29 subscription-manager-1.24.26.tar.gz
-rw-rw-r--. 1 _johnbadm domain users 905K Sep 29 14:29 subscription-manager-cockpit-1.24.26.tar.gz
-rw-r--r--. 1 _johnbadm domain users 268K Sep 29 14:29 subscription-manager.spec

/tmp/subscription-manager $ sha1sum rhel/subscription-manager-1.24.26.tar.gz centos/subscription-manager-1.24.26.tar.gz
399e129a63dfb1096ce96666070b1442aed9dc1b rhel/subscription-manager-1.24.26.tar.gz
89e5fa47d8ce6ddb9ea9cb54be8322c935249847 centos/subscription-manager-1.24.26.tar.gz
jberanek

jberanek

2020-09-29 13:37

reporter   ~0037755

Using -m on the cpio could help, showing upstream's tarball being newer:

$ ls -l centos rhel
centos:
total 3.3M
-rw-rw-r--. 1 _johnbadm domain users 622 Aug 6 17:50 subscription-manager-1.24.13-centos-remove-redhat.repo.patch
-rw-rw-r--. 1 _johnbadm domain users 2.1M Apr 2 01:37 subscription-manager-1.24.26.tar.gz
-rw-rw-r--. 1 _johnbadm domain users 905K Apr 2 01:37 subscription-manager-cockpit-1.24.26.tar.gz
-rw-rw-r--. 1 _johnbadm domain users 268K Aug 6 17:50 subscription-manager.spec

rhel:
total 3.3M
-rw-rw-r--. 1 _johnbadm domain users 2.1M Jul 9 16:43 subscription-manager-1.24.26.tar.gz
-rw-rw-r--. 1 _johnbadm domain users 905K Jul 9 17:18 subscription-manager-cockpit-1.24.26.tar.gz
-rw-r--r--. 1 _johnbadm domain users 268K Jul 9 17:19 subscription-manager.spec
ManuelWolfshant

ManuelWolfshant

2020-10-01 11:30

manager   ~0037767

Last edited: 2020-10-01 11:30

View 2 revisions

the differences in the tar files are due to the debranding done by CentOS
please retest with subscription-manager-1.24.42 which will be released in the following days.

jberanek

jberanek

2020-10-01 16:31

reporter   ~0037769

Except the debranding of subscription-manager-1.24.26-4.el7.centos has ended up in a reversion of the bug fix which was applied in subscription-manager-1.24.26-3.el7.centos but is also fixed in the upstream subscription-manager-1.24.26-4.el7_8.

Sure the CentOS 7.9 subscription-manager-1.24.42 may also have the fix, but it doesn't mean this regression didn't happen!
jberanek

jberanek

2020-10-01 16:37

reporter   ~0037770

Unpacking each SRPMs tarballs:

/tmp/subscription-manager $ grep "if " centos/subscription-manager-1.24.26/etc-conf/rhsmd.cron
if [ -n $config ]; then
if [ -n "$ps_check" ]; then

/tmp/subscription-manager $ grep "if " rhel/subscription-manager-1.24.26/etc-conf/rhsmd.cron
if [ -n "$config" ]; then
if [ -n "$ps_check" ]; then

Issue History

Date Modified Username Field Change
2020-09-29 09:15 jberanek New Issue
2020-09-29 11:20 ManuelWolfshant Note Added: 0037747
2020-09-29 11:27 jberanek Note Added: 0037748
2020-09-29 11:30 jberanek Note Added: 0037749
2020-09-29 11:31 jberanek Note Added: 0037750
2020-09-29 13:17 ManuelWolfshant Note Added: 0037751
2020-09-29 13:20 jberanek Note Added: 0037752
2020-09-29 13:20 jberanek Note Added: 0037753
2020-09-29 13:32 jberanek Note Added: 0037754
2020-09-29 13:37 jberanek Note Added: 0037755
2020-10-01 11:30 ManuelWolfshant Note Added: 0037767
2020-10-01 11:30 ManuelWolfshant Note Edited: 0037767 View Revisions
2020-10-01 16:31 jberanek Note Added: 0037769
2020-10-01 16:37 jberanek Note Added: 0037770