Skip to content

fix: prevent build watch from redeploying old builds on restart - #137

Merged
biersoeckli merged 1 commit into
feat/extend-project-canva-view-with-app-configuration-settingsfrom
fix/build-watch-redeploy-on-restart
Sep 24, 2026
Merged

biersoeckli merged 1 commit into
feat/extend-project-canva-view-with-app-configuration-settingsfrom
fix/build-watch-redeploy-on-restart

Conversation

@aperolschpritz

Copy link
Copy Markdown
Collaborator

Problem

When QuickStack restarts, the build watch redeploys old successful builds.

  1. Builds that were already built and deployed a long time ago get deployed again.
  2. Wrong/older versions get deployed after restart, because with multiple successful jobs per app an older one can win.

Root cause

k8s.Watch.watch(path, {}, ...) is started without a resourceVersion. Per the Kubernetes API, an unset resourceVersion uses "Get State and Start at Most Recent": the watch begins with synthetic ADDED events for every existing build Job.

handleJobEvent only checks the in-memory processedJobs set, which is empty after a process restart. Every replayed SUCCEEDED job therefore triggers handleSucceeded -> createDeployment. Jobs are replayed in list order (effectively alphabetical by job name), so among several successful builds the older one can be processed last and overwrite the deployment. This is issue #100.

A previous scanExistingJobs guard was removed in 8bd76dc, leaving the watch replay unguarded.

Fix

V1: seed processedJobs with existing terminal jobs before the watch starts.

  • seedProcessedJobs() lists jobs and marks SUCCEEDED/FAILED as processed. Running/pending jobs stay unseeded so they still deploy when they finish.
  • Replayed ADDED events for old builds are now ignored.
  • handleJobEvent also ignores DELETED events, so cleaning up finished jobs cannot trigger a deployment.

Tests

  • Old successful build replayed as ADDED after startup is not redeployed.
  • A running build is still deployed once it succeeds after startup.
  • DELETED events are ignored even when the job shows as succeeded.

Verified locally: unit tests pass, ESLint clean, tsc --noEmit --project tsconfig.server.json clean.

@biersoeckli
biersoeckli marked this pull request as ready for review September 24, 2026 12:19
@biersoeckli
biersoeckli added this pull request to stack #139 September 24, 2026 12:19
@biersoeckli
biersoeckli force-pushed the fix/build-watch-redeploy-on-restart branch from 9fc2294 to b4abd23 Compare September 24, 2026 12:20
@biersoeckli
biersoeckli merged commit 2686fd4 into main Sep 24, 2026
2 checks passed
@biersoeckli
biersoeckli deleted the fix/build-watch-redeploy-on-restart branch September 24, 2026 13:52
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.

2 participants