Skip to content
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

Fix panic when runlabel is missing #8039

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/domain/infra/abi/containers_runlabel.go
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
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