-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
add support for subpath in play kube for named volumes #16803
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,28 @@ spec: | |
- containerPort: 80 | ||
` | ||
|
||
var subpathTest = ` | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: testpod | ||
spec: | ||
containers: | ||
- name: testctr | ||
image: quay.io/libpod/alpine_nginx:latest | ||
command: | ||
- sleep | ||
- inf | ||
volumeMounts: | ||
- mountPath: /var | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work with other types of volume mount? HostPath for example? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in this PR, probably won't be too hard though. I think I just need to edit all of the appropriate specgen structs. |
||
name: testing | ||
subPath: testing/onlythis | ||
volumes: | ||
- name: testing | ||
persistentVolumeClaim: | ||
claimName: testvol | ||
` | ||
|
||
var checkInfraImagePodYaml = ` | ||
apiVersion: v1 | ||
kind: Pod | ||
|
@@ -4460,4 +4482,39 @@ spec: | |
Expect(ps.OutputToStringArray()).To(HaveLen(0)) | ||
}) | ||
|
||
It("podman play kube with named volume subpaths", func() { | ||
SkipIfRemote("volume export does not exist on remote") | ||
volumeCreate := podmanTest.Podman([]string{"volume", "create", "testvol1"}) | ||
volumeCreate.WaitWithDefaultTimeout() | ||
Expect(volumeCreate).Should(Exit(0)) | ||
|
||
session := podmanTest.Podman([]string{"run", "--volume", "testvol1:/data", ALPINE, "sh", "-c", "mkdir -p /data/testing/onlythis && touch /data/testing/onlythis/123.txt && echo hi >> /data/testing/onlythis/123.txt"}) | ||
session.WaitWithDefaultTimeout() | ||
Expect(session).Should(Exit(0)) | ||
|
||
tar := filepath.Join(podmanTest.TempDir, "out.tar") | ||
session = podmanTest.Podman([]string{"volume", "export", "--output", tar, "testvol1"}) | ||
session.WaitWithDefaultTimeout() | ||
Expect(session).Should(Exit(0)) | ||
|
||
volumeCreate = podmanTest.Podman([]string{"volume", "create", "testvol"}) | ||
volumeCreate.WaitWithDefaultTimeout() | ||
Expect(volumeCreate).Should(Exit(0)) | ||
|
||
volumeImp := podmanTest.Podman([]string{"volume", "import", "testvol", filepath.Join(podmanTest.TempDir, "out.tar")}) | ||
volumeImp.WaitWithDefaultTimeout() | ||
Expect(volumeImp).Should(Exit(0)) | ||
|
||
err = writeYaml(subpathTest, kubeYaml) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
playKube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) | ||
playKube.WaitWithDefaultTimeout() | ||
Expect(playKube).Should(Exit(0)) | ||
|
||
exec := podmanTest.Podman([]string{"exec", "-it", "testpod-testctr", "cat", "/var/123.txt"}) | ||
exec.WaitWithDefaultTimeout() | ||
Expect(exec).Should(Exit(0)) | ||
Expect(exec.OutputToString()).Should(Equal("hi")) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be stored? Or is this only in effect for the length of the
kube play
? Not sure this needs to be plumbed this deeply?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does since in generateSpec (which play kube eventually calls) we use
ContainerNamedVolume
to generate the mountpoint and we need to subpath to get the source properly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just put the full path (path + subpath) into the named volume as Path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait, I see the problem there, different containers will want to index into the volume at different places.