From a029e0547a2e5615968acf5acf39d3dd108f18dd Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Mon, 18 May 2026 12:06:54 -0500 Subject: [PATCH] fix: race condition causing builds stuck queued --- internal/controllers/v1beta2/build_qoshandler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/controllers/v1beta2/build_qoshandler.go b/internal/controllers/v1beta2/build_qoshandler.go index f9b2403d..eb499b84 100644 --- a/internal/controllers/v1beta2/build_qoshandler.go +++ b/internal/controllers/v1beta2/build_qoshandler.go @@ -120,7 +120,10 @@ func (r *LagoonBuildReconciler) processQueue(ctx context.Context, opLog logr.Log } else { // start the build pod immediately var lagoonBuild lagooncrd.LagoonBuild - if err := r.Get(ctx, types.NamespacedName{Namespace: pBuild.Namespace, Name: startBuild}, &lagoonBuild); err != nil { + // Bypass controller-runtime read cache to avoid race condition where a build exists but + // has not been put in the cache yet. + if err := r.APIReader.Get(ctx, types.NamespacedName{Namespace: pBuild.Namespace, Name: startBuild}, &lagoonBuild); err != nil { + // An error here results in the build being stuck queued until remote-controller is restarted. return err } if err := r.processBuild(ctx, opLog, lagoonBuild); err != nil {