Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

play.go: remove volumes with kube down --force #18814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/domain/infra/abi/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions test/e2e/play_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
danishprakash marked this conversation as resolved.
Show resolved Hide resolved
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() {
Expand Down