Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1679986

Summary: Add random sleep time for insights configuration
Product: Red Hat Enterprise Linux 6 Reporter: Kenny Tordeurs <ktordeur>
Component: insights-clientAssignee: Link Dupont <link>
Status: CLOSED ERRATA QA Contact: Pavol Kotvan <pakotvan>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.10CC: ahumbe, cww, dajohnso, jcrafts, klape, lphiri, nicampbe, pakotvan, robwilli, toneata
Target Milestone: rcKeywords: Triaged
Target Release: 6.10   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-10 10:15:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1766236    
Bug Blocks:    

Description Kenny Tordeurs 2019-02-22 12:40:55 UTC
Description of problem:
When many (hundreds) RHEL6 clients are running insights cronjob at the same time to Satellite it can cause 503 errors:
~~~
DEBUG insights.client.connection Upload status: 503 Service Unavailable {"displayMessage": "Service unavailable or restarting, try later", "errors": ["Service unavailable or restarting, try later"], "status": "503" }
ERROR insights.client.connection Upload archive failed with status code  503
ERROR insights.client.client Upload attempt 1 of 1 failed! Status Code: 503
ERROR insights.client.client All attempts to upload have failed!
~~~

The cronjob in question:

# cat etc/cron.daily/insights-client
~~~
#!/bin/sh
name=insights-client
path=/usr/bin/${name}

/sbin/service cgconfig status > /dev/null 2>&1
if [ $? == 0 ];
then
    /bin/cgcreate -g memory,cpu,blkio:insights
    /bin/cgset -r memory.limit_in_bytes=2147483648 insights
    /bin/cgset -r memory.soft_limit_in_bytes=1073741824 insights
    /bin/cgset -r memory.memsw.limit_in_bytes=2147483648 insights
    /bin/cgset -r cpu.cfs_quota_us=30000 -r cpu.cfs_period_us=100000 insights
    /bin/cgset -r blkio.weight=100 insights
    /bin/cgexec -g memory,cpu,blkio:insights /usr/bin/timeout 10m ${path} --retry 3 --quiet
    /bin/cgdelete memory,cpu,blkio:insights
else
    /usr/bin/timeout 10m ${path} --quiet
fi
~~~

It's actually a symlink to:
# file etc/cron.daily/insights-client
/etc/cron.daily/insights-client: symbolic link to ../insights-client/insights-client.cron

I would say the best would be to add a delay to the execution, what about something like below:
~~~
#!/bin/sh

# Add a random sleep time of max 20min before executing
/bin/sleep   `/usr/bin/expr $RANDOM % 1200`

name=insights-client
path=/usr/bin/${name}

/sbin/service cgconfig status > /dev/null 2>&1
if [ $? == 0 ];
then
    /bin/cgcreate -g memory,cpu,blkio:insights
    /bin/cgset -r memory.limit_in_bytes=2147483648 insights
    /bin/cgset -r memory.soft_limit_in_bytes=1073741824 insights
    /bin/cgset -r memory.memsw.limit_in_bytes=2147483648 insights
    /bin/cgset -r cpu.cfs_quota_us=30000 -r cpu.cfs_period_us=100000 insights
    /bin/cgset -r blkio.weight=100 insights
    /bin/cgexec -g memory,cpu,blkio:insights /usr/bin/timeout 10m ${path} --retry 3 --quiet
    /bin/cgdelete memory,cpu,blkio:insights
else
    /usr/bin/timeout 10m ${path} --quiet
fi
~~~

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

How reproducible:
100%

Steps to Reproduce:
1. Run hundreds of insights-clients report uploads concurrently to your Satellite
2.
3.

Actual results:
~~~
DEBUG insights.client.connection Upload status: 503 Service Unavailable {"displayMessage": "Service unavailable or restarting, try later", "errors": ["Service unavailable or restarting, try later"], "status": "503" }
ERROR insights.client.connection Upload archive failed with status code  503
ERROR insights.client.client Upload attempt 1 of 1 failed! Status Code: 503
ERROR insights.client.client All attempts to upload have failed!
~~~


Expected results:
No issues

Additional info:

Comment 4 Kenny Tordeurs 2019-02-22 16:39:43 UTC
Important note:

This is only for RHEL6 clients as they use cronjobs for the scheduling.

insights-client for RHEL 7.5 uses systemd, instead of cron, for client agent scheduling. The reason for the change is to enhance resource utilization in RHEL 7 so that Insights doesn’t impact customer machines by using too many compute resources. The change to systemd will delete any current customization of the Red Hat Insights cron job.

# systemctl status insights-client.service

Also there is a insights-client.timer service:
# systemctl status insights-client.timer


# cat /etc/systemd/system/multi-user.target.wants/insights-client.timer
~~~
[Unit]
Description=Insights Client Timer Task
Documentation=man:insights-client(8)
After=network.target

[Timer]
OnCalendar=daily
RandomizedDelaySec=14400

[Install]
WantedBy=multi-user.target
~~~

Comment 5 Dave Johnson 2019-11-15 03:49:53 UTC
Pavol, please reproduce and create an associated JIRA card.  I am tempted to say this is no longer an issue, right.  We are are not seeing this in production, right?

Comment 7 Link Dupont 2019-11-15 13:40:34 UTC
This is fixed in PR#97[1]. I implemented a very similar solution to the suggestion above.

1: https://github.com/RedHatInsights/insights-client/pull/97

Comment 8 Dave Johnson 2020-01-20 15:04:08 UTC
Pavol, has this been released yet?  If not, can you please give an idea as to when?  TY

Comment 14 errata-xmlrpc 2020-03-10 10:15: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://access.redhat.com/errata/RHBA-2020:0748