RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1687523 - when /var/log/rhsm/ is missing, subscription-manager outputs rhsm logs on terminal.
Summary: when /var/log/rhsm/ is missing, subscription-manager outputs rhsm logs on ter...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.1
Hardware: All
OS: All
low
high
Target Milestone: rc
: ---
Assignee: Jiri Hnidek
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-11 16:31 UTC by jcastran
Modified: 2021-08-30 13:41 UTC (History)
9 users (show)

Fixed In Version: subscription-manager-1.26.5-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 16:54:49 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 2156 0 'None' closed 1687523: Try to create /var/log/rhsm directory; ENT-1406 2021-02-18 21:44:54 UTC
Red Hat Knowledge Base (Solution) 3569241 0 Troubleshoot None RHSM logs are dumped on terminal after executing subscription-manager or yum commands 2019-03-11 16:31:01 UTC
Red Hat Product Errata RHBA-2020:1849 0 None None None 2020-04-28 16:55:08 UTC

Description jcastran 2019-03-11 16:31:01 UTC
This bug was initially created as a copy of Bug #1686920

I am copying this bug because: 
This also occurs in RHEL 8


Description of problem:
when /var/log/rhsm/ is missing, subscription-manager outputs rhsm logs on terminal.

Everytime yum is called, it calls the subscription-manager plugin and the output can be extremely excessive. This can even stop ansible which will fail when too much yum output is seen.

Version-Release number of selected component (if applicable):
subscription-manager-1.21.10-3.el7_6.x86_64

How reproducible:
Everytime

Steps to Reproduce:
1. mv /var/log/rhsm/ .
2. yum repolist

