From d4bf6fc6bb167a93944a4beb3b752f2def7db5f6 Mon Sep 17 00:00:00 2001 From: Vivek Patel Date: Wed, 6 Oct 2021 20:03:48 +0530 Subject: [PATCH] Fixes Wf duplicate issues for gateway steps Prevents gateway steps from verifying again by fixing return logic for converting those step definitions into workflow.Step instances --- automation/service/workflow_converter.go | 17 ++++++++++------- pkg/wfexec/gateways.go | 8 ++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/automation/service/workflow_converter.go b/automation/service/workflow_converter.go index 3fb55b5c3..30d2ed2a8 100644 --- a/automation/service/workflow_converter.go +++ b/automation/service/workflow_converter.go @@ -203,16 +203,16 @@ func (svc workflowConverter) workflowStepDefConv(g *wfexec.Graph, s *types.Workf } }() - if err != nil { - return false, err - } else if conv != nil { - conv.SetID(s.ID) - g.AddStep(conv) - return true, err - } else { + if err == nil && conv == nil { // signal caller that we were unable to // resolve definition at the moment return false, nil + } else { + if conv != nil { + conv.SetID(s.ID) + g.AddStep(conv) + } + return err == nil, err } } @@ -276,6 +276,9 @@ func (svc workflowConverter) convGateway(g *wfexec.Graph, s *types.WorkflowStep, } } + // return empty struct even if we get an error, + // so step definitions converted into workflow.Step instances + // and this step don't go through verification more than one time if s.Ref == "excl" { return wfexec.ExclGateway(pp...) } else { diff --git a/pkg/wfexec/gateways.go b/pkg/wfexec/gateways.go index 4f5b99956..cb14149e5 100644 --- a/pkg/wfexec/gateways.go +++ b/pkg/wfexec/gateways.go @@ -100,12 +100,12 @@ type inclGateway struct { // InclGateway fn initializes inclusive gateway func InclGateway(pp ...*GatewayPath) (*inclGateway, error) { if len(pp) < 2 { - return nil, fmt.Errorf("expecting at least two paths for incusive gateway") + return &inclGateway{}, fmt.Errorf("expecting at least two paths for incusive gateway") } for _, p := range pp { if p.test == nil { - return nil, fmt.Errorf("all inclusve gateway paths must have valid test Expression") + return &inclGateway{}, fmt.Errorf("all inclusve gateway paths must have valid test Expression") } } @@ -142,12 +142,12 @@ type exclGateway struct { func ExclGateway(pp ...*GatewayPath) (*exclGateway, error) { t := len(pp) if t < 2 { - return nil, fmt.Errorf("expecting at least two paths for exclusive gateway") + return &exclGateway{}, fmt.Errorf("expecting at least two paths for exclusive gateway") } for i, p := range pp { if p.test == nil && i != t-1 { - return nil, fmt.Errorf("all exclusive gateway paths must have valid test Expression") + return &exclGateway{}, fmt.Errorf("all exclusive gateway paths must have valid test Expression") } }