-
Notifications
You must be signed in to change notification settings - Fork 3.1k
use conmon for exec #3143
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
Merged
openshift-merge-robot
merged 2 commits into
containers:master
from
haircommander:conmon-exec
Jul 22, 2019
Merged
use conmon for exec #3143
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,8 +35,9 @@ func init() { | |
| execCommand.SetUsageTemplate(UsageTemplate()) | ||
| flags := execCommand.Flags() | ||
| flags.SetInterspersed(false) | ||
| flags.StringVar(&execCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _") | ||
| flags.StringArrayVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables") | ||
| flags.BoolVarP(&execCommand.Interfactive, "interactive", "i", false, "Not supported. All exec commands are interactive by default") | ||
| flags.BoolVarP(&execCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached") | ||
| flags.BoolVarP(&execCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of") | ||
| flags.BoolVar(&execCommand.Privileged, "privileged", false, "Give the process extended Linux capabilities inside the container. The default is false") | ||
| flags.BoolVarP(&execCommand.Tty, "tty", "t", false, "Allocate a pseudo-TTY. The default is false") | ||
|
|
@@ -45,30 +46,35 @@ func init() { | |
| flags.IntVar(&execCommand.PreserveFDs, "preserve-fds", 0, "Pass N additional file descriptors to the container") | ||
| flags.StringVarP(&execCommand.Workdir, "workdir", "w", "", "Working directory inside the container") | ||
| markFlagHiddenForRemoteClient("latest", flags) | ||
| markFlagHiddenForRemoteClient("preserve-fds", flags) | ||
| } | ||
|
|
||
| func execCmd(c *cliconfig.ExecValues) error { | ||
| args := c.InputArgs | ||
| argStart := 1 | ||
| if len(args) < 1 && !c.Latest { | ||
| return errors.Errorf("you must provide one container name or id") | ||
| } | ||
| if len(args) < 2 && !c.Latest { | ||
| return errors.Errorf("you must provide a command to exec") | ||
| } | ||
| argLen := len(c.InputArgs) | ||
| if c.Latest { | ||
| argStart = 0 | ||
| if argLen < 1 { | ||
| return errors.Errorf("you must provide a command to exec") | ||
| } | ||
| } else { | ||
| if argLen < 1 { | ||
| return errors.Errorf("you must provide one container name or id") | ||
| } | ||
| if argLen < 2 { | ||
| return errors.Errorf("you must provide a command to exec") | ||
| } | ||
| } | ||
| cmd := args[argStart:] | ||
| runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "error creating libpod runtime") | ||
| } | ||
| defer runtime.DeferredShutdown(false) | ||
|
|
||
| err = runtime.Exec(c, cmd) | ||
| if errors.Cause(err) == define.ErrCtrStateInvalid { | ||
| exitCode, err = runtime.ExecContainer(getContext(), c) | ||
| if errors.Cause(err) == define.ErrOCIRuntimePermissionDenied { | ||
| exitCode = 126 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR but maybe worth checking later: it may be worth add exit codes to the |
||
| } | ||
| if errors.Cause(err) == define.ErrOCIRuntimeNotFound { | ||
| exitCode = 127 | ||
| } | ||
| return err | ||
| } | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1234,6 +1234,7 @@ _podman_diff() { | |
|
|
||
| _podman_exec() { | ||
| local options_with_args=" | ||
| --detach-keys | ||
| -e | ||
| --env | ||
| --user | ||
|
|
||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.