Merge pull request #16697 from rhatdan/pod

stop reporting errors removing containers that don't exist
This commit is contained in:
OpenShift Merge Robot
2022-12-15 03:35:46 -05:00
committed by GitHub
2 changed files with 33 additions and 5 deletions

View File

@ -44,10 +44,6 @@ func (p *Pod) startInitContainers(ctx context.Context) error {
icLock.Unlock()
return fmt.Errorf("failed to remove once init container %s: %w", initCon.ID(), err)
}
// Removing a container this way requires an explicit call to clean up the db
if err := p.runtime.state.RemoveContainerFromPod(p, initCon); err != nil {
logrus.Errorf("Removing container %s from database: %v", initCon.ID(), err)
}
icLock.Unlock()
}
}

View File

@ -207,7 +207,7 @@ EOF
run_podman container inspect --format "{{.HostConfig.NetworkMode}}" $infraID
is "$output" "none" "network mode none is set for the container"
run_podman kube down - < $PODMAN_TMPDIR/test.yaml
run_podman kube down $PODMAN_TMPDIR/test.yaml
run_podman 125 inspect test_pod-test
is "$output" ".*Error: inspecting object: no such object: \"test_pod-test\""
run_podman pod rm -a
@ -436,6 +436,38 @@ status: {}
run_podman rm -f -t0 myyaml
}
@test "podman play with init container" {
TESTDIR=$PODMAN_TMPDIR/testdir
mkdir -p $TESTDIR
testUserYaml="
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- command:
- ls
- /dev/shm/test1
image: $IMAGE
name: testCtr
initContainers:
- command:
- touch
- /dev/shm/test1
image: $IMAGE
name: initCtr
"
echo "$testUserYaml" > $PODMAN_TMPDIR/test.yaml
run_podman kube play $PODMAN_TMPDIR/test.yaml
assert "$output" !~ "level=" "init containers should not generate logrus.Error"
run_podman inspect --format "{{.State.ExitCode}}" pod-testCtr
is "$output" "0" "init container should have created /dev/shm/test1"
run_podman kube down $PODMAN_TMPDIR/test.yaml
}
@test "podman kube play - hostport" {
HOST_PORT=$(random_free_port)
echo "