Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Filter CodeExitError type error in Exec streaming API #145

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/hyper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func (c *Client) ExecInContainer(containerId string, cmd []string, stdin io.Read
return err
}

return utilexec.CodeExitError{Err: nil, Code: int(exitCode)}
return utilexec.CodeExitError{Err: fmt.Errorf("Exit with code %d", exitCode), Code: int(exitCode)}
}

// Wait gets exit code by containerID and execID
Expand Down
7 changes: 6 additions & 1 deletion pkg/hyper/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
kubeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
"k8s.io/kubernetes/pkg/kubelet/server/streaming"
"k8s.io/kubernetes/pkg/kubelet/util/ioutils"
utilexec "k8s.io/kubernetes/pkg/util/exec"
)

type streamingRuntime struct {
Expand All @@ -42,7 +43,11 @@ func (sr *streamingRuntime) Exec(rawContainerID string, cmd []string, stdin io.R
if err != nil {
return err
}
return sr.client.ExecInContainer(rawContainerID, cmd, stdin, stdout, stderr, tty, resize, 0)
err = sr.client.ExecInContainer(rawContainerID, cmd, stdin, stdout, stderr, tty, resize, 0)
if _, ok := err.(utilexec.CodeExitError); ok {
return nil
}
return err
}

// Attach attach to a running container.
Expand Down