Red Hat Satellite engineering is moving the tracking of its product development work on Satellite 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 "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. 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 "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-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 1385177 - katello-clean-empty-puppet-environments cron.weekly job needs to hide errors when trying to delete non-existent folders
Summary: katello-clean-empty-puppet-environments cron.weekly job needs to hide errors ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Infrastructure
Version: 6.2.2
Hardware: x86_64
OS: Linux
low
low
Target Milestone: Unspecified
Assignee: Chris Roberts
QA Contact: Lukas Pramuk
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1399338 1405485
TreeView+ depends on / blocked
 
Reported: 2016-10-14 21:37 UTC by Craig Donnelly
Modified: 2019-12-16 07:07 UTC (History)
9 users (show)

Fixed In Version: katello-3.0.0-15
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1399338 1405485 (view as bug list)
Environment:
Last Closed: 2017-01-26 10:43:03 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 16523 0 Normal Closed Support cleaning empty puppet envs with puppet 4 2020-08-26 18:44:02 UTC
Foreman Issue Tracker 17047 0 Normal Resolved katello-clean-empty-puppet-environments cron.weekly job needs to hide errors when trying to delete non-existent folders 2020-08-26 18:44:03 UTC
Red Hat Product Errata RHBA-2017:0197 0 normal SHIPPED_LIVE Satellite 6.2.7 Async Bug Release 2017-01-26 15:38:38 UTC

Description Craig Donnelly 2016-10-14 21:37:43 UTC
Description of problem:
The cron.weekly job put in place to clean empty puppet environments will now have situations where there are no KT_* environments to clean up. In this situation, the find command fails and an error is output. We should redirect the errors to null (hide them) or come up with a different command.

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

How reproducible:
100%

Steps to Reproduce:
1. Install Satellite 6.2
2. Have no publshed puppet environments. (KT_* folders are no longer created for content-views, so on if not modules are published)
3. Run /etc/cron.weekly/katello-clean-empty-puppet-environments

Actual results:
find: ‘/etc/puppet/environments/KT*’: No such file or directory

Expected results:
No errors from script output

Additional info:
Since the only purpose is to clean out unused puppet environments, we could simply add '> /dev/null 2>&1' to the end of the scripts `find` command.

Comment 1 James Hartsock 2016-10-14 21:43:51 UTC
better than ignoring possibly legitimate errors would be to check for the existence of the directory before doing the find.

Comment 2 Craig Donnelly 2016-10-14 23:09:18 UTC
Sure thing,

We can go this route instead:

#!/bin/bash

if [ -d /etc/puppet/environments ];then
  if ls /etc/puppet/environments | grep KT; then
    find /etc/puppet/environments/KT* -maxdepth 0 -type d -empty -delete
  fi
fi

Comment 3 Craig Donnelly 2016-10-14 23:33:24 UTC
This has actually already been taken care of upstream.
The new cron looks like this:

$ cat katello-clean-empty-puppet-environments
#!/bin/bash

# Puppet 4
[ -d /etc/puppetlabs/code/environments ] &&  find /etc/puppetlabs/code/environments/KT* -maxdepth 0 -type d -empty -delete

# Puppet 3
[ -d /etc/puppet/environments ] && find /etc/puppet/environments/KT* -maxdepth 0 -type d -empty -delete

This just needs to be pulled down into Satellite 6.2.

Solved in:

https://github.com/Katello/katello-packaging/commit/f7b70e71ecaf99cd9de375d75d0880d4f3d5c3be

and

https://github.com/Katello/katello-packaging/commit/5846981719e9bd6a5617daf7078b8729dbb1e5f0

Comment 5 Chris Roberts 2016-10-20 14:18:54 UTC
http://projects.theforeman.org/issues/17047

Comment 6 Lukas Pramuk 2017-01-10 11:28:43 UTC
VERIFIED.

@satellite-6.2.7-1.0.el7sat.noarch
katello-common-3.0.0-15.el7sat.noarch

used manual reproducer from comment#0

# ls /etc/puppet/environments/KT*
ls: cannot access /etc/puppet/environments/KT*: No such file or directory

# /etc/cron.weekly/katello-clean-empty-puppet-environments
<empty>

Comment 8 errata-xmlrpc 2017-01-26 10:43:03 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-2017:0197


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