Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Don't link the shell to the shim in detached mode
Browse files Browse the repository at this point in the history
In case our runtime is used in standalone mode with the --detach
flag enabled, we should not get any output on the current shell.
We should still be able to get some outputs if a console has been
provided.

This patch relies on the latest virtcontainers vendoring to be
able to indicate if we are in case of a detached command or not.

Fixes #326

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
  • Loading branch information
Sebastien Boeuf committed Jul 14, 2017
1 parent 9d8d773 commit 80c686b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ var createCLICommand = cli.Command{
context.String("bundle"),
console,
context.String("pid-file"),
false,
runtimeConfig,
)
},
}

func create(containerID, bundlePath, console, pidFilePath string,
func create(containerID, bundlePath, console, pidFilePath string, detach bool,
runtimeConfig oci.RuntimeConfig) error {
var err error

Expand All @@ -106,12 +107,12 @@ func create(containerID, bundlePath, console, pidFilePath string,

switch containerType {
case vc.PodSandbox:
process, err = createPod(ociSpec, runtimeConfig, containerID, bundlePath, console)
process, err = createPod(ociSpec, runtimeConfig, containerID, bundlePath, console, detach)
if err != nil {
return err
}
case vc.PodContainer:
process, err = createContainer(ociSpec, containerID, bundlePath, console)
process, err = createContainer(ociSpec, containerID, bundlePath, console, detach)
if err != nil {
return err
}
Expand Down Expand Up @@ -144,7 +145,7 @@ func create(containerID, bundlePath, console, pidFilePath string,
}

func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
containerID, bundlePath, console string) (vc.Process, error) {
containerID, bundlePath, console string, detach bool) (vc.Process, error) {

ccKernelParams := []vc.Param{
{
Expand Down Expand Up @@ -175,7 +176,7 @@ func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
}
}

podConfig, err := oci.PodConfig(ociSpec, runtimeConfig, bundlePath, containerID, console, false)
podConfig, err := oci.PodConfig(ociSpec, runtimeConfig, bundlePath, containerID, console, detach)
if err != nil {
return vc.Process{}, err
}
Expand All @@ -194,9 +195,9 @@ func createPod(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
}

func createContainer(ociSpec oci.CompatOCISpec, containerID, bundlePath,
console string) (vc.Process, error) {
console string, detach bool) (vc.Process, error) {

contConfig, err := oci.ContainerConfig(ociSpec, bundlePath, containerID, console, false)
contConfig, err := oci.ContainerConfig(ociSpec, bundlePath, containerID, console, detach)
if err != nil {
return vc.Process{}, err
}
Expand Down
1 change: 1 addition & 0 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func execute(context *cli.Context) error {
User: params.ociProcess.User.Username,
Interactive: params.ociProcess.Terminal,
Console: consolePath,
Detach: params.detach,
}

_, _, process, err := vc.EnterContainer(podID, params.cID, cmd)
Expand Down
2 changes: 1 addition & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func run(containerID, bundle, console, consoleSocket, pidFile string, detach boo
return err
}

if err := create(containerID, bundle, consolePath, pidFile, runtimeConfig); err != nil {
if err := create(containerID, bundle, consolePath, pidFile, detach, runtimeConfig); err != nil {
return err
}

Expand Down

0 comments on commit 80c686b

Please sign in to comment.