Skip to content
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
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kolyshkin
Copy link
Contributor

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.

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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
@kolyshkin kolyshkin marked this pull request as ready for review January 16, 2025 05:38
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")
}
Copy link
Contributor Author

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant