Skip to content

fix: race condition causing builds stuck queued - #379

Merged
shreddedbacon merged 1 commit into
mainfrom
qos-race-condition
May 18, 2026
Merged

fix: race condition causing builds stuck queued#379
shreddedbacon merged 1 commit into
mainfrom
qos-race-condition

Conversation

@rocketeerbkw

@rocketeerbkw rocketeerbkw commented May 18, 2026

Copy link
Copy Markdown
Member

Checklist

  • Affected Issues have been mentioned in the Closing issues section
  • Documentation has been written/updated
  • PR title is ready for changelog and subsystem label(s) applied

Attempts to fix a race condition that can leave a build stuck queued until the remote-controller is restarted. Seen in production but not able to reproduce locally.

The race condition:

  1. New build comes in, picked up by build handler
  2. Build CRD is created (direct k8s api) and added to BuildQueueCache
  3. Reconciler/Queue system sees pending build in BuildQueueCache and attempts to load CRD (hits k8s cache only)
  4. CRD is not in the cache, so returns not found
  5. Error condition leaves build in bad state in queue cache, and never picked up again

Related error thrown in remote-controller:

ERROR v1beta2.LagoonBuild error running queue processor {"lagoonbuild":{"name":"lagoon-build-abcdef","namespace":"drupal-example-main"},"error":"LagoonBuild.crd.lagoon.sh \"lagoon-build-ghijkl\" not found"}

github.com/uselagoon/remote-controller/internal/controllers/v1beta2.(*LagoonBuildReconciler).whichBuildNext
    /workspace/internal/controllers/v1beta2/build_qoshandler.go:67
github.com/uselagoon/remote-controller/internal/controllers/v1beta2.(*LagoonBuildReconciler).qosBuildProcessor
    /workspace/internal/controllers/v1beta2/build_qoshandler.go:40
github.com/uselagoon/remote-controller/internal/controllers/v1beta2.(*LagoonBuildReconciler).Reconcile
    /workspace/internal/controllers/v1beta2/build_controller.go:160
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.23.1/pkg/internal/controller/controller.go:222
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.23.1/pkg/internal/controller/controller.go:479
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.23.1/pkg/internal/controller/controller.go:438
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func1
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.23.1/pkg/internal/controller/controller.go:313

Closing issues

n/a

@shreddedbacon shreddedbacon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple enough, will see if it helps

@shreddedbacon
shreddedbacon merged commit 7263b3f into main May 18, 2026
12 checks passed
@shreddedbacon
shreddedbacon deleted the qos-race-condition branch May 18, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants