Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Richerson <[email protected]>
  • Loading branch information
matthew-richerson committed Jan 13, 2025
1 parent 0de7851 commit 5e993f5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/controller/nnf_workflow_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ func (r *NnfWorkflowReconciler) startPreRunState(ctx context.Context, workflow *
}

func (r *NnfWorkflowReconciler) finishPreRunState(ctx context.Context, workflow *dwsv1alpha2.Workflow, index int) (*result, error) {

log := r.Log.WithValues("Workflow", client.ObjectKeyFromObject(workflow), "Index", index)
dwArgs, _ := dwdparse.BuildArgsMap(workflow.Spec.DWDirectives[index])

// Add an environment variable to the workflow status section for the location of the
Expand Down Expand Up @@ -979,7 +979,11 @@ func (r *NnfWorkflowReconciler) finishPreRunState(ctx context.Context, workflow
// Add an environment variable with a list of allocations "DW_JOBS=firstfs:/mnt/dw/path1,secondfs:/mnt/dw/path2"
found := false
listEnvValue, exists := workflow.Status.Env[listEnvName]
nameAndPathList := strings.Split(listEnvValue, ",")

splitFn := func(c rune) bool {
return c == ','
}
nameAndPathList := strings.FieldsFunc(listEnvValue, splitFn)
if exists {
for _, nameAndPath := range nameAndPathList {
if nameAndPath == fmt.Sprintf("%s:%s", dwArgs["name"], path) {
Expand All @@ -990,6 +994,8 @@ func (r *NnfWorkflowReconciler) finishPreRunState(ctx context.Context, workflow
}

if !found {
log.Info("list", "current", nameAndPathList, "new", fmt.Sprintf("%s:%s", dwArgs["name"], path), "together", strings.Join(append(nameAndPathList, fmt.Sprintf("%s:%s", dwArgs["name"], path)), ","))

workflow.Status.Env[listEnvName] = strings.Join(append(nameAndPathList, fmt.Sprintf("%s:%s", dwArgs["name"], path)), ",")
}

Expand Down

0 comments on commit 5e993f5

Please sign in to comment.