Skip to content

Commit

Permalink
Revert "set, then unset, pending pipelinerun regardless of concurrenc…
Browse files Browse the repository at this point in the history
…y limit in startPR"

This reverts commit 13aa6e5.
  • Loading branch information
chmouel committed Jun 26, 2023
1 parent 0c393f1 commit c9a7c05
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions pkg/pipelineascode/pipelineascode.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,11 @@ func (p *PacRun) startPR(ctx context.Context, match matcher.Match) (*tektonv1.Pi
// Add labels and annotations to pipelinerun
kubeinteraction.AddLabelsAndAnnotations(p.event, match.PipelineRun, match.Repo, p.vcx.GetConfig())

userAsksForPending := match.Repo.Spec.ConcurrencyLimit != nil && *match.Repo.Spec.ConcurrencyLimit != 0
// regardless of whether the user has set concurrency, we use the pending bit for a very short time to
// attempt to reduce updates conflicts between ourselves and other controllers that start updating the PipelineRun
// as soon as the underlying Pod(s) have started, so we have a better chance updating the PipelineRun after its
// initial creation
match.PipelineRun.Spec.Status = tektonv1.PipelineRunSpecStatusPending

// if concurrency is defined then start the pipelineRun in pending state and
// state as queued
if userAsksForPending {
if match.Repo.Spec.ConcurrencyLimit != nil && *match.Repo.Spec.ConcurrencyLimit != 0 {
// pending status
match.PipelineRun.Spec.Status = tektonv1.PipelineRunSpecStatusPending
// pac state as queued
match.PipelineRun.Labels[keys.State] = kubeinteraction.StateQueued
match.PipelineRun.Annotations[keys.State] = kubeinteraction.StateQueued
Expand Down Expand Up @@ -192,7 +187,7 @@ func (p *PacRun) startPR(ctx context.Context, match matcher.Match) (*tektonv1.Pi
}

// if pipelineRun is in pending state then report status as queued
if pr.Spec.Status == tektonv1.PipelineRunSpecStatusPending && userAsksForPending {
if pr.Spec.Status == tektonv1.PipelineRunSpecStatusPending {
status.Status = "queued"
status.Text = fmt.Sprintf(params.QueuingPipelineRunText, pr.GetName(), match.Repo.GetNamespace())
}
Expand Down Expand Up @@ -222,15 +217,6 @@ func (p *PacRun) startPR(ctx context.Context, match matcher.Match) (*tektonv1.Pi
return pr, fmt.Errorf("cannot update pipelinerun %s with ownerRef: %w", pr.GetGenerateName(), err)
}
}

// now unset pending bit to get the other controllers, including the tekton pipeline controller, started with the PipelineRun,
// where they start making updates, unless user has specified concurrency control
if !userAsksForPending {
pr, err = action.PatchPipelineRun(ctx, p.logger, "specStatus", p.run.Clients.Tekton, pr, getPendingPatch(""))
if err != nil {
return pr, fmt.Errorf("cannot patch pipelinerun pending bit %s: %w", pr.GetGenerateName(), err)
}
}
return pr, nil
}

Expand All @@ -253,11 +239,3 @@ func getExecutionOrderPatch(order string) map[string]interface{} {
},
}
}

func getPendingPatch(specStatus string) map[string]interface{} {
return map[string]interface{}{
"spec": map[string]interface{}{
"status": specStatus,
},
}
}

0 comments on commit c9a7c05

Please sign in to comment.