Repository navigation
Use anonyous FIFO instead of pipe in os::cmd output test - #10040
Conversation
|
@liggitt PTAL |
|
[test] |
| if [[ -n "${grep_args}" ]]; then | ||
| test_result=$( os::cmd::internal::run_collecting_output 'os::cmd::internal::get_results | grep -Eq "${grep_args}"'; echo $? ) | ||
|
|
||
| test_result=$( os::cmd::internal::run_collecting_output "grep -Eq '${grep_args}' <(os::cmd::internal::get_results)"; echo $? ) |
There was a problem hiding this comment.
is there a reason the quotes got inverted?
There was a problem hiding this comment.
They were technically correct both times since the os::cmd::internal::run_collecting_output does an eval ... but it's better practice to have the args (e.g. ${grep_args}) expand in the shell before the eval so things like the stack trace can better signal to us what exactly was going on.
|
LGTM |
fc484e0 to
cbb9d32
Compare
|
After going to hell and back trying to understand ten layers of Bash quoting rules I am happy with this now [test] |
cbb9d32 to
5ac5735
Compare
|
Flake on e2e, this is ready @liggitt |
|
The "no output" error surprised me, could it be related? |
| # Validate patching works correctly | ||
| oc login -u system:admin | ||
| os::cmd::expect_success 'oc login -u system:admin' | ||
| # Clean up group if needed to be re-entrant |
5ac5735 to
703b5be
Compare
Still can't run e2e locally ... re[test] although I would not expect that to be related, nothing changed with how we gather the output, just how we search through it |
|
@liggitt didn't see the issue in e2e again, do not think it is related to this patch |
|
@liggitt my comment triggered the currently running tests, but the push triggered the last series, which succeeded |
|
[merge] |
|
test flaked on #9938: merge flaked on @liggitt please re-tag |
|
rebased & ready again @liggitt |
|
[merge] |
|
@openshift-bot you're drunk, go home |
Previously, the output of the last command was searched by `grep -q`. When `grep -q` finds the text it is looking for, it exits immediately with exit code 0. If the command feed- ing `grep -q` with input is still running, it will write to a pipe that has no readers, and Bash will terminate the producer process with a SIGPIPE as this is invalid behavior. Instead of using a `cat | grep` approach for searching in os::cmd, we can therefore use `grep <(file)` approach, which creates an anonymous FIFO to pass the data and therefore guards against this sort of error. Signed-off-by: Steve Kuznetsov <[email protected]>
Signed-off-by: Steve Kuznetsov <[email protected]>
Signed-off-by: Steve Kuznetsov <[email protected]>
Signed-off-by: Steve Kuznetsov <[email protected]>
Signed-off-by: Steve Kuznetsov <[email protected]>
703b5be to
6badc53
Compare
|
@liggitt robot is crazy, or GitHub API is crazy, since there were no merge conflicts, but I had to rebase anyway... will probably need another tag later |
|
[test][merge] |
|
Evaluated for origin merge up to 6badc53 |
|
Evaluated for origin test up to 6badc53 |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/7067/) |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/7067/) (Image: devenv-rhel7_4706) |
Previously, the output of the last command was searched by
grep -q. Whengrep -qfinds the text it is looking for,it exits immediately with exit code 0. If the command feed-
ing
grep -qwith input is still running, it will writeto a pipe that has no readers, and Bash will terminate the
producer process with a SIGPIPE as this is invalid behavior.
Instead of using a
cat | grepapproach for searching inos::cmd, we can therefore use
grep <(file)approach, whichcreates an anonymous FIFO to pass the data and therefore
guards against this sort of error.
Signed-off-by: Steve Kuznetsov [email protected]
fixes #9371