puppet-mongodb
puppet-mongodb copied to clipboard
Reorder switches in dbpath_fix find command
Pull Request (PR) description
Fix ordering of switches in dbpath_fix's find command
This Pull Request (PR) fixes the following issues
Fixes #571
Hi. I gave this a quick look and I'm not sure if this change is correct. The find output differs, depending on the command order. I am not sure if the new output is still correct.
My understanding is that this block of code is supposed to run if the ~~output~~ return code of only_if command is 0. This will happen only if grep matches any lines and for that find needs to produce any output which does not happen with -print in its current position. In fact -print could be skipped altogether because it is default if no other expression is specified.
@pjfbashton can you provide an acceptance test that valides this PR?
Apologies for delayed response.
You are actually correct. Proposed solution was not working as intended as it would always return results thus that exec would always run.
Existing find command is not correct though because it will never return results and it seems that the correct solution is to drop -print altogether and I have update the PR to that effect.
Please see the following
test 1 - mixed ownership
# find m/ -ls
2886300 4 drwxr-xr-x 5 root root 4096 Mar 18 11:47 m
2886303 4 drwxr-xr-x 2 root root 4096 Mar 18 11:47 m/3
2886301 4 drwxr-xr-x 2 mongod mongod 4096 Mar 18 11:47 m/1
2886302 4 drwxr-xr-x 2 mongod mongod 4096 Mar 18 11:47 m/2
- current solution is wrong - it should return 2 results so that grep matches and exec is run
# find m -not -user mongod -o -not -group mongod -print -quit | wc -l
0
- working solution is to actually drop
-printaltogether
# find m/ -not -user mongod -o -not -group mongod -quit | wc -l
2
test 2 - ownership on all files is wrong
# find m/ -ls
2886300 4 drwxr-xr-x 5 root root 4096 Mar 18 11:47 m
2886303 4 drwxr-xr-x 2 root root 4096 Mar 18 11:47 m/3
2886301 4 drwxr-xr-x 2 root root 4096 Mar 18 11:47 m/1
2886302 4 drwxr-xr-x 2 root root 4096 Mar 18 11:47 m/2
- existing solution returns no results and it should return 4 lines
# find m/ -not -user mongod -o -not -group mongod -print -quit | wc -l
0
- no
-printsolution - correct result
# find m/ -not -user mongod -o -not -group mongod -quit | wc -l
4
test 3 - ownership on all files is correct
# find m -ls
2886300 4 drwxr-xr-x 5 mongod mongod 4096 Mar 18 11:47 m
2886303 4 drwxr-xr-x 2 mongod mongod 4096 Mar 18 11:47 m/3
2886301 4 drwxr-xr-x 2 mongod mongod 4096 Mar 18 11:47 m/1
2886302 4 drwxr-xr-x 2 mongod mongod 4096 Mar 18 11:47 m/2
- existing solution
# find m/ -not -user mongod -o -not -group mongod -print -quit | wc -l
0
- proposed solution
# find m/ -not -user mongod -o -not -group mongod -quit | wc -l
0
As you can see from above 3 cases only find command without -print works fine.