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 1923835 - [insights-client] check is ran twice daily producing two logs for the same day
Summary: [insights-client] check is ran twice daily producing two logs for the same day
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: insights-client
Version: 8.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: 8.3
Assignee: Štěpán Tomsa
QA Contact: Pavol Kotvan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-02-02 03:23 UTC by Bryan Kinney
Modified: 2024-06-14 00:07 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-17 13:38:10 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 ESSNTL-467 0 None None None 2021-10-11 16:42:17 UTC
Red Hat Knowledge Base (Solution) 5844811 0 None None None 2022-03-15 10:42:05 UTC

Description Bryan Kinney 2021-02-02 03:23:31 UTC
Description of problem:
With the default insights-client.conf settings:
   #auto_config=True
   #base_url=cert-api.access.redhat.com:443/r/insights

The insights-client is ran twice daily within minutes of each other.

This produces two logs for the same day.
This means that only 2 days of logs are available instead of four.
The insights-client wasn't ran manually.

My tests ran on GSS lab RHEV 7.9.

Note: These bugzilla cases may be related.
  Bug 1708683 - base_url can be specified to configure manually.
  Bug 1734283 - separate classic and payload reports to allow 4 days of report.

Version-Release number of selected component (if applicable):
   Client version: 3.1.1
   Core version: 3.0.205-1

How reproducible:
Install and register the server.
Allow the timer to run normally for a few days.

Steps to Reproduce:
1. Install and register
2. Allow daily reports to be ran normally by timer.

Actual results:
Directory listing of /var/log/insights-client/
-rw-r--r--. 1 root root  11403 Feb  2 00:45 insights-client.log
-rw-r--r--. 1 root root 165379 Feb  2 00:45 insights-client.log.1
-rw-r--r--. 1 root root  11387 Feb  1 03:43 insights-client.log.2
-rw-r--r--. 1 root root 165074 Feb  1 03:43 insights-client.log.3

=> The smaller file is the base_url: cert-api.access.redhat.com/r/insights/platform
=> The larger file is the basic_url: cert-api.access.redhat.com/r/insights

Expected results:
There should be 4 log files for 4 different days.
Currently, each pair is ran seconds or minutes from each other.

Additional info:
This seems to be a regression of Bug 1734283.
Although, both the classic and payload reports are ran twice per day.
This gives 4 classic logs and 4 more payload logs for only 2 days worth.

Comment 1 Link Dupont 2021-02-02 14:29:50 UTC
What is the output of `systemctl list-units | grep -i insights`?

Comment 2 Bryan Kinney 2021-02-03 00:23:45 UTC
On the test server the output of that command:
 # systemctl list-units | grep -i insights
  insights-client-results.path                                                                loaded active waiting   Monitor /etc/insights-client/.lastupload for modifications
  insights-client.timer                                                                       loaded active waiting   Insights Client Timer Task

For the customer side please see comment #3 in the case.

Only the monitor and timer come up for both.
So no extra timers or the like.
You should be able to see this behavior in any normal running installation of insights.

I know that a log is made each time the client is used.
For example, during initial registration, there will be several log files for different tasks.
But that is a one time occurrence.

Comment 3 Link Dupont 2021-02-22 16:33:48 UTC
A new log file is created every time insights-client is run. The first log is generated by the nightly collection run of insights-client (triggered by insights-client.timer starting the insights-client.service unit). Towards the end of this process, it updates the file `/etc/insights-client/.lastupload`. The insights-client-results.path watches that file for changes and triggers the insights-client-results.service unit. _That_ unit runs `insights-client --check-results`. The second execution of insights-client with the `--check-results` flag then creates the second, smaller log file.

This is functioning "as designed", and is an unfortunate side-effect of a combination of factors based on the software's current architecture.

* Logs are rotated every time the process starts
* The process runs twice in an effort to retrieve the Advisor results from the archive that was most recently updated. This implementation can been seen in the `--check-results` and insights-client-results.{path,service} files. It was necessary to implement this feature in this way because insights-client does not have an event-triggering system, or a long-lived system daemon process that can run code at appropriate times. It can only operate when invoked (by a user, or by a process manager like systemd).

