Skip to content

Commit

Permalink
Merge pull request containers#20832 from openshift-cherrypick-robot/c…
Browse files Browse the repository at this point in the history
…herry-pick-20744-to-v4.8

[v4.8] If API calls for kube play --replace, then replace pod
  • Loading branch information
openshift-merge-bot[bot] authored Nov 30, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents e3bd1e0 + a62b81d commit 0f81579
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/domain/infra/abi/play.go
Original file line number Diff line number Diff line change
@@ -714,6 +714,11 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
podSpec.PodSpecGen.ServiceContainerID = serviceContainer.ID()
}

if options.Replace {
if _, err := ic.PodRm(ctx, []string{podName}, entities.PodRmOptions{Force: true, Ignore: true}); err != nil {
return nil, nil, fmt.Errorf("replacing pod %v: %w", podName, err)
}
}
// Create the Pod
pod, err := generate.MakePod(&podSpec, ic.Libpod)
if err != nil {
7 changes: 7 additions & 0 deletions test/apiv2/80-kube.at
Original file line number Diff line number Diff line change
@@ -48,6 +48,13 @@ t POST libpod/kube/play $YAML 200 \
.Pods[0].ContainerErrors=null \
.Pods[0].Containers[0]~[0-9a-f]\\{64\\}

t POST libpod/kube/play $YAML 500

t POST 'libpod/kube/play?replace=true' $YAML 200 \
.Pods[0].ID~[0-9a-f]\\{64\\} \
.Pods[0].ContainerErrors=null \
.Pods[0].Containers[0]~[0-9a-f]\\{64\\}

t DELETE libpod/kube/play $YAML 200 \
.StopReport[0].Id~[0-9a-f]\\{64\\} \
.RmReport[0].Id~[0-9a-f]\\{64\\}

0 comments on commit 0f81579

Please sign in to comment.