Skip to content

Commit

Permalink
Merge pull request #8039 from zhangguanzhang/runlabel-panic
Browse files Browse the repository at this point in the history
Fix panic when runlabel is missing
  • Loading branch information
openshift-merge-robot authored Oct 16, 2020
2 parents 9f98b34 + 97fec29 commit 9d5f28b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/domain/infra/abi/containers_runlabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func (ic *ContainerEngine) ContainerRunlabel(ctx context.Context, label string,
if err != nil {
return err
}
if runlabel == "" {
return errors.Errorf("cannot find the value of label: %s in image: %s", label, imageRef)
}

cmd, env, err := generateRunlabelCommand(runlabel, img, args, options)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/runlabel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ var _ = Describe("podman container runlabel", func() {
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", ALPINE})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
// should not panic when label missing the value or don't have the label
Expect(result.LineInOutputContains("panic")).NotTo(BeTrue())
})
It("podman container runlabel bogus label in remote image should result in non-zero exit", func() {
result := podmanTest.Podman([]string{"container", "runlabel", "RUN", "docker.io/library/ubuntu:latest"})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())

// should not panic when label missing the value or don't have the label
Expect(result.LineInOutputContains("panic")).NotTo(BeTrue())
})

It("podman container runlabel global options", func() {
Expand Down

0 comments on commit 9d5f28b

Please sign in to comment.