Skip to content

Commit 5d33736

Browse files
committed
fix: Skip reconciliation of stale PLRs
Instead of running the reconcile loop on the fresh pipeline, skip it and let the next iterations to reconcile it. Signed-off-by: Gal Ben Haim <[email protected]>
1 parent 25bfed7 commit 5d33736

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

pkg/reconciler/reconciler.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,15 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, pr *tektonv1.PipelineRun
5757

5858
logger.Debugf("reconciling pipelineRun %s/%s", pr.GetNamespace(), pr.GetName())
5959

60-
// Get fresh PipelineRun from API server to avoid informer cache staleness
61-
freshPR, err := r.run.Clients.Tekton.TektonV1().PipelineRuns(pr.GetNamespace()).Get(ctx, pr.GetName(), metav1.GetOptions{})
60+
// make sure we have the latest pipelinerun to reconcile, since there is something updating at the same time
61+
lpr, err := r.run.Clients.Tekton.TektonV1().PipelineRuns(pr.GetNamespace()).Get(ctx, pr.GetName(), metav1.GetOptions{})
6262
if err != nil {
63-
logger.Errorf("failed to get fresh pipelineRun %s/%s: %v", pr.GetNamespace(), pr.GetName(), err)
64-
return fmt.Errorf("cannot get fresh PipelineRun: %w", err)
63+
return fmt.Errorf("cannot get pipelineRun: %w", err)
6564
}
6665

67-
if freshPR.GetResourceVersion() != pr.GetResourceVersion() {
68-
logger.Debugf("using fresh pipelineRun data (cached version %s vs fresh version %s)", pr.GetResourceVersion(), freshPR.GetResourceVersion())
69-
pr = freshPR
66+
if lpr.GetResourceVersion() != pr.GetResourceVersion() {
67+
logger.Debugf("Skipping reconciliation, pipelineRun was updated (cached version %s vs fresh version %s)", pr.GetResourceVersion(), lpr.GetResourceVersion())
68+
return nil
7069
}
7170

7271
// if pipelineRun is in completed or failed state then return
@@ -116,16 +115,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, pr *tektonv1.PipelineRun
116115
return nil
117116
}
118117

119-
// make sure we have the latest pipelinerun to reconcile, since there is something updating at the same time
120-
lpr, err := r.run.Clients.Tekton.TektonV1().PipelineRuns(pr.GetNamespace()).Get(ctx, pr.GetName(), metav1.GetOptions{})
121-
if err != nil {
122-
return fmt.Errorf("cannot get pipelineRun: %w", err)
123-
}
124-
125-
if lpr.GetResourceVersion() != pr.GetResourceVersion() {
126-
return nil
127-
}
128-
129118
// If we have a controllerInfo annotation, then we need to get the
130119
// configmap configuration for it
131120
//

0 commit comments

Comments
 (0)