You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os::cmd sometimes doesn't find text in output #9371
FAILURE after 0.214s: test/cmd/router.sh:32: executing 'oadm router --dry-run --host-network=false --stats-port=1937 -o yaml' expecting failure and text 'hostPort: 1937': the output content test failed
Standard output from the command:
...
- containerPort: 1937
hostPort: 1937
...
Standard error from the command:
error: router could not be created; service account "router" is not allowed to access host ports on nodes, grant access with oadm policy add-scc-to-user hostnetwork -z router
@stevekuznetsov, don't you need to expand $grep_args in os::cmd::internal::expect_exit_code_run_grep when you invoke os::cmd::internal::run_collecting_output? Looks like it won't be expanded because it's in a single-quoted string in os::cmd::internal::expect_exit_code_run_grep, and it will be undefined in os::cmd::internal::run_collecting_output, so you'll be grepping for the empty string, which will always match.
It's a bit weird that you're telling os::cmd::internal::run_collecting_output to invoke os::cmd::internal::get_results because the former sets up redirection to ${os_cmd_internal_tmpout} and ${os_cmd_internal_tmperr}, and the latter cats ${os_cmd_internal_tmpout} and ${os_cmd_internal_tmperr}. I guess this is OK because you are appending, not truncating, in os::cmd::internal::run_collecting_output, but it looks weird, boggles the mind a bit, and makes me wonder whether it is really doing what was intended.
Very interesting ... grep -q exits with 0 as soon as it finds a match, which leaves the cat that's feeding it without a reader on the other side of the pipe, so it gets SIGPIPE and the shell fails with 141. @Miciah thoughts on how to work around this while keeping grep quiet?
Activity
[-]`os::cmd` sometimes mis-characterizes failure causes[/-][+]`os::cmd` sometimes doesn't find text in output[/+]stevekuznetsov commentedon Jul 7, 2016
Sample
std{err,out}logs for a failed run:stderrstdoutstevekuznetsov commentedon Jul 7, 2016
Downloading the logs above, I can't reproduce this error.
@Miciah the broken line is here and the functions called there are here and here ... any thoughts on how to better debug?
Miciah commentedon Jul 7, 2016
@stevekuznetsov, don't you need to expand
$grep_argsinos::cmd::internal::expect_exit_code_run_grepwhen you invokeos::cmd::internal::run_collecting_output? Looks like it won't be expanded because it's in a single-quoted string inos::cmd::internal::expect_exit_code_run_grep, and it will be undefined inos::cmd::internal::run_collecting_output, so you'll be grepping for the empty string, which will always match.It's a bit weird that you're telling
os::cmd::internal::run_collecting_outputto invokeos::cmd::internal::get_resultsbecause the former sets up redirection to${os_cmd_internal_tmpout}and${os_cmd_internal_tmperr}, and the latter cats${os_cmd_internal_tmpout}and${os_cmd_internal_tmperr}. I guess this is OK because you are appending, not truncating, inos::cmd::internal::run_collecting_output, but it looks weird, boggles the mind a bit, and makes me wonder whether it is really doing what was intended.Miciah commentedon Jul 7, 2016
Oh, disregard my first paragraph:
stevekuznetsov commentedon Jul 7, 2016
Yeah, re: your second paragraph... I'm not really sure why that happens the way it does. But if it ain't broke... :)
juanvallejo commentedon Jul 26, 2016
stevekuznetsov commentedon Jul 26, 2016
Very interesting ...
grep -qexits with0as soon as it finds a match, which leaves thecatthat's feeding it without a reader on the other side of the pipe, so it getsSIGPIPEand the shell fails with141. @Miciah thoughts on how to work around this while keepinggrepquiet?liggitt commentedon Jul 26, 2016
just redirect the
grepstderr/stdout to /dev/null?stevekuznetsov commentedon Jul 26, 2016
@liggitt not sure I understand what you mean -- the
SIGPIPEis happening from inside Bash, simply ignoring the error output ofgrepwon't help usliggitt commentedon Jul 26, 2016
instead of running grep in quiet mode
stevekuznetsov commentedon Jul 26, 2016
@liggitt I see. I think without changing the
grepbehavior we can instead do this since it's smarter about pipes: