Skip to content

Commit 15a7671

Browse files
Release candidate: v1.96.0 (#5871)
2 parents 1047080 + 7684be6 commit 15a7671

180 files changed

Lines changed: 4699 additions & 806 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/deploy.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"hpc-toolkit/pkg/logging"
2222
"hpc-toolkit/pkg/modulewriter"
2323
"hpc-toolkit/pkg/shell"
24+
"hpc-toolkit/pkg/validators"
2425
"path/filepath"
2526

2627
"github.com/spf13/cobra"
@@ -65,13 +66,15 @@ func runDeployCmd(cmd *cobra.Command, args []string) {
6566
}
6667
})
6768
}
68-
doDeploy(deplRoot)
69+
skipSecurity, _ := cmd.Flags().GetBool("skip-gke-security-check")
70+
doDeploy(deplRoot, skipSecurity)
6971
}
7072

71-
func doDeploy(deplRoot string) {
73+
func doDeploy(deplRoot string, skipSecurity bool) {
7274
artDir := getArtifactsDir(deplRoot)
7375
checkErr(shell.CheckWritableDir(artDir), nil)
7476
bp, ctx := artifactBlueprintOrDie(artDir)
77+
validators.PerformGkeVulnerabilitiesCheck(skipSecurity, &bp)
7578
groups := bp.Groups
7679
checkErr(validateGroupSelectionFlags(bp), ctx)
7780
checkErr(validateRuntimeDependencies(deplRoot, groups), ctx)

cmd/job/submit.go

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"hpc-toolkit/pkg/config"
2020
"os"
2121
"path/filepath"
22+
"reflect"
23+
"regexp"
2224
"slices"
2325
"time"
2426

@@ -70,6 +72,12 @@ var (
7072

7173
gkeNapProvisioning string
7274
gkeNapReservation string
75+
76+
envVars []string
77+
pathwaysProxyEnv []string
78+
pathwaysServerEnv []string
79+
pathwaysWorkerEnv []string
80+
validEnvKeyRegex = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
7381
)
7482

7583
var SubmitCmd = &cobra.Command{
@@ -104,6 +112,12 @@ and JobSet/Kueue specific configurations like workload name, queue, nodes, and r
104112
return err
105113
}
106114

115+
for _, envs := range [][]string{envVars, pathwaysProxyEnv, pathwaysServerEnv, pathwaysWorkerEnv} {
116+
if err := validateEnvFlags(envs); err != nil {
117+
return err
118+
}
119+
}
120+
107121
priorityClassName = strings.ToLower(priorityClassName)
108122

109123
return nil
@@ -121,6 +135,7 @@ func init() {
121135
SubmitCmd.Flags().StringVarP(&platform, "platform", "f", "linux/amd64", "Target platform for the image build (e.g., 'linux/amd64', 'linux/arm64'). Used with --base-image.")
122136

123137
SubmitCmd.Flags().StringSliceVar(&volumeStr, "mount", nil, "Volumes to mount (format: <src>:<dest>[:<mode>], mode can be 'ro' or 'rw', default 'ro').")
138+
SubmitCmd.Flags().StringArrayVar(&envVars, "env", []string{}, "Custom environment variables to pass to the workload container in KEY=VALUE format. Can be specified multiple times.")
124139

125140
SubmitCmd.Flags().StringVarP(&workloadName, "name", "n", "", "Name of the workload to create. Required.")
126141
SubmitCmd.Flags().StringVarP(&kueueQueueName, "queue", "q", "", "Name of the Kueue LocalQueue to submit the workload to. If empty, it will be auto-discovered.")
@@ -157,6 +172,9 @@ func init() {
157172
SubmitCmd.Flags().StringVar(&pathways.ProxyArgs, "pathways-proxy-args", "", "Arbitrary additional command-line arguments to pass directly to the `pathways-proxy` executable.")
158173
SubmitCmd.Flags().StringVar(&pathways.ServerArgs, "pathways-server-args", "", "Arbitrary additional command-line arguments to pass directly to the `pathways-rm` (resource manager) executable.")
159174
SubmitCmd.Flags().StringVar(&pathways.WorkerArgs, "pathways-worker-args", "", "Arbitrary additional command-line arguments to pass directly to the `pathways-worker` executable.")
175+
SubmitCmd.Flags().StringArrayVar(&pathwaysProxyEnv, "pathways-proxy-env", []string{}, "Custom environment variables for the Pathways proxy container in KEY=VALUE format. Can be specified multiple times.")
176+
SubmitCmd.Flags().StringArrayVar(&pathwaysServerEnv, "pathways-server-env", []string{}, "Custom environment variables for the Pathways server container in KEY=VALUE format. Can be specified multiple times.")
177+
SubmitCmd.Flags().StringArrayVar(&pathwaysWorkerEnv, "pathways-worker-env", []string{}, "Custom environment variables for the Pathways worker container in KEY=VALUE format. Can be specified multiple times.")
160178
SubmitCmd.Flags().StringVar(&pathways.ColocatedPythonSidecarImage, "pathways-colocated-python-sidecar-image", "", "Image for an optional Python-based sidecar container to run alongside the Pathways head components.")
161179
SubmitCmd.Flags().StringVar(&pathways.HeadNodePool, "pathways-head-np", "", "The node pool to use for the Pathways head job. If empty, it will be auto-detected (looking for 'cpu-np' or 'pathways-np').")
162180

@@ -195,6 +213,12 @@ func runSubmitCmd(cmd *cobra.Command, args []string) error {
195213
return fmt.Errorf("--num-nodes cannot be used with TPU jobs (it is calculated automatically from topology)")
196214
}
197215

216+
jobTopology := strings.ToLower(strings.TrimSpace(topology))
217+
218+
pathways.ProxyEnv = parseEnvFlags(pathwaysProxyEnv)
219+
pathways.ServerEnv = parseEnvFlags(pathwaysServerEnv)
220+
pathways.WorkerEnv = parseEnvFlags(pathwaysWorkerEnv)
221+
198222
jobDef := orchestrator.JobDefinition{
199223
ImageName: imageName,
200224
BaseImage: baseImage,
@@ -219,7 +243,7 @@ func runSubmitCmd(cmd *cobra.Command, args []string) error {
219243
RestartOnExitCodes: restartOnExitCodes,
220244
ImagePullSecrets: imagePullSecrets,
221245
ServiceAccountName: serviceAccountName,
222-
Topology: topology,
246+
Topology: jobTopology,
223247
GKEScheduler: gkeScheduler,
224248
AwaitJobCompletion: awaitJobCompletion,
225249
UseParallelContainers: !gkeDisableParallelContainers,
@@ -230,12 +254,44 @@ func runSubmitCmd(cmd *cobra.Command, args []string) error {
230254
IsPathwaysJob: isPathwaysJob,
231255
Pathways: pathways,
232256
RawMounts: volumeStr,
257+
Env: parseEnvFlags(envVars),
233258
Verbose: verbose,
234259
}
235260

236261
return orc.SubmitJob(jobDef)
237262
}
238263

264+
func parseEnvFlags(envs []string) map[string]string {
265+
if len(envs) == 0 {
266+
return nil
267+
}
268+
res := make(map[string]string)
269+
for _, env := range envs {
270+
parts := strings.SplitN(env, "=", 2)
271+
if len(parts) == 2 {
272+
res[parts[0]] = parts[1]
273+
}
274+
}
275+
return res
276+
}
277+
278+
func validateEnvFlags(envs []string) error {
279+
for _, env := range envs {
280+
parts := strings.SplitN(env, "=", 2)
281+
if len(parts) != 2 {
282+
return fmt.Errorf("invalid environment variable format: %q. Must be in KEY=VALUE format", env)
283+
}
284+
key := parts[0]
285+
if key == "" {
286+
return fmt.Errorf("invalid environment variable key in %q: key cannot be empty", env)
287+
}
288+
if !validEnvKeyRegex.MatchString(key) {
289+
return fmt.Errorf("invalid environment variable name: %q. Must conform to POSIX environment variable naming rules (letters, numbers, and underscores, cannot start with a digit)", key)
290+
}
291+
}
292+
return nil
293+
}
294+
239295
func parseDurationToSeconds(dStr string, flagName string) (int, error) {
240296
d, err := time.ParseDuration(dStr)
241297
if err == nil {
@@ -257,7 +313,7 @@ func validatePathwaysFlags() error {
257313
}
258314
} else {
259315
// Check if any pathways-specific flag is set without --pathways
260-
if pathways != (orchestrator.PathwaysJobDefinition{MaxSliceRestarts: 1}) {
316+
if !reflect.DeepEqual(pathways, orchestrator.PathwaysJobDefinition{MaxSliceRestarts: 1}) || len(pathwaysProxyEnv) > 0 || len(pathwaysServerEnv) > 0 || len(pathwaysWorkerEnv) > 0 {
261317
return fmt.Errorf("pathways flags specified but --pathways flag is missing")
262318
}
263319
}

0 commit comments

Comments
 (0)