Skip to content

Commit 2117adf

Browse files
chmouelpiyush-garg
authored andcommitted
Do checks if the pipeline run is the latest later
In reconciler when checking if the pipeline run is the latest, we should check this after pr is done so we do that API call (which is not cached) the less often as possible. Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent bfcce18 commit 2117adf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/reconciler/reconciler.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, pr *tektonv1.PipelineRun
5454
return nil
5555
}
5656

57-
// make sure we have the latest pipelinerun to reconcile, since there is something updating at the same time
58-
lpr, err := r.run.Clients.Tekton.TektonV1().PipelineRuns(pr.GetNamespace()).Get(ctx, pr.GetName(), metav1.GetOptions{})
59-
if err != nil {
60-
return fmt.Errorf("cannot get pipelineRun: %w", err)
61-
}
62-
if lpr.GetResourceVersion() != pr.GetResourceVersion() {
63-
return nil
64-
}
65-
6657
// if its a GitHub App pipelineRun PR then process only if check run id is added otherwise wait
6758
if _, ok := pr.Annotations[keys.InstallationID]; ok {
6859
if _, ok := pr.Annotations[keys.CheckRunID]; !ok {
@@ -80,6 +71,15 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, pr *tektonv1.PipelineRun
8071
return nil
8172
}
8273

74+
// make sure we have the latest pipelinerun to reconcile, since there is something updating at the same time
75+
lpr, err := r.run.Clients.Tekton.TektonV1().PipelineRuns(pr.GetNamespace()).Get(ctx, pr.GetName(), metav1.GetOptions{})
76+
if err != nil {
77+
return fmt.Errorf("cannot get pipelineRun: %w", err)
78+
}
79+
if lpr.GetResourceVersion() != pr.GetResourceVersion() {
80+
return nil
81+
}
82+
8383
logger = logger.With(
8484
"pipeline-run", pr.GetName(),
8585
"event-sha", pr.GetAnnotations()[keys.SHA],

0 commit comments

Comments
 (0)