Actual results:
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
2019-01-23 07:26:48,781 [INFO] yum:23157:MainThread @connection.py:871 - Connection built: http_proxy=intsquid.imf.org:8080 host=subscription.rhn.redhat.com port=443 handler=/subscription auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=True
2019-01-23 07:26:48,802 [INFO] yum:23157:MainThread @connection.py:871 - Connection built: http_proxy=intsquid.imf.org:8080 host=subscription.rhn.redhat.com port=443 handler=/subscription auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=True
2019-01-23 07:26:49,092 [INFO] yum:23157:MainThread @connection.py:588 - Response: status=200, request="GET /subscription/"
''
repo id                           repo name                               status
rhel-7-server-rpms/7Server/x86_64 Red Hat Enterprise Linux 7 Server (RPMs 23382
repolist: 23382


Expected results:
repo id                           repo name                               status
rhel-7-server-rpms/7Server/x86_64 Red Hat Enterprise Linux 7 Server (RPMs 23382
repolist: 23382

AND /var/log/rhsm/ gets created so subscription-manager can log properly.

Additional info:
rpm -Va does show the directory as missing. reinstalling the subscription-manager package will resolve this issue. Depending on the entitlements this output can be extremely verbose and all caused by a missing directory that it should either create if needed, or log straight to /var/log/ instead of /var/log/rhsm/.

Comment 5 Chris Snyder 2019-03-22 15:17:16 UTC
To address this we have agreed on adding an extra log message to indicate that the standard log file (/var/log/rhsm/rhsm.log) could not be written to and that further log output will be to stdout/stderr.
This should help others in the future as a diagnostic step to determine the root cause of the strange log output.

I would also advise any folks seeing this issue to see the attached knowledge base solution: https://access.redhat.com/solutions/3569241

Comment 8 Jiri Hnidek 2019-09-05 08:11:58 UTC
I implemented it a little bit different than it was proposed. When /var/log/rhsm directory does not exist, then logutil module (subscription-manager, yum plugin, etc.) tries to create this directory. When it is not possible to create this directory (permission, fs us read-only, etc.), then extra error message is printed (including reason) and all other messages are printed to stderr.

Comment 12 Shwetha Kallesh 2020-02-05 08:50:22 UTC
Verification:

[root@kvm-04-guest02 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.9.21-1
subscription management rules: 5.37
subscription-manager: 1.26.10-1.el8


[root@kvm-04-guest02 ~]# mv /var/log/rhsm/rhsm.log /root
mv: overwrite '/root/rhsm.log'? y

[root@kvm-04-guest02 ~]# ls /var/log/rhsm/*
/var/log/rhsm/rhsmcertd.log


[root@kvm-04-guest02 ~]# yum repolist
Updating Subscription Management repositories.
repo id                                                                                                    repo name
beaker-AppStream                                                                                           beaker-AppStream
beaker-AppStream-debuginfo                                                                                 beaker-AppStream-debuginfo
beaker-BaseOS                                                                                              beaker-BaseOS
beaker-BaseOS-debuginfo                                                                                    beaker-BaseOS-debuginfo
beaker-CRB                                                                                                 beaker-CRB
beaker-CRB-debuginfo                                                                                       beaker-CRB-debuginfo
beaker-HighAvailability                                                                                    beaker-HighAvailability
beaker-HighAvailability-debuginfo                                                                          beaker-HighAvailability-debuginfo
beaker-NFV                                                                                                 beaker-NFV
beaker-NFV-debuginfo                                                                                       beaker-NFV-debuginfo
beaker-RT                                                                                                  beaker-RT
beaker-RT-debuginfo                                                                                        beaker-RT-debuginfo
beaker-ResilientStorage                                                                                    beaker-ResilientStorage
beaker-ResilientStorage-debuginfo                                                                          beaker-ResilientStorage-debuginfo
beaker-SAP                                                                                                 beaker-SAP
beaker-SAP-debuginfo                                                                                       beaker-SAP-debuginfo
beaker-SAPHANA                                                                                             beaker-SAPHANA
beaker-SAPHANA-debuginfo                                                                                   beaker-SAPHANA-debuginfo
beaker-harness                                                                                             beaker-harness
beaker-tasks                                                                                               beaker-tasks
rhel-8-for-x86_64-appstream-htb-rpms                                                                       Red Hat Enterprise Linux 8 for x86_64 - AppStream HTB (RPMs)
rhel-8-for-x86_64-baseos-htb-rpms                                                                          Red Hat Enterprise Linux 8 for x86_64 - BaseOS HTB (RPMs)

Now verify if the rhsm.log file is created:
[root@kvm-04-guest02 ~]# ls /var/log/rhsm/*
/var/log/rhsm/rhsmcertd.log  /var/log/rhsm/rhsm.log
^^ file is created
[root@kvm-04-guest02 ~]# cat /var/log/rhsm/rhsm.log 
2020-02-05 03:47:27,106 [INFO] yum:31990:MainThread @connection.py:905 - Connection built: host=subscription.rhsm.stage.redhat.com port=443 handler=/subscription auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False
^^ output is logged as well

Comment 14 errata-xmlrpc 2020-04-28 16:54:49 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-2020:1849

Comment 15 Ed Avis 2020-05-12 10:55:43 UTC
The new message gets printed every time dnf is run as a non-root user:

% dnf --quiet list autoremote
2020-05-12 11:52:09,965 [ERROR] dnf:683858:MainThread @logutil.py:194 - [Errno 13] Permission denied: '/var/log/rhsm/rhsm.log' - Further logging output will be written to stderr

I think it should only appear when run as root.  A non-root user wouldn't expect to write to /var/log anyway.

Comment 16 Mason Loring Bliss 2020-08-25 13:36:10 UTC
For perspective, changes made to package repositories ought to be logged,
and as such, any inability to log should be treated as an error. In this
case, we're seeing an inability to log treated as a warning. If anything,
for clarity and auditability, we might consider going the other way, and
moving from warning the user to a hard stop.

Comment 17 Ed Avis 2020-09-08 07:17:49 UTC
I entirely agree that changes made to package repositories ought to be logged.  This bug report only concerns the case where dnf is not run as root, and so cannot change anything.  In that case it can't write to the log files either.  But if run as non-root this is all entirely expected, and should not flag a warning.

Of course continue to warn (or even hard error) when dnf is run as root and plans to make a change to the repositories, but cannot log it.


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