runc init: remove some code#3113
Merged
Merged
Conversation
runc init is special. For one thing, it needs to do a few things before main(), so we have func init() that checks if we're init and does that. What happens next is main() is called, which does some options parsing, figures out it needs to call initCommand.Action and so it does. Now, main() is entirely unnecessary -- we can do everything right from init(). Hopefully the change makes things slightly less complicated. From a user's perspective, the only change is runc help no longer lists 'runc init` (which I think it also good). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
As pointed out in TODO item added by commit 64bb59f, it is not necessary to have a special sync mechanism for cgroupns, as the parent adds runc init to cgroup way earlier (before sending nl bootstrap data. This sync was added by commit df3fa11, which was also added a second cgroup manager.Apply() call, later removed in commit d1ba8e3. It seems the original author had the idea to wait for that second Apply(). Fixes: df3fa11 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
3 tasks
cyphar
reviewed
Jul 29, 2021
| func init() { | ||
| if len(os.Args) > 1 && os.Args[1] == "init" { | ||
| // This is the golang entry point for runc init, executed | ||
| // before main() but after libcontainer/nsenter's nsexec(). |
Member
There was a problem hiding this comment.
Might not hurt to mention the function never returns (since this all ends in execve) so main never actually runs.
Contributor
Author
There was a problem hiding this comment.
I had something like that but eventually removed it as this is somewhat clear (for one thing, the code within the block ends with a panic).
I will try to improve this further in #3114 (which is a followup to this PR).
mrunalp
approved these changes
Jul 29, 2021
This file contains hidden or 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
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.
Remove some code from runc init which is not needed. Please review commit-by-commit.