Skip to content

Commit

Permalink
Merge pull request #138 from grycap/dev-srisco
Browse files Browse the repository at this point in the history
Add RESOURCE_ID environment variable
  • Loading branch information
srisco authored Apr 11, 2022
2 parents bd81f4e + ac48be7 commit 59435f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/handlers/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ func MakeJobHandler(cfg *types.Config, kubeClientset *kubernetes.Clientset, back
Value: jobUUID,
}

// Make RESOURCE_ID envVar
resourceIDVar := v1.EnvVar{
Name: "RESOURCE_ID",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: "spec.nodeName",
},
},
}

// Get podSpec from the service
podSpec, err := service.ToPodSpec(cfg)
if err != nil {
Expand All @@ -103,6 +113,7 @@ func MakeJobHandler(cfg *types.Config, kubeClientset *kubernetes.Clientset, back
podSpec.Containers[i].Args = []string{"-c", fmt.Sprintf("echo $%s | %s", types.EventVariable, service.GetSupervisorPath())}
podSpec.Containers[i].Env = append(podSpec.Containers[i].Env, event)
podSpec.Containers[i].Env = append(podSpec.Containers[i].Env, jobUUIDVar)
podSpec.Containers[i].Env = append(podSpec.Containers[i].Env, resourceIDVar)
}
}

Expand Down

0 comments on commit 59435f4

Please sign in to comment.