-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improvements to how runc exec
is handled
#4592
Open
kolyshkin
wants to merge
4
commits into
opencontainers:main
Choose a base branch
from
kolyshkin:exec-nits
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's move some code from execProcess to newProcess, fixing the following few issues: 1. There is no need to call container.State() here (which does quite a lot) -- we only need container.Config(). 2. There is no need to search for bundle in container labels if "runc exec --process" form is used. 3. There is no need to search for "process" value twice. 4. It is not very clear why checking for len(context.Args()) is done. Move the check to just before Args is used. Signed-off-by: Kir Kolyshkin <[email protected]>
Every time we call container.Config(), a new copy of struct Config is created and returned, and we do it twice here. Accessing container.config directly fixes this. Fixes: 805b8c7 ("Do not create exec fifo in factory.Create") Signed-off-by: Kir Kolyshkin <[email protected]>
The rootuid and rootgid are only needed when detach and createTTY are both false. We also call c.Config() twice, every time creating a copy of struct Config. Solve both issues by passing container pointer to setupIO, and get rootuid/rootgid only when we need those. Signed-off-by: Kir Kolyshkin <[email protected]>
1. Pass an argument as a pointer rather than copying the whole structure. It was a pointer initially, but this has changed in commit b2d9d99 without giving a reason why. 2. The newProcess description was added by commit 9fac183 (yes, the very first one) and hasn't changed since. As of commit 29b139f, the part of it which says "and stdio from the current process" is no longer valid. Remove it, and while at it, rewrite the description entirely. Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin
commented
Jan 16, 2025
Comment on lines
-165
to
-172
state, err := container.State() | ||
if err != nil { | ||
return -1, err | ||
} | ||
bundle, ok := utils.SearchLabels(state.Config.Labels, "bundle") | ||
if !ok { | ||
return -1, errors.New("bundle not found in labels") | ||
} |
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.
this is replaced with
bundle, ok := utils.SearchLabels(c.Config().Labels, "bundle")
if !ok {
return nil, errors.New("bundle not found in labels")
}
(see below)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few small and specific patches around how
runc exec
is being set up.No changes to functionality, relatively easy to review.
Please see individual commit descriptions for details.