Skip to content

Commit

Permalink
feat: consider workflow jobs with label 'deploy' as deployments for s…
Browse files Browse the repository at this point in the history
…equencing
  • Loading branch information
smrz2001 committed Aug 26, 2024
1 parent 670ff6c commit 8947f15
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cd/manager/common/job/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,12 @@ type Workflow struct {
Id int64
Labels []string
}

func (w Workflow) IsType(l string) bool {
for _, label := range w.Labels {
if label == l {
return true
}
}
return false
}
14 changes: 12 additions & 2 deletions cd/manager/jobmanager/jobManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (m *JobManager) processTestJobs(dequeuedJobs []job.JobState) bool {
func (m *JobManager) processWorkflowJobs(dequeuedJobs []job.JobState) bool {
// Check if there are any deploy jobs in progress
if len(m.getActiveDeploys()) == 0 {
dequeuedWorkflows := make([]job.JobState, 0, 0)
dequeuedWorkflows := make([]job.JobState, 0)
// Do not collapse back-to-back workflow jobs because they could be pointing to different actual workflows
for _, dequeuedJob := range dequeuedJobs {
// Break out of the loop as soon as we find a deploy job so that we don't collapse workflow jobs across
Expand Down Expand Up @@ -521,6 +521,16 @@ func (m *JobManager) updateJobStage(jobState job.JobState, jobStage job.JobStage

func (m *JobManager) getActiveDeploys() []job.JobState {
return m.cache.JobsByMatcher(func(js job.JobState) bool {
return job.IsActiveJob(js) && (js.Type == job.JobType_Deploy)
// We have active deployments if there are any deploy jobs in progress, or workflow jobs with a "deploy" label.
if job.IsActiveJob(js) {
if js.Type == job.JobType_Deploy {
return true
} else if js.Type == job.JobType_Workflow {
if workflow, err := job.CreateWorkflowJob(js); err == nil {
return workflow.IsType(job.WorkflowJobLabel_Deploy)
}
}
}
return false
})
}

0 comments on commit 8947f15

Please sign in to comment.