Red Hat Bugzilla – Bug 1385177
katello-clean-empty-puppet-environments cron.weekly job needs to hide errors when trying to delete non-existent folders
Last modified: 2018-08-31 11:19 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.
better than ignoring possibly legitimate errors would be to check for the existence of the directory before doing the find.
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
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
http://projects.theforeman.org/issues/17047
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>
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