mirror of
https://github.com/containers/podman.git
synced 2025-06-27 21:50:18 +08:00
Merge pull request #18086 from umohnani8/detach
Properly remove the service container during kube down
This commit is contained in:
@ -1343,6 +1343,23 @@ func (ic *ContainerEngine) PlayKubeDown(ctx context.Context, body io.Reader, opt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the service containers associated with the pods if any
|
||||||
|
serviceCtrIDs := []string{}
|
||||||
|
for _, name := range podNames {
|
||||||
|
pod, err := ic.Libpod.LookupPod(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ctr, err := pod.ServiceContainer()
|
||||||
|
if errors.Is(err, define.ErrNoSuchCtr) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
serviceCtrIDs = append(serviceCtrIDs, ctr.ID())
|
||||||
|
}
|
||||||
|
|
||||||
// Add the reports
|
// Add the reports
|
||||||
reports.StopReport, err = ic.PodStop(ctx, podNames, entities.PodStopOptions{})
|
reports.StopReport, err = ic.PodStop(ctx, podNames, entities.PodStopOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1368,10 +1385,12 @@ func (ic *ContainerEngine) PlayKubeDown(ctx context.Context, body io.Reader, opt
|
|||||||
|
|
||||||
// Remove the service container to ensure it is removed before we return for the remote case
|
// Remove the service container to ensure it is removed before we return for the remote case
|
||||||
// Needed for the clean up with podman kube play --wait in the remote case
|
// Needed for the clean up with podman kube play --wait in the remote case
|
||||||
if reports.ServiceContainerID != "" {
|
if len(serviceCtrIDs) > 0 {
|
||||||
_, err = ic.ContainerRm(ctx, []string{reports.ServiceContainerID}, entities.RmOptions{})
|
for _, ctrID := range serviceCtrIDs {
|
||||||
if err != nil && !errors.Is(err, define.ErrNoSuchCtr) {
|
_, err = ic.ContainerRm(ctx, []string{ctrID}, entities.RmOptions{})
|
||||||
return nil, err
|
if err != nil && !errors.Is(err, define.ErrNoSuchCtr) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user