-
Notifications
You must be signed in to change notification settings - Fork 17.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
os/exec: exec.CommandContext(...).Output() does not respect context timeout #57129
Labels
Comments
Duplicate of #23019 |
rm3l
added a commit
to rm3l/odo
that referenced
this issue
May 10, 2023
This command is called at dependency injection time to initialize a (nil-able) Podman client, even if users won't use Podman at all. As discussed, this command is supposed to be quite fast to return, hence this timeout of 1 second. Initially, we were using cmd.Output to get the command output, but as reported in [1], cmd.Output does not respect the context timeout. This explains the workaround of reading from both stdout and stderr pipes, *and* relying on cmd.Wait() to close those pipes properly when the program exits (either as expected or when the timeout is reached). [1] golang/go#57129
rm3l
added a commit
to rm3l/odo
that referenced
this issue
May 10, 2023
This command is called at dependency injection time to initialize a (nil-able) Podman client, even if users won't use Podman at all. As discussed, this command is supposed to be quite fast to return, hence this timeout of 1 second. Initially, we were using cmd.Output to get the command output, but as reported in [1], cmd.Output does not respect the context timeout. This explains the workaround of reading from both stdout and stderr pipes, *and* relying on cmd.Wait() to close those pipes properly when the program exits (either as expected or when the timeout is reached). [1] golang/go#57129 Co-authored-by: Philippe Martin <phmartin@redhat.com>
rm3l
added a commit
to rm3l/odo
that referenced
this issue
May 10, 2023
This command is called at dependency injection time to initialize a (nil-able) Podman client, even if users won't use Podman at all. As discussed, this command is supposed to be quite fast to return, hence this timeout of 1 second. Initially, we were using cmd.Output to get the command output, but as reported in [1], cmd.Output does not respect the context timeout. This explains the workaround of reading from both stdout and stderr pipes, *and* relying on cmd.Wait() to close those pipes properly when the program exits (either as expected or when the timeout is reached). [1] golang/go#57129 Co-authored-by: Philippe Martin <phmartin@redhat.com>
openshift-merge-robot
pushed a commit
to redhat-developer/odo
that referenced
this issue
May 11, 2023
…ld not affect `odo dev` on cluster) (#6808) * Add test highlighting the issue and setting the expectations * Add a timeout of 1s to the 'podman version' command This command is called at dependency injection time to initialize a (nil-able) Podman client, even if users won't use Podman at all. As discussed, this command is supposed to be quite fast to return, hence this timeout of 1 second. Initially, we were using cmd.Output to get the command output, but as reported in [1], cmd.Output does not respect the context timeout. This explains the workaround of reading from both stdout and stderr pipes, *and* relying on cmd.Wait() to close those pipes properly when the program exits (either as expected or when the timeout is reached). [1] golang/go#57129 Co-authored-by: Philippe Martin <phmartin@redhat.com> * Log the errors returned at dependency injection time when the optional Kubernetes/Podman clients could not be initialized This helps debug such potential issues instead of swallowing the errors. * Make the timeout configurable via the 'PODMAN_CMD_INIT_TIMEOUT' env var This will allow setting a different value for environments like in GitHub where the Podman client would take slightly more time to return (I guess because of we are running a lot of Podman commands in parallel?). * Increase the timeout for Podman tests to an arbitrary value of 10s Some tests did not pass because the Podman client did not initialize in 1s; I guess because we are running a lot of Podman commands in parallel? This should hopefully improve this situation. * fixup! Add a timeout of 1s to the 'podman version' command --------- Co-authored-by: Philippe Martin <phmartin@redhat.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?I create the following two files
go env
OutputWhat did you do?
Create two files:
main.go
hang.sh
Then run
What did you expect to see?
I expect the program to complete in approximately 1 second with the following output:
What did you see instead?
Program completes with the expected output, but only after 100 seconds.
Interestingly enough, when I replace
.Output()
withRun()
, the program completes in 1 second as expected.The text was updated successfully, but these errors were encountered: