mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +08:00
Merge pull request #26643 from Luap99/rm-dead-conmon
podman rm: handle case where conmon was killed
This commit is contained in:
@ -1544,7 +1544,7 @@ func (c *Container) waitForConmonToExitAndSave() error {
|
||||
logrus.Errorf("Error cleaning up container %s after Conmon exited prematurely: %v", c.ID(), err)
|
||||
}
|
||||
|
||||
return fmt.Errorf("container %s conmon exited prematurely, exit code could not be retrieved: %w", c.ID(), define.ErrInternal)
|
||||
return fmt.Errorf("container %s conmon exited prematurely, exit code could not be retrieved: %w", c.ID(), define.ErrConmonDead)
|
||||
}
|
||||
|
||||
return c.save()
|
||||
|
@ -539,7 +539,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
|
||||
// ErrNoSuchCtr is non-fatal, other errors will be
|
||||
// treated as fatal.
|
||||
if errors.Is(err, define.ErrNoSuchCtr) {
|
||||
errs = append(errs, fmt.Errorf("no such container %s", name))
|
||||
errs = append(errs, fmt.Errorf("no such container %q", name))
|
||||
continue
|
||||
}
|
||||
return nil, nil, err
|
||||
@ -550,7 +550,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
|
||||
// ErrNoSuchCtr is non-fatal, other errors will be
|
||||
// treated as fatal.
|
||||
if errors.Is(err, define.ErrNoSuchCtr) {
|
||||
errs = append(errs, fmt.Errorf("no such container %s", name))
|
||||
errs = append(errs, fmt.Errorf("no such container %q", name))
|
||||
continue
|
||||
}
|
||||
return nil, nil, err
|
||||
|
@ -188,11 +188,7 @@ var _ = Describe("Podman inspect", func() {
|
||||
|
||||
ctrInspect := podmanTest.Podman([]string{"container", "inspect", ALPINE})
|
||||
ctrInspect.WaitWithDefaultTimeout()
|
||||
if IsRemote() {
|
||||
Expect(ctrInspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", ALPINE)))
|
||||
} else {
|
||||
Expect(ctrInspect).To(ExitWithError(125, fmt.Sprintf("no such container %s", ALPINE)))
|
||||
}
|
||||
Expect(ctrInspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", ALPINE)))
|
||||
|
||||
imageInspect := podmanTest.Podman([]string{"image", "inspect", ALPINE})
|
||||
imageInspect.WaitWithDefaultTimeout()
|
||||
@ -399,11 +395,7 @@ var _ = Describe("Podman inspect", func() {
|
||||
|
||||
inspect := podmanTest.Podman([]string{"inspect", "--type", "container", podName})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
if IsRemote() {
|
||||
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", podName)))
|
||||
} else {
|
||||
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("no such container %s", podName)))
|
||||
}
|
||||
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", podName)))
|
||||
})
|
||||
|
||||
It("podman inspect --type network on a container should fail", func() {
|
||||
|
@ -1778,7 +1778,7 @@ search | $IMAGE |
|
||||
# Unclear why `-t0` is required here, works locally without.
|
||||
# But it shouldn't hurt and does make the test pass...
|
||||
PODMAN_TIMEOUT=5 run_podman 125 stop -t0 $cname
|
||||
is "$output" "Error: container .* conmon exited prematurely, exit code could not be retrieved: internal libpod error" "correct error on missing conmon"
|
||||
is "$output" "Error: container .* conmon exited prematurely, exit code could not be retrieved: conmon process killed" "correct error on missing conmon"
|
||||
|
||||
# This should be safe because stop is guaranteed to call cleanup?
|
||||
run_podman inspect --format "{{ .State.Status }}" $cname
|
||||
|
@ -202,4 +202,20 @@ function __run_healthcheck_container() {
|
||||
die "Container never entered 'stopping' state"
|
||||
}
|
||||
|
||||
# bats test_tags=ci:parallel
|
||||
@test "podman rm after killed conmon" {
|
||||
cname=c_$(safename)
|
||||
run_podman run -d --name $cname $IMAGE sleep 1000
|
||||
|
||||
run_podman inspect --format '{{ .State.ConmonPid }}' $cname
|
||||
conmon_pid=$output
|
||||
|
||||
kill -9 ${conmon_pid}
|
||||
|
||||
run_podman rm -f -t0 $cname
|
||||
|
||||
run_podman 125 container inspect $cname
|
||||
assert "$output" =~ "no such container \"$cname\"" "Container should be removed"
|
||||
}
|
||||
|
||||
# vim: filetype=sh
|
||||
|
@ -1081,7 +1081,7 @@ EOF
|
||||
is "$output" "$exit_code_prop" \
|
||||
"$basename: service container has the expected policy set in its annotations"
|
||||
else
|
||||
assert "$output" =~ "no such container $service_container" \
|
||||
assert "$output" =~ "no such container \"$service_container\"" \
|
||||
"$basename: unexpected error from podman container inspect"
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user