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 2189281 - insights-client change log management to logrotate standard
Summary: insights-client change log management to logrotate standard
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: insights-client
Version: 9.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Jason Jerome
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On: 1940267
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-24 16:07 UTC by Alba Hita
Modified: 2023-11-07 09:49 UTC (History)
15 users (show)

Fixed In Version: insights-client-3.2.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1940267
Environment:
Last Closed: 2023-11-07 08:32:52 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-155565 0 None None None 2023-04-24 16:08:26 UTC
Red Hat Product Errata RHBA-2023:6432 0 None None None 2023-11-07 08:33:24 UTC

Comment 2 Archana Pandey 2023-06-08 14:36:51 UTC
pre-verification:


[root@iqe-insightsvm-arpandey-9 ~]# insights-client --version
Client: 3.2.0
Core: 3.0.8-dev
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]#
[root@iqe-insightsvm-arpandey-9 ~]# rpm -qa | grep insights-client
insights-client-3.2.0.git.424.5dfefcf7-0.el9.noarch
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 5168
-rw-r--r--. 1 root root  815439 Jun  8 10:10 insights-client.log
-rw-r--r--. 1 root root 3978824 Jun  8 07:01 insights-client.log.1
[root@iqe-insightsvm-arpandey-9 ~]# 

[root@iqe-insightsvm-arpandey-9 ~]# cat /etc/logrotate.d/insights-client 
/var/log/insights-client/*.log {
    rotate 4
    weekly
    missingok
    notifempty
    sharedscripts
    copytruncate
    create 0644 root root
}[root@iqe-insightsvm-arpandey-9 ~]#

[root@iqe-insightsvm-arpandey-9 ~]# insights-client 
Starting to collect Insights data for iqe-insightsvm-arpandey-9
Uploading Insights data.
Successfully uploaded report from iqe-insightsvm-arpandey-9 to account 6089719.
View details about this system on console.redhat.com:
https://console.redhat.com/insights/inventory/07e2e735-f7b4-45d3-b02f-f57104a433e3
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 5168
-rw-r--r--. 1 root root 1209457 Jun  8 10:11 insights-client.log
-rw-r--r--. 1 root root 3978824 Jun  8 07:01 insights-client.log.1       <<<< log file not rotated on every run of insights-client
[root@iqe-insightsvm-arpandey-9 ~]# insights-client 
Starting to collect Insights data for iqe-insightsvm-arpandey-9
Uploading Insights data.
Successfully uploaded report from iqe-insightsvm-arpandey-9 to account 6089719.
View details about this system on console.redhat.com:
https://console.redhat.com/insights/inventory/07e2e735-f7b4-45d3-b02f-f57104a433e3
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 6192
-rw-r--r--. 1 root root 1605973 Jun  8 10:11 insights-client.log
-rw-r--r--. 1 root root 3978824 Jun  8 07:01 insights-client.log.1      <<<<<<  log file not rotated on every run of insights-client
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# logrotate -vf /etc/logrotate.d/insights-client   << testing if logrotate feature rotates the log
reading config file /etc/logrotate.d/insights-client
Reading state from file: /var/lib/logrotate/logrotate.status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state

Handling 1 logs

rotating pattern: /var/log/insights-client/*.log  forced from command line (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/insights-client/insights-client.log
  Now: 2023-06-08 10:12
  Last rotated at 2023-06-08 07:01
  log needs rotating
rotating log /var/log/insights-client/insights-client.log, log->rotateCount is 4
dateext suffix '-20230608'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
set default create context to unconfined_u:object_r:insights_client_var_log_t:s0
renaming /var/log/insights-client/insights-client.log.4 to /var/log/insights-client/insights-client.log.5 (rotatecount 4, logstart 1, i 4), 
old log /var/log/insights-client/insights-client.log.4 does not exist
renaming /var/log/insights-client/insights-client.log.3 to /var/log/insights-client/insights-client.log.4 (rotatecount 4, logstart 1, i 3), 
old log /var/log/insights-client/insights-client.log.3 does not exist
renaming /var/log/insights-client/insights-client.log.2 to /var/log/insights-client/insights-client.log.3 (rotatecount 4, logstart 1, i 2), 
old log /var/log/insights-client/insights-client.log.2 does not exist
renaming /var/log/insights-client/insights-client.log.1 to /var/log/insights-client/insights-client.log.2 (rotatecount 4, logstart 1, i 1), 
renaming /var/log/insights-client/insights-client.log.0 to /var/log/insights-client/insights-client.log.1 (rotatecount 4, logstart 1, i 0), 
old log /var/log/insights-client/insights-client.log.0 does not exist
log /var/log/insights-client/insights-client.log.5 doesn't exist -- won't try to dispose of it
copying /var/log/insights-client/insights-client.log to /var/log/insights-client/insights-client.log.1
set default create context to unconfined_u:object_r:insights_client_var_log_t:s0
truncating /var/log/insights-client/insights-client.log
set default create context to unconfined_u:object_r:logrotate_var_lib_t:s0
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 5460
-rw-r--r--. 1 root root       0 Jun  8 10:12 insights-client.log
-rw-r--r--. 1 root root 1608678 Jun  8 10:12 insights-client.log.1
-rw-r--r--. 1 root root 3978824 Jun  8 07:01 insights-client.log.2    << log file rotated as expected
[root@iqe-insightsvm-arpandey-9 ~]# 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Test Case: Insights-client updated, old version of core

[root@iqe-insightsvm-arpandey-9 ~]# insights-client --version
Client: 3.2.0
Core: 3.1.26-1
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 448
-rw-r--r--. 1 root root 398475 Jun  8 10:19 insights-client.log
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# insights-client 
Starting to collect Insights data for iqe-insightsvm-arpandey-9
Uploading Insights data.
Successfully uploaded report from iqe-insightsvm-arpandey-9 to account 6089719.
View details about this system on console.redhat.com:
https://console.redhat.com/insights/inventory/07e2e735-f7b4-45d3-b02f-f57104a433e3
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 924
-rw-r--r--. 1 root root 944226 Jun  8 10:23 insights-client.log
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# logrotate -vf /etc/logrotate.d/insights-client    <<< forcing log rotate
reading config file /etc/logrotate.d/insights-client
Reading state from file: /var/lib/logrotate/logrotate.status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state

Handling 1 logs

rotating pattern: /var/log/insights-client/*.log  forced from command line (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/insights-client/insights-client.log
  Now: 2023-06-08 10:24
  Last rotated at 2023-06-08 10:12
  log needs rotating
rotating log /var/log/insights-client/insights-client.log, log->rotateCount is 4
dateext suffix '-20230608'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
set default create context to unconfined_u:object_r:insights_client_var_log_t:s0
renaming /var/log/insights-client/insights-client.log.4 to /var/log/insights-client/insights-client.log.5 (rotatecount 4, logstart 1, i 4), 
old log /var/log/insights-client/insights-client.log.4 does not exist
renaming /var/log/insights-client/insights-client.log.3 to /var/log/insights-client/insights-client.log.4 (rotatecount 4, logstart 1, i 3), 
old log /var/log/insights-client/insights-client.log.3 does not exist
renaming /var/log/insights-client/insights-client.log.2 to /var/log/insights-client/insights-client.log.3 (rotatecount 4, logstart 1, i 2), 
old log /var/log/insights-client/insights-client.log.2 does not exist
renaming /var/log/insights-client/insights-client.log.1 to /var/log/insights-client/insights-client.log.2 (rotatecount 4, logstart 1, i 1), 
old log /var/log/insights-client/insights-client.log.1 does not exist
renaming /var/log/insights-client/insights-client.log.0 to /var/log/insights-client/insights-client.log.1 (rotatecount 4, logstart 1, i 0), 
old log /var/log/insights-client/insights-client.log.0 does not exist
log /var/log/insights-client/insights-client.log.5 doesn't exist -- won't try to dispose of it
copying /var/log/insights-client/insights-client.log to /var/log/insights-client/insights-client.log.1
set default create context to unconfined_u:object_r:insights_client_var_log_t:s0
truncating /var/log/insights-client/insights-client.log
set default create context to unconfined_u:object_r:logrotate_var_lib_t:s0
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# 
[root@iqe-insightsvm-arpandey-9 ~]# ll /var/log/insights-client/
total 924
-rw-r--r--. 1 root root      0 Jun  8 10:24 insights-client.log
-rw-r--r--. 1 root root 944226 Jun  8 10:24 insights-client.log.1                <<<< log rotated successfully
[root@iqe-insightsvm-arpandey-9 ~]# 


verified that logrotate is being used because the insights client have logrotate implementation.
Setting verified tested.

Comment 5 Archana Pandey 2023-07-21 13:07:19 UTC
Final Verification on build insights-client-3.2.0-1.el9.noarch

Bug has been verified by running automated tests https://main-jenkins-csb-insights-qe.apps.ocp-c1.prod.psi.redhat.com/job/rhc_and_insights_clients/job/main_rhc_insights/9022/testReport/csbprodrhel93.tests/test_client/

some logs to support verification from jenkins console : 

+ rpm -qa
+ grep insights-client
insights-client-3.2.0-1.el9.noarch

tests/test_client.py::test_verify_logrotate_is_configured <- ../../../../../../iqe_venv/lib/python3.8/site-packages/iqe_insights_client/tests/test_client.py Content of log file is /var/log/insights-client/*.log {
    rotate 4
    weekly
    missingok
    notifempty
    copytruncate
}


-------------------------------- live log call ---------------------------------
2023-07-21 08:11:28 INFO Content of log file is /var/log/insights-client/*.log {
    rotate 4
    weekly
    missingok
    notifempty
    copytruncate
}

PASSED                                                                   [ 13%]
tests/test_client.py::test_verify_logrotate_when_forced_conf <- ../../../../../../iqe_venv/lib/python3.8/site-packages/iqe_insights_client/tests/test_client.py 
-------------------------------- live log call ---------------------------------
2023-07-21 08:11:28 INFO log file size before test is 258606
2023-07-21 08:11:28 INFO number of log files before test is : 1
2023-07-21 08:11:28 INFO Starting to collect Insights data for rhiqe.a3e02360-9e2b-42bd-b0e0-e6685e198015.iqe-insights-client-plugin
2023-07-21 08:11:57 INFO Uploading Insights data.
2023-07-21 08:12:05 INFO Successfully uploaded report for rhiqe.a3e02360-9e2b-42bd-b0e0-e6685e198015.iqe-insights-client-plugin.
2023-07-21 08:12:05 INFO View the Red Hat Insights console at https://console.redhat.com/insights/
PASSED

Based on automated test results - Verification: Passed

Comment 7 errata-xmlrpc 2023-11-07 08:32: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 (insights-client bug fix and enhancement update), 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-2023:6432


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