-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use anonyous FIFO instead of pipe in os::cmd output test #10040
Use anonyous FIFO instead of pipe in os::cmd output test #10040
Conversation
@liggitt PTAL |
[test] |
@@ -193,23 +193,14 @@ function os::cmd::internal::expect_exit_code_run_grep() { | |||
|
|||
local test_result=0 | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason the quotes got inverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
|
@@ -349,9 +349,8 @@ echo 'projects command ok' | |||
|
|||
os::test::junit::declare_suite_start "cmd/basicresources/patch" | |||
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move or remove comment
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 -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 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 | grep
approach 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