Skip to content

Commit

Permalink
fix (scheduler) : create asset subdir in run-input cmd & provide job_…
Browse files Browse the repository at this point in the history
…name environment variable to executors to maintain backward compatibility (#701)

* fix (scheduler) : create asset subdir in run-input cmd

* fix : add JOB_NAME in executor env

* fix : expected dag
  • Loading branch information
smarchint authored Jan 6, 2023
1 parent 200b4e5 commit 8d70686
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/cmd/scheduler/run_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ func (j *jobRunInputCommand) writeJobAssetsToFiles(
writeToFileFn := utils.WriteStringToFileIndexed()
for fileName, fileContent := range jobResponse.Files {
filePath := filepath.Join(dirPath, fileName)

assetSubDir := filepath.Dir(filePath)
if err := os.MkdirAll(assetSubDir, fs.FileMode(permission)); err != nil {
return fmt.Errorf("failed to create asset sub-directory at %s: %w", assetSubDir, err)
}

if err := writeToFileFn(filePath, fileContent, j.logger.Writer()); err != nil {
return fmt.Errorf("failed to write asset file at %s: %w", filePath, err)
}
Expand Down
1 change: 1 addition & 0 deletions ext/scheduler/airflow/dag/dag.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ asset_volume_mounts = [
executor_env_vars = [
k8s.V1EnvVar(name="JOB_LABELS", value='{{.JobDetails.GetLabelsAsString}}'),
k8s.V1EnvVar(name="JOB_DIR", value=JOB_DIR),
k8s.V1EnvVar(name="JOB_NAME", value='{{$.JobDetails.Name}}'),
]

init_env_vars = [
Expand Down
1 change: 1 addition & 0 deletions ext/scheduler/airflow/dag/expected_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
executor_env_vars = [
k8s.V1EnvVar(name="JOB_LABELS", value='orchestrator=optimus'),
k8s.V1EnvVar(name="JOB_DIR", value=JOB_DIR),
k8s.V1EnvVar(name="JOB_NAME", value='infra.billing.weekly-status-reports'),
]

init_env_vars = [
Expand Down

0 comments on commit 8d70686

Please sign in to comment.