Skip to content

Commit 3a96f57

Browse files
author
vmridul
committed
feat(backend): add PVC subPath support to backend
Signed-off-by: vmridul <[email protected]>
1 parent ffbd69f commit 3a96f57

File tree

7 files changed

+121
-52
lines changed

7 files changed

+121
-52
lines changed

backend/src/v2/driver/k8s.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,12 +1011,14 @@ func makeVolumeMountPatch(
10111011
pvcName := resolvedPvcName.GetStringValue()
10121012

10131013
pvcMountPath := pvcMount.GetMountPath()
1014+
pvcSubPath := pvcMount.GetSubPath()
10141015
if pvcName == "" || pvcMountPath == "" {
10151016
return nil, nil, fmt.Errorf("failed to mount volume, missing mountpath or pvc name")
10161017
}
10171018
volumeMount := k8score.VolumeMount{
10181019
Name: pvcName,
10191020
MountPath: pvcMountPath,
1021+
SubPath: pvcSubPath,
10201022
}
10211023
volume := k8score.Volume{
10221024
Name: pvcName,

backend/src/v2/driver/k8s_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
2727
args args
2828
wantPath string
2929
wantName string
30+
wantSubPath string
3031
inputParams map[string]*structpb.Value
3132
}{
3233
{
@@ -43,6 +44,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
4344
},
4445
"/mnt/path",
4546
"pvc-name",
47+
"",
4648
nil,
4749
},
4850
{
@@ -60,6 +62,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
6062
},
6163
"/mnt/path",
6264
"pvc-name",
65+
"",
6366
nil,
6467
},
6568
{
@@ -76,10 +79,29 @@ func Test_makeVolumeMountPatch(t *testing.T) {
7679
},
7780
"/mnt/path",
7881
"pvc-name",
82+
"",
7983
map[string]*structpb.Value{
8084
"param_1": structpb.NewStringValue("pvc-name"),
8185
},
8286
},
87+
{
88+
"pvc with subPath",
89+
args{
90+
[]*kubernetesplatform.PvcMount{
91+
{
92+
MountPath: "/mnt/path",
93+
SubPath: "logs/experiment1",
94+
PvcNameParameter: inputParamConstant("pvc-name"),
95+
},
96+
},
97+
nil,
98+
nil,
99+
},
100+
"/mnt/path",
101+
"pvc-name",
102+
"logs/experiment1",
103+
nil,
104+
},
83105
}
84106

85107
for _, tt := range tests {
@@ -98,6 +120,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
98120
assert.Equal(t, 1, len(volumes))
99121
assert.Equal(t, volumeMounts[0].MountPath, tt.wantPath)
100122
assert.Equal(t, volumeMounts[0].Name, tt.wantName)
123+
assert.Equal(t, volumeMounts[0].SubPath, tt.wantSubPath)
101124
assert.Equal(t, volumes[0].Name, tt.wantName)
102125
assert.Equal(t, volumes[0].PersistentVolumeClaim.ClaimName, tt.wantName)
103126
})

kubernetes_platform/go/kubernetesplatform/kubernetes_executor_config.pb.go

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kubernetes_platform/proto/kubernetes_executor_config.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ message PvcMount {
9595

9696
// Name of the PVC.
9797
ml_pipelines.TaskInputsSpec.InputParameterSpec pvc_name_parameter = 5;
98+
99+
// Optional subPath inside the PVC to mount (instead of mounting the volume root).
100+
string sub_path = 6;
98101
}
99102

100103
message CreatePvc {

0 commit comments

Comments
 (0)