If you don't care about the "check-results" feature (where the JSON content of the most recent Advisor analysis is cached locally on the system), the simplest solution to this would be to disable and mask the path unit. This will stop the path unit and prevent it from starting. That, in turn, would prevent the second insights-client invocation from occurring and rotating the logs.

systemctl stop insights-client-results.path
systemctl mask insights-client-results.path

If you do use the check-results feature, then we would need to pursue a couple of possible solutions:

* Allow the number of logs kept to be modified by setting a value in the config file.
* Name the log file after the command string; then the log will rotate only on multiple invocations of the same command. So if I invoked "insights-client --check-results --verbose", a log file named insights-client_--check-results_--verbose.log would get created, and would only rotate if "insights-client --check-results --verbose" is invoked again. This has some obvious shortcomings that could leave log files around on the system indefinitely, so I'm not convinced this is a good approach yet.

Comment 4 Link Dupont 2021-02-24 15:54:38 UTC
Migrating this bug as part of the effort to close the cloud.redhat.com/Client Product/Component.

Comment 6 Peter Vreman 2021-02-26 13:31:34 UTC
Link,

What application/process is using the feature of caching the Advisor JSON enabled?
Why is a feature to download content just to populate a cached value that potential be used enabled by default, for me this is not backwards compatbile.
If 'systemctl mask insights-client-results.path' is an approach that the user can be doing. Where is it documented?

Honestly the most simple approach is to change just the keep '4' to '16' logfiles. I do not see why the 4 logfiles is such a constraint.
Also implement logrotate with compression then space to keep 30 days of logs is also not an issue.


Peter

Comment 7 Link Dupont 2021-03-01 14:48:01 UTC
(In reply to Peter Vreman from comment #6)
> Link,
> 
> What application/process is using the feature of caching the Advisor JSON
> enabled?

This was added to enable an integration between Cockpit and insights-client. The Cockpit team wanted to enhance their Insights integration to show a summary of the number of Advisor "hits" a particular system had when navigating the Cockpit UI.

> Why is a feature to download content just to populate a cached value that
> potential be used enabled by default, for me this is not backwards
> compatbile.

This is a fair point. It was probably something more appropriately released with a new "Y release", rather than in a batch update. Since the time when this feature was released, we began putting in more effort to make insights-client releases that align with appropriate RHEL releases; this should make these sort of unexpected feature enhancements more palatable.

> If 'systemctl mask insights-client-results.path' is an approach that the
> user can be doing. Where is it documented?

We may not have explicit documentation describing how to disable the insights-client-results.path systemd unit using the systemd masking feature. I can ask around if it is documented any where. Generally, masking a unit is considered a reasonable way to permanently disable a systemd unit, so there may have been some assumptions made that a system administrator who wished to disable a unit would "just know" to mask it.

> Honestly the most simple approach is to change just the keep '4' to '16'
> logfiles. I do not see why the 4 logfiles is such a constraint.

It's pretty arbitrary, yes. At the time, 4 was probably selected because it seemed reasonable, along with the assumption that insights-client would only ever run once per 24 hours. I agree that exposing the number of log files to keep as a config option is the simplest approach. It's a reasonable feature to add, without any downside, so I'll add it to our list of feature enhancements.

> Also implement logrotate with compression then space to keep 30 days of logs
> is also not an issue.

I believe the current implementation uses a Python log rotation library. I don't know whether that uses compression or not, but that is a reasonable thing to add while we're making changes to the logging code.

> 
> Peter

Comment 8 Peter Vreman 2021-03-16 09:41:14 UTC
Thanks for the https://access.redhat.com/solutions/5844811 that explains is nicely

For a real fix i recommand to look at the logfile topic as a whole. E.g. do you want to write a new log file for every action, or just append to an existing logfile.
E.g. also commands like '--version' and '--validate' are impacted.

I have raised RFE asking for logrotate in insights-client, sadly it is not picked up with the right mindset to improve a Insights, instead it was directly mentioned RHEL7 is end of life.

For me it is ok to have this BZ closed for the 'insights-client-result' fixed if the RFE to implement lograote is going to be implemented. If the logrotate is not going forward then I want to keep this BZ open because also simple actions like '--version' and '--validate' are createing new log files and are counted against the 4 logfiles history.

Comment 9 Link Dupont 2021-03-16 14:12:21 UTC
(In reply to Peter Vreman from comment #8)
> Thanks for the https://access.redhat.com/solutions/5844811 that explains is
> nicely
> 
> For a real fix i recommand to look at the logfile topic as a whole. E.g. do
> you want to write a new log file for every action, or just append to an
> existing logfile.
> E.g. also commands like '--version' and '--validate' are impacted.
> 
> I have raised RFE asking for logrotate in insights-client, sadly it is not
> picked up with the right mindset to improve a Insights, instead it was
> directly mentioned RHEL7 is end of life.

This was probably an automatic comment added as a side effect of us moving all the insights-client bugs under the Red Hat Enterprise Linux product family. Would you mind linking the bug number? We can take a look and see if it's really something that is RHEL 7 specific. If not, it can be moved the the Red Hat Enterprise Linux 8 product.

> 
> For me it is ok to have this BZ closed for the 'insights-client-result'
> fixed if the RFE to implement lograote is going to be implemented. If the
> logrotate is not going forward then I want to keep this BZ open because also
> simple actions like '--version' and '--validate' are createing new log files
> and are counted against the 4 logfiles history.

I'm more in favor of a general logrotate fix too, rather than a specific fix for this bug. It sounds like the workaround from the Solutions article is enough to mitigate this bug for you, correct?

Comment 10 Peter Vreman 2021-03-16 16:34:53 UTC
Link,

The masking works.
To be one the safe side I implemented it with 2 masks

systemctl mask insights-client-results.service
systemctl mask insights-client-results.path


There is one downside of masking 'insights-client-results.path'. There is a systemd dependency info message is not that nice and should be maybe be mentioned in the KB that it can safely be ignored:
----
vrempet-admin@li-lc-1437 ~
$ sudo systemctl status insights-client-results.path
● insights-client-results.path
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)

Mar 16 14:30:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 14:55:01 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 14:58:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 15:25:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 15:28:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 15:30:01 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 15:55:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 15:58:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 16:25:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.
Mar 16 16:28:00 li-lc-1437 systemd[1]: Cannot add dependency job for unit insights-client-results.path, ignoring: Unit is masked.

vrempet-admin@li-lc-1437 ~
$ sudo systemctl status insights-client-results.service
● insights-client-results.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)

vrempet-admin@li-lc-1437 ~
$
----



The dependency is added by comes from:
----
/usr/lib/systemd/system/insights-client.timer:Also=insights-client-results.path
----
Is this really needed here? For most users insights-client-results.path is not needed at all and shall be managed by a 'cockpit-insight-client' integration and not for simple insights-client with the collected data sent to cloud.redhat.com

Comment 11 Bryan Kinney 2021-03-19 00:29:02 UTC
The work around found here:
   https://access.redhat.com/solutions/5844811
is satisfactory for the current logging system in the insights-client.

The KB has been updated with a note of the systemd errors.
I believe this case can be closed.

Comment 12 Peter Vreman 2021-09-21 14:34:57 UTC
Any news to migrate the cockpit integration to a dedicated cockpit rpm and not in the base insights-client?

Comment 14 Alba Hita 2022-03-17 12:12:13 UTC
(In reply to Peter Vreman from comment #12)
> Any news to migrate the cockpit integration to a dedicated cockpit rpm and
> not in the base insights-client?

At this moment, there is no plan to do a dedicated cockpit rpm.

The KB seems to help solve this issue. 
There is a plan of future work in logrotate and improvements of logs in insights-client.
So it seems this case can be closed.

Comment 15 Link Dupont 2022-03-17 14:01:40 UTC
Peter, we dug up https://bugzilla.redhat.com/show_bug.cgi?id=1940267 and will be implementing a solution using logrotate. I think this provides a more flexible solution overall.

Comment 16 Peter Vreman 2022-03-17 14:31:33 UTC
Link, thanks, yes using logrotate is the most flexible way. I also asked for logrotate support in the past already that i as a customer can control the logrotation to my own needs.


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