mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
play.go: remove volumes on down -f
* add e2e test Signed-off-by: danishprakash <danish.prakash@suse.com>
This commit is contained in:
@ -1343,6 +1343,17 @@ func (ic *ContainerEngine) PlayKubeDown(ctx context.Context, body io.Reader, opt
|
||||
return nil, fmt.Errorf("unable to read YAML as Kube Pod: %w", err)
|
||||
}
|
||||
podNames = append(podNames, podYAML.ObjectMeta.Name)
|
||||
|
||||
for _, vol := range podYAML.Spec.Volumes {
|
||||
switch vs := vol.VolumeSource; {
|
||||
case vs.PersistentVolumeClaim != nil:
|
||||
volumeNames = append(volumeNames, vs.PersistentVolumeClaim.ClaimName)
|
||||
case vs.ConfigMap != nil:
|
||||
volumeNames = append(volumeNames, vs.ConfigMap.Name)
|
||||
case vs.Secret != nil:
|
||||
volumeNames = append(volumeNames, vs.Secret.SecretName)
|
||||
}
|
||||
}
|
||||
case "Deployment":
|
||||
var deploymentYAML v1apps.Deployment
|
||||
|
||||
|
@ -4984,6 +4984,19 @@ spec:
|
||||
exec.WaitWithDefaultTimeout()
|
||||
Expect(exec).Should(Exit(0))
|
||||
Expect(exec.OutputToString()).Should(Equal("hi"))
|
||||
|
||||
teardown := podmanTest.Podman([]string{"kube", "down", "--force", kubeYaml})
|
||||
teardown.WaitWithDefaultTimeout()
|
||||
Expect(teardown).Should(Exit(0))
|
||||
Expect(teardown.OutputToString()).Should(ContainSubstring("testvol"))
|
||||
|
||||
// kube down --force should remove volumes
|
||||
// specified in the manifest but not externally
|
||||
// created volumes, testvol1 in this case
|
||||
checkVol := podmanTest.Podman([]string{"volume", "ls", "--format", "{{.Name}}"})
|
||||
checkVol.WaitWithDefaultTimeout()
|
||||
Expect(checkVol).Should(Exit(0))
|
||||
Expect(checkVol.OutputToString()).To(Equal("testvol1"))
|
||||
})
|
||||
|
||||
It("podman play kube with hostPath subpaths", func() {
|
||||
|
Reference in New Issue
Block a user