Skip to content

Commit

Permalink
SDK/DSL: ContainerOp.add_pvolume - Fix volume passed in add_volume (#…
Browse files Browse the repository at this point in the history
…2306)

Signed-off-by: Ilias Katsakioris <elikatsis@arrikto.com>
  • Loading branch information
elikatsis authored and k8s-ci-robot committed Oct 5, 2019
1 parent ed285ce commit a77d8e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sdk/python/kfp/dsl/_container_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,8 @@ def add_pvolumes(self,
self.dependent_names.extend(pvolume.dependent_names)
else:
pvolume = PipelineVolume(volume=pvolume)
self.pvolumes[mount_path] = pvolume.after(self)
pvolume = pvolume.after(self)
self.pvolumes[mount_path] = pvolume
self.add_volume(pvolume)
self._container.add_volume_mount(V1VolumeMount(
name=pvolume.name,
Expand Down
11 changes: 10 additions & 1 deletion sdk/python/tests/dsl/container_op_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from kubernetes.client.models import V1EnvVar, V1VolumeMount

import kfp
from kfp.dsl import ContainerOp, UserContainer, Sidecar
from kfp.dsl import ContainerOp, UserContainer, Sidecar, PipelineVolume


class TestContainerOp(unittest.TestCase):
Expand Down Expand Up @@ -89,3 +89,12 @@ def test_deprecation_warnings(self):
op.add_volume_mount(V1VolumeMount(
mount_path='/secret/gcp-credentials',
name='gcp-credentials'))


def test_add_pvolumes(self):
pvolume = PipelineVolume(pvc='test')
op = ContainerOp(name='op1', image='image', pvolumes={'/mnt': pvolume})

self.assertEqual(pvolume.dependent_names, [])
self.assertEqual(op.pvolume.dependent_names, [op.name])
self.assertEqual(op.volumes[0].dependent_names, [op.name])

0 comments on commit a77d8e9

Please sign in to comment.