-
Notifications
You must be signed in to change notification settings - Fork 222
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
cmd/run: Optimize 'enter' and 'run' in the non-fallback case #813
cmd/run: Optimize 'enter' and 'run' in the non-fallback case #813
Conversation
This will be used by the subsequent commit to optimize the 'enter' and 'run' commands in the non-fallback case, by attempting the fallback only if an error was encountered by the main 'podman exec' invocation, as opposed to pre-emptively setting up the fallback. containers#813
Currently, the 'enter' command involves two extra invocations of 'podman exec' to detect if the user's chosen shell and current working directory are present inside the toolbox container. Each invocation is sufficiently expensive to add a noticeable overhead to the 'enter' and 'run' commands. Moreover, file system operations being inherently racy, it's always better to detect errors and handle them instead of trying to pre-emptively avoid them. Therefore, this shuffles the code around to attempt the non-fallback invocation, and then handle the errors by attempting a series of fallbacks for the command and the current working directory. containers#813
41bea8c
to
43a3222
Compare
Currently, the 'enter' command involves two extra invocations of 'podman exec' to detect if the user's chosen shell and current working directory are present inside the toolbox container. Each invocation is sufficiently expensive to add a noticeable overhead to the 'enter' and 'run' commands. Moreover, file system operations being inherently racy, it's always better to detect errors and handle them instead of trying to pre-emptively avoid them. Therefore, this shuffles the code around to attempt the non-fallback invocation, and then handle the errors by attempting a series of fallbacks for the command and the current working directory. containers#813
43a3222
to
3b57aac
Compare
Build failed.
|
Currently, the 'enter' command involves two extra invocations of 'podman exec' to detect if the user's chosen shell and current working directory are present inside the toolbox container. Each invocation is sufficiently expensive to add a noticeable overhead to the 'enter' and 'run' commands. Moreover, file system operations being inherently racy, it's always better to detect errors and handle them instead of trying to pre-emptively avoid them. Therefore, this shuffles the code around to attempt the non-fallback invocation, and then handle the errors by attempting a series of fallbacks for the command and the current working directory. Unfortunately, in case of a missing command, capsh(1) adds an extra error message that seems difficult to get rid of: $ toolbox enter /bin/sh: /bin/zsh: No such file or directory Error: command /bin/zsh not found in container fedora-toolbox-34 Using /bin/bash instead. containers#813
3b57aac
to
11051a6
Compare
Currently, the 'enter' command involves two extra invocations of 'podman exec' to detect if the user's chosen shell and current working directory are present inside the toolbox container. Each invocation is sufficiently expensive to add a noticeable overhead to the 'enter' and 'run' commands. Moreover, file system operations being inherently racy, it's always better to detect errors and handle them instead of trying to pre-emptively avoid them. Therefore, this shuffles the code around to attempt the non-fallback invocation, and then handle the errors by attempting a series of fallbacks for the command and the current working directory. Unfortunately, in case of a missing command, capsh(1) adds an extra error message that seems difficult to get rid of: $ toolbox enter /bin/sh: /bin/zsh: No such file or directory Error: command /bin/zsh not found in container fedora-toolbox-34 Using /bin/bash instead. containers#813
11051a6
to
4536e2c
Compare
Build failed.
|
err = fmt.Errorf("directory %s not found in container %s", workDir, container) | ||
return err | ||
} | ||
} else { |
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.
We can't assume that an exit code of 127 from podman exec
means that either the working directory or the command was absent. The given shell might also return with 127, which will get forwarded by podman exec
, if the last command that was attempted inside the shell was absent. In such cases this will create a loop.
See #872
Currently, the
enter
command involves two extra invocations ofpodman exec
to detect if the user's chosen shell and current workingdirectory are present inside the toolbox container. Each invocation is
sufficiently expensive to add a noticeable overhead to the
enter
andrun
commands. Moreover, file system operations being inherently racy,it's always better to detect errors and handle them instead of trying
to pre-emptively avoid them.
Therefore, this shuffles the code around to attempt the non-fallback
invocation, and then handle the errors by attempting a series of
fallbacks for the command and the current working directory.
Unfortunately, in case of a missing command,
capsh(1)
adds an extraerror message that seems difficult to get rid of: