Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1385177 - katello-clean-empty-puppet-environments cron.weekly job needs to hide errors when trying to delete non-existent folders
katello-clean-empty-puppet-environments cron.weekly job needs to hide errors ...
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Infrastructure (Show other bugs)
6.2.2
x86_64 Linux
low Severity low (vote)
: 6.2.7
: Unused
Assigned To: Chris Roberts
Lukas Pramuk
http://projects.theforeman.org/issues...
: Triaged
Depends On:
Blocks: 1399338 1405485
  Show dependency treegraph
 
Reported: 2016-10-14 17:37 EDT by Craig Donnelly
Modified: 2018-08-31 11 EDT (History)
9 users (show)

See Also:
Fixed In Version: katello-3.0.0-15
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1399338 1405485 (view as bug list)
Environment:
Last Closed: 2017-01-26 05:43:03 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 16523 None None None 2016-10-17 19:01 EDT
Foreman Issue Tracker 17047 None None None 2016-10-20 11:03 EDT
Red Hat Product Errata RHBA-2017:0197 normal SHIPPED_LIVE Satellite 6.2.7 Async Bug Release 2017-01-26 10:38:38 EST

  None (edit)
Description Craig Donnelly 2016-10-14 17:37:43 EDT
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 17:43:51 EDT
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 19:09:18 EDT
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 19:33:24 EDT
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 10:18:54 EDT
http://projects.theforeman.org/issues/17047
Comment 6 Lukas Pramuk 2017-01-10 06:28:43 EST
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 05:43:03 EST
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.