feat(exec): Add --no-session flag for improved performance#26727
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
c03d7e3 to
5263c85
Compare
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
d63e18d to
f7d110b
Compare
|
Hello @mheon, I'm not really sure why some of the pipelines fail, I'm stuck. |
|
Integration tests, you need a SkipIfRemote in your tests. System tests are both flakes. |
f7d110b to
e637650
Compare
e637650 to
1853aea
Compare
f5cfc13 to
cd2b89f
Compare
cd2b89f to
82dcb63
Compare
82dcb63 to
1a91259
Compare
Honny1
left a comment
There was a problem hiding this comment.
Good job, LGTM
The failed Healthcheck seems to be a flake. I tested it locally and the Healthcheck passed.
|
LGTM |
|
I think there's still a pending review @mheon Or I'm not sure if I should do something else before that. |
|
@containers/podman-maintainers PTAL |
pkg/domain/infra/abi/containers.go
Outdated
| return define.TranslateExecErrorToExitCode(ec, err), err | ||
| } | ||
|
|
||
| func (ic *ContainerEngine) ContainerExecNoSession(ctx context.Context, nameOrID string, options entities.ExecOptions, streams define.AttachStreams) (int, error) { |
There was a problem hiding this comment.
is there a reason to define a new function on the interface like this, it could easily be added in ContainerExec()
In particular this function simply removes several required things that ContainerExec() does.
First this here never calls, getContainers() which means --latest will be broken
Second, it misses the if options.Tty branch to add the TERM env which means you get different behavior fro TERM in session on no session mode which seems very unexpected
Lastly it also doesn't do the tty resize logic that is in ExecAttachCtr() so the terminal is not set into the right state I think
There was a problem hiding this comment.
I'd prefer to keep this separate - I'm expecting further changes down the line to diverge from normal Exec()
There was a problem hiding this comment.
different how? we can split in libpod but doing this here on the cli/ContainerEngine just seems to bypass basic code that we must always do as I pointed out above.
We can always do if execNoSession inside ContainerExec() once we looked up the container and configured the basic exec config.
what further changes are expected here where this function makes sense?
There was a problem hiding this comment.
Complete removal of the Conmon backend in favor of directly calling OCI runtime exec directly.
There was a problem hiding this comment.
Sure but that can still happen within ContainerExec(), right now we duplicate common lookup logic which I find quite bad due the bugs mentioned, at the end of ContainerExec() a simple if options.NoSession would be easier IMO.
There was a problem hiding this comment.
Was there something I should do related to this?
I'm a little unsure, will resolve it in the meantime!
|
Do we have any numbers on what's the improvement is? Can you run it under hyperfine and check what's the difference with a regular exec? |
I did the test on my machine and the results are very good: |
There is this in makeExecConfig() which sets a exit command on conmon which we don't want. So in theory all you need to do is to make sure the command is nil for you exec config then it should work I think. |
1a91259 to
bb3eaf0
Compare
bb3eaf0 to
bb967f2
Compare
bb967f2 to
0d8b404
Compare
0d8b404 to
d15725c
Compare
| Expect(execResult).Should(ExitWithError(127, "OCI runtime attempted to invoke a command that was not found")) | ||
|
|
||
| execSession := podmanTest.Podman([]string{"exec", "--no-session", ctrName, "sleep", "30"}) | ||
| killSession := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "kill -9 $(pgrep sleep)"}) |
There was a problem hiding this comment.
I think the problem here is that this is running serially - maybe put the execSession bit in a goroutine so they run concurrent? Though you'd need a sleep to sequence them, give time for the first exec to start (our CI is really slow)
d718ce4 to
2cb0bce
Compare
|
Any suggestions on how to fix the failure on that pipeline due to the merge? I think there's also a linting error from upstream? |
|
Linting error fix: #27234 |
|
@ryanmccann1024 Could you please rebase on main? |
2cb0bce to
90057c1
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Honny1, ryanmccann1024 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Hello, Should I do anything else for this PR? |
Fixes: containers#26588 For use cases like HPC, where `podman exec` is called in rapid succession, the standard exec process can become a bottleneck due to container locking and database I/O for session tracking. This commit introduces a new `--no-session` flag to `podman exec`. When used, this flag invokes a new, lightweight backend implementation that: - Skips container locking, reducing lock contention - Bypasses the creation, tracking, and removal of exec sessions in the database - Executes the command directly and retrieves the exit code without persisting session state - Maintains consistency with regular exec for container lookup, TTY handling, and environment setup - Shares implementation with health check execution to avoid code duplication The implementation addresses all performance bottlenecks while preserving compatibility with existing exec functionality including --latest flag support and proper exit code handling. Changes include: - Add --no-session flag to cmd/podman/containers/exec.go - Implement lightweight execution path in libpod/container_exec.go - Ensure consistent container validation and environment setup - Add comprehensive exit code testing including signal handling (exit 137) - Optimize configuration to skip unnecessary exit command setup Signed-off-by: Ryan McCann <ryan_mccann@student.uml.edu> Signed-off-by: ryanmccann1024 <ryan_mccann@student.uml.edu>
90057c1 to
61cbc0c
Compare
|
Restarted 3 flakes |
|
/lgtm |
|
I don't know why it's not picking up the release note. Removed the label. |
Luap99
left a comment
There was a problem hiding this comment.
Personally I am still not happy with the duplication between ContainerExecNoSession() and ContainerExec(), people will forget to update them in sync if new option get added and it seems really unnecessary to me to define more of these "engine" interface functions when there is exactly one call only different.
But since others want to merge this then I won't object further
Fixes: #26588
For use cases like HPC, where
podman execis called in rapid succession, the standard exec process can become a bottleneck due to container locking and database I/O for session tracking.This commit introduces a new
--no-sessionflag topodman exec. When used, this flag invokes a new, lightweight backend implementation (ExecNoSession) that:Does this PR introduce a user-facing change?