fix(controlplane): playbook dispatch resolves and caches per the task's org
Issue: archie-core-5t4z7
This commit is contained in:
2 files changed
+31
-17
No files matched your search
@@ -196,7 +196,7 @@ type Daemon struct {
|
||||
// Playbooks are the loaded EDA playbooks, consulted before kind/label
|
||||
// bindings when pinning a workflow. Nil means none.
|
||||
Playbooks interface {
|
||||
Dispatch(playbook.DispatchInput) (playbook.Decision, bool)
|
||||
Dispatch(context.Context, playbook.DispatchInput) (playbook.Decision, bool)
|
||||
Run(context.Context, storecontract.PlaybookDispatcher, *slog.Logger, playbook.DispatchInput) error
|
||||
}
|
||||
// PlaybookLedger is the at-most-once gate action playbooks run through.
|
||||
@@ -2132,11 +2132,11 @@ func (d *Daemon) runActionPlaybooks(ctx context.Context, task *workflow.Task) {
|
||||
|
||||
// resolveWorkflowID picks the definition to pin: a matching playbook, then
|
||||
// the kind defaults. A task already naming a workflow keeps it.
|
||||
func (d *Daemon) resolveWorkflowID(task *workflow.Task, available map[string]struct{}) (string, error) {
|
||||
func (d *Daemon) resolveWorkflowID(ctx context.Context, task *workflow.Task, available map[string]struct{}) (string, error) {
|
||||
if d.Playbooks == nil || task.Workflow != "" {
|
||||
return workflow.ResolveWorkflowID(task, available)
|
||||
}
|
||||
decision, matched := d.Playbooks.Dispatch(playbookInput(task))
|
||||
decision, matched := d.Playbooks.Dispatch(ctx, playbookInput(task))
|
||||
if !matched {
|
||||
return workflow.ResolveWorkflowID(task, available)
|
||||
}
|
||||
@@ -2181,7 +2181,7 @@ func (d *Daemon) pinWorkflowFromCollection(ctx context.Context, task *workflow.T
|
||||
for _, definition := range collection.Definitions {
|
||||
available[definition.ID] = struct{}{}
|
||||
}
|
||||
id, err := d.resolveWorkflowID(task, available)
|
||||
id, err := d.resolveWorkflowID(ctx, task, available)
|
||||
if err != nil {
|
||||
return pinFailure{taskstate.ParkNeedsHuman, err}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user