diff --git a/pkg/core/workflow_execute.go b/pkg/core/workflow_execute.go index 2d789ffa4..4ec592d6a 100644 --- a/pkg/core/workflow_execute.go +++ b/pkg/core/workflow_execute.go @@ -27,34 +27,24 @@ func (e *Engine) executeWorkflow(ctx *scan.ScanContext, w *workflows.Workflow) b // we can know the nesting level only at runtime, so the best we can do here is increase template threads by one unit in case it's equal to 1 to allow // at least one subtemplate to go through, which it's idempotent to one in-flight template as the parent one is in an idle state - templateThreads := w.Options.Options.TemplateThreads if templateThreads == 1 { templateThreads++ } - - runWorkflowStep := func(template *workflows.WorkflowTemplate, ctx *scan.ScanContext, results *atomic.Bool, swg *syncutil.AdaptiveWaitGroup, w *workflows.Workflow) { - if err := e.runWorkflowStep(template, ctx, results, swg, w); err != nil { - gologger.Warning().Msgf(workflowStepExecutionError, template.Template, err) - } - } - swg, _ := syncutil.New(syncutil.WithSize(templateThreads)) for _, template := range w.Workflows { - if w.Mode == "sequential" { - runWorkflowStep(template, ctx, results, swg, w) - } else { - swg.Add() - go func(template *workflows.WorkflowTemplate) { - defer swg.Done() - newCtx := scan.NewScanContext(ctx.Context(), ctx.Input.Clone()) - runWorkflowStep(template, newCtx, results, swg, w) - }(template) - } + swg.Add() + + go func(template *workflows.WorkflowTemplate) { + defer swg.Done() + newCtx := scan.NewScanContext(ctx.Context(), ctx.Input.Clone()) + if err := e.runWorkflowStep(template, newCtx, results, swg, w); err != nil { + gologger.Warning().Msgf(workflowStepExecutionError, template.Template, err) + } + }(template) } swg.Wait() - return results.Load() } diff --git a/pkg/workflows/workflows.go b/pkg/workflows/workflows.go index bb8b308fa..5f41329ab 100644 --- a/pkg/workflows/workflows.go +++ b/pkg/workflows/workflows.go @@ -11,12 +11,6 @@ import ( // Workflow is a workflow to execute with chained requests, etc. type Workflow struct { - // description: | - // Mode to execute workflow (default: "concurrent"). - // values: - // - empty|concurrent (default) - // - sequential - Mode string `yaml:"mode,omitempty" json:"mode,omitempty" jsonschema:"title=mode to execute workflow,description=Mode to execute workflow,enum=concurrent,enum=sequential"` // description: | // Workflows is a list of workflows to execute for a template. Workflows []*WorkflowTemplate `yaml:"workflows,omitempty" json:"workflows,omitempty" jsonschema:"title=list of workflows to execute,description=List of workflows to execute for template"`