Skip to content

Commit

Permalink
Add requires for stages in case of multi plugins quicksync pattern (#…
Browse files Browse the repository at this point in the history
…5239)

Signed-off-by: khanhtc1202 <[email protected]>
  • Loading branch information
khanhtc1202 authored Sep 30, 2024
1 parent c1a06aa commit c4ca5c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 12 additions & 0 deletions pkg/app/pipedv1/controller/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,18 @@ func (p *planner) buildQuickSyncStages(ctx context.Context, cfg *config.GenericA
sort.Sort(model.PipelineStages(stages))
sort.Sort(model.PipelineStages(rollbackStages))

// In case there is more than one forward stage, build requires for each stage
// based on the order of stages.
if len(stages) > 1 {
preStageID := ""
for _, s := range stages {
if preStageID != "" {
s.Requires = []string{preStageID}
}
preStageID = s.Id
}
}

stages = append(stages, rollbackStages...)
if len(stages) == 0 {
return nil, fmt.Errorf("unable to build quick sync stages for deployment")
Expand Down
10 changes: 6 additions & 4 deletions pkg/app/pipedv1/controller/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ func TestBuildQuickSyncStages(t *testing.T) {
Index: 0,
},
{
Id: "plugin-2-stage-1",
Index: 1,
Id: "plugin-2-stage-1",
Index: 1,
Requires: []string{"plugin-1-stage-1"},
},
{
Id: "plugin-1-rollback",
Expand Down Expand Up @@ -244,8 +245,9 @@ func TestBuildQuickSyncStages(t *testing.T) {
Index: 0,
},
{
Id: "plugin-2-stage-1",
Index: 1,
Id: "plugin-2-stage-1",
Index: 1,
Requires: []string{"plugin-1-stage-1"},
},
},
},
Expand Down

0 comments on commit c4ca5c3

Please sign in to comment.