Skip to content

Commit

Permalink
fixup: workflow postcondition
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Cassolato <[email protected]>
  • Loading branch information
guicassolato committed Jul 24, 2024
1 parent 1b6c378 commit 16fd7a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controller/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ func (d *Workflow) Run(ctx context.Context, resourceEvent ResourceEvent, topolog
// dispatch the event to concurrent tasks
funcs := d.Tasks
waitGroup := &sync.WaitGroup{}
defer waitGroup.Wait()
waitGroup.Add(len(funcs))
for _, f := range funcs {
go func() {
defer waitGroup.Done()
f(ctx, resourceEvent, topology)
}()
}
waitGroup.Wait()

// run precondition reconcile function
if d.Postcondition != nil {
Expand Down
6 changes: 2 additions & 4 deletions examples/kuadrant/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ func buildReconciler(gatewayProviders []string, client *dynamic.DynamicClient) c
}
},
Tasks: []controller.CallbackFunc{
(&controller.Workflow{
Precondition: (&reconcilers.TopologyFileReconciler{}).Reconcile, // Graphiz frees the memory that might be simutanously used by the reconcilers, so this needs to run in a precondition
Tasks: []controller.CallbackFunc{effectivePolicyReconciler.Reconcile},
}).Run,
effectivePolicyReconciler.Reconcile,
},
Postcondition: (&reconcilers.TopologyFileReconciler{}).Reconcile, // Graphiz frees the memory that might be simutanously used by the reconcilers, so this needs to run in a precondition
}

return reconciler.Run
Expand Down

0 comments on commit 16fd7a5

Please sign in to comment.