Skip to content

Commit

Permalink
Merge pull request containers#7182 from zhangguanzhang/fix-exitCode-f…
Browse files Browse the repository at this point in the history
…or-start

implement the exitcode when start a container with attach
  • Loading branch information
openshift-merge-robot authored Aug 3, 2020
2 parents 2e3928e + a5a0ba9 commit 1709335
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/podman/containers/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ func start(cmd *cobra.Command, args []string) error {
}

for _, r := range responses {
if r.Err == nil && !startOptions.Attach {
fmt.Println(r.RawInput)
if r.Err == nil {
if startOptions.Attach {
// Implement the exitcode when the only one container is enabled attach
registry.SetExitCode(r.ExitCode)
} else {
fmt.Println(r.RawInput)
}
} else {
errs = append(errs, r.Err)
}
}
// TODO need to understand an implement exitcodes

return errs.PrintErrors()
}
12 changes: 12 additions & 0 deletions test/e2e/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ var _ = Describe("Podman start", func() {
Expect(session.OutputToString()).To(Equal(name))
})

It("podman start single container with attach and test the signal", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"create", "--entrypoint", "sh", ALPINE, "-c", "exit 1"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
cid := session.OutputToString()
session = podmanTest.Podman([]string{"start", "--attach", cid})
session.WaitWithDefaultTimeout()
// It should forward the signal
Expect(session.ExitCode()).To(Equal(1))
})

It("podman start multiple containers", func() {
session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expand Down

0 comments on commit 1709335

Please sign in to comment.