Skip to content

Commit bdb43e7

Browse files
author
vmridul
committed
feat(backend): add subPath support for PVC mounts
Signed-off-by: vmridul <vermamridul1302@gmail.com>
1 parent ffbd69f commit bdb43e7

File tree

19 files changed

+208
-195
lines changed

19 files changed

+208
-195
lines changed

.github/workflows/trivy-cache.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/trivy.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,16 @@ jobs:
1313
uses: actions/checkout@v4
1414

1515
- name: Run Trivy vulnerability scanner in repo mode
16-
uses: aquasecurity/trivy-action@0.33.1
16+
uses: aquasecurity/trivy-action@0.28.0
1717
with:
1818
scan-type: 'fs'
1919
ignore-unfixed: true
2020
format: 'sarif'
2121
output: 'trivy-results.sarif'
2222
severity: 'CRITICAL,HIGH'
2323
skip-dirs: 'components'
24-
env:
25-
# Use ECR instead of GitHub Container Registry to avoid rate limiting.
26-
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
27-
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
28-
TRIVY_SKIP_DB_UPDATE: true
29-
TRIVY_SKIP_JAVA_DB_UPDATE: true
3024

3125
- name: Upload Trivy scan results to GitHub Security tab
32-
uses: github/codeql-action/upload-sarif@v4
26+
uses: github/codeql-action/upload-sarif@v3
3327
with:
3428
sarif_file: 'trivy-results.sarif'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Workflow Linter
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
- 'release-*'
7+
8+
pull_request:
9+
paths:
10+
- '.github/workflows/**'
11+
12+
jobs:
13+
actionlint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
# actionlint requires Go to run.
20+
- name: Setup Go 🛠️
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.24.7' # Use a recent, supported Go version
24+
25+
- name: Install actionlint
26+
run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
27+
28+
# actionlint automatically finds all workflow files in .github/workflows/
29+
- name: Run actionlint
30+
run: actionlint -color

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,3 @@ repos:
7373
language: golang
7474
require_serial: true
7575
pass_filenames: false
76-
- repo: https://github.com/rhysd/actionlint
77-
rev: v1.7.9
78-
hooks:
79-
- id: actionlint
80-
types: ["yml", "yaml"]

backend/metadata_writer/src/metadata_writer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import collections
2020
import kubernetes
2121
import yaml
22+
import urllib3
2223
from time import sleep
2324
import lru
2425

@@ -399,9 +400,7 @@ def is_kfp_v2_pod(pod) -> bool:
399400
# If the for loop ended, a server-side timeout occurred. Continue watching.
400401
pass
401402

402-
except Exception as e:
403-
# Handle any errors, print stack trace, and continue watching.
404-
import traceback
405-
print(traceback.format_exc())
403+
except urllib3.exceptions.ReadTimeoutError as e:
404+
# Client side timeout, continue watching.
406405
continue
407406

backend/src/apiserver/server/run_server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ func (s *RunServerV1) ReportRunMetricsV1(ctx context.Context, request *apiv1beta
460460
return &apiv1beta1.ReportRunMetricsResponse{Results: apiResults}, nil
461461
}
462462

463+
463464
// Terminates a run.
464465
// Applies common logic on v1beta1 and v2beta1 API.
465466
func (s *BaseRunServer) terminateRun(ctx context.Context, runId string) error {
@@ -604,6 +605,7 @@ func (s *RunServer) DeleteRun(ctx context.Context, request *apiv2beta1.DeleteRun
604605
return &emptypb.Empty{}, nil
605606
}
606607

608+
607609
// Terminates a run.
608610
// Supports v2beta1 behavior.
609611
func (s *RunServer) TerminateRun(ctx context.Context, request *apiv2beta1.TerminateRunRequest) (*emptypb.Empty, error) {

backend/src/apiserver/server/run_server_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ func TestCanAccessRun_Unauthenticated(t *testing.T) {
14791479
)
14801480
}
14811481

1482+
14821483
func TestRetryRun(t *testing.T) {
14831484
clients, manager, experiment := initWithExperiment(t)
14841485
defer clients.Close()

backend/src/apiserver/template/v2_template.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ func (t *V2Spec) ScheduledWorkflow(modelJob *model.Job) (*scheduledworkflow.Sche
105105
return nil, util.Wrap(err, "Failed to convert runtime config")
106106
}
107107
job.RuntimeConfig = jobRuntimeConfig
108-
109-
// Parameter macros like [[CurrentTime]], [[RunUUID]], [[ScheduledTime]], [[Index]] are not formatted here.
110-
// They remain unformatted in the ScheduledWorkflow spec and will be formatted by the scheduled workflow controller
111108
if err = t.validatePipelineJobInputs(job); err != nil {
112109
return nil, util.Wrap(err, "invalid pipeline job inputs")
113110
}
@@ -319,37 +316,6 @@ func (t *V2Spec) RunWorkflow(modelRun *model.Run, options RunWorkflowOptions) (u
319316
return nil, util.NewInternalServerError(err, "Failed to convert to PipelineJob RuntimeConfig")
320317
}
321318
job.RuntimeConfig = jobRuntimeConfig
322-
323-
// Format parameters to expand macros like [[CurrentTime]], [[RunUUID]], [[ScheduledTime]], [[Index]] (V1 forward compatibility).
324-
// Uses NewSWFParameterFormatter to support all macros. For standalone runs, [[ScheduledTime]] and [[Index]] remain unformatted
325-
326-
if job.RuntimeConfig != nil && len(job.RuntimeConfig.GetParameterValues()) > 0 {
327-
scheduledEpoch := int64(-1) // disabled by default
328-
329-
if modelRun.ScheduledAtInSec > 0 {
330-
scheduledEpoch = modelRun.ScheduledAtInSec
331-
}
332-
formatter := util.NewSWFParameterFormatter(
333-
options.RunID,
334-
scheduledEpoch,
335-
options.RunAt,
336-
-1,
337-
)
338-
// Convert structpb.Value to strings, format, convert back
339-
paramValues := job.RuntimeConfig.GetParameterValues()
340-
stringParams := make(map[string]string)
341-
for key, val := range paramValues {
342-
if strVal := val.GetStringValue(); strVal != "" {
343-
stringParams[key] = strVal
344-
}
345-
}
346-
// Format the string parameters
347-
formattedParams := formatter.FormatWorkflowParameters(stringParams)
348-
// Convert formatted strings back to structpb.Value
349-
for key, formattedVal := range formattedParams {
350-
paramValues[key] = structpb.NewStringValue(formattedVal)
351-
}
352-
}
353319
if err = t.validatePipelineJobInputs(job); err != nil {
354320
return nil, util.Wrap(err, "invalid pipeline job inputs")
355321
}

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 {
@@ -100,6 +122,7 @@ func Test_makeVolumeMountPatch(t *testing.T) {
100122
assert.Equal(t, volumeMounts[0].Name, tt.wantName)
101123
assert.Equal(t, volumes[0].Name, tt.wantName)
102124
assert.Equal(t, volumes[0].PersistentVolumeClaim.ClaimName, tt.wantName)
125+
assert.Equal(t, volumeMounts[0].SubPath, tt.wantSubPath)
103126
})
104127
}
105128
}

0 commit comments

Comments
 (0)