Repository navigation
Harden the admission gate after the production cutover - #207
Merged
Merged
Conversation
…agree Production runs a mutable image tag with pullPolicy Always, so new code starts serving when the image is pushed, not when the deploy job runs — and migrations run just before that job. A pod rescheduled in the gap executes new code against the old schema. On 2026-09-05 that gap was 24 minutes and cost five sessions: the admission gate sits on the container-create path, so a table it could not read failed the launch outright. A missing policy table is not an ambiguous answer — the queue cannot be on if its policy does not exist — so the gate says no and the legacy path serves. Narrowed to that one question; every other database error still raises. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
… never started Two things the cutover found in production. The legacy-quota removal could never have run. Kubeclient returns labels as a RecursiveOpenStruct, so #to_h gives symbol keys, and every guard clause read them with string keys — silently nil, so "Namespace is not a managed session scope" fired for all 62 objects regardless of how correctly they were labelled. The dry run is what caught it, which is what the dry run is for. There was no test at all for that method; there are three now, built on a real Kubeclient::Resource, because a plain Hash stand-in reads fine with string keys and hides exactly this. The stale sweeper never asked about `not_started`. It swept running, ready and finishing, so a launch lost between the database commit and Temporal sat untouched — production had 47 of them, the oldest since March, none carrying an error to explain itself. The scope needed its own branch too: these sessions have no started_at, so the default branch would have matched nothing. Queued sessions stay exempt — waiting for a slot is not staleness. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
5 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three things the production cutover surfaced. All were found by running the change against a real cluster, not by reading it.
1. New code can serve before its schema arrives
Production runs
aixle-app-web:mainwithimagePullPolicy: Always. The tag is mutable, so new code starts serving when the image is pushed, not when the deploy job runs — andDB Migrateruns just beforeDeploy. On 2026-09-05 that gap was 24 minutes:A worker pod rescheduled in that window (spot, autoscaling — they move constantly) ran new code against the old schema. Five sessions died with
PG::UndefinedTable: relation "session_admission_policies" does not exist, because the admission gate sits on the container-create path.A missing policy table is not an ambiguous answer — the queue cannot be on if its policy does not exist — so the gate now says no and the legacy path serves. Narrowed to that one question; every other database error still raises.
This also protects the follow-up that drops
namespace_resource_quotas, where the same window runs in reverse.2. The legacy-quota removal could never have run
remove_managed_session_quotarefused all 62 objects with "Namespace is not a managed session scope" no matter how correctly they were labelled:Kubeclient returns labels as a
RecursiveOpenStruct, so#to_hgives symbol keys and every guard clause read them with string keys. The dry run is what caught it, which is what the dry run is for.There was no test at all for that method. There are three now, built on a real
Kubeclient::Resource— a plain Hash stand-in reads fine with string keys and hides exactly this. Verified that they fail without the fix, with the same message production gave.3. Sessions that never started were never reaped
The stale sweeper asked about
running,readyandfinishing— nevernot_started. A launch lost between the database commit and Temporal therefore sat untouched forever. Production had 47 of them, the oldest since March, 45 from a single day, none carrying an error to explain itself:That is the failure the queue's durable launch intent exists to prevent, but the legacy path still needs a floor. The scope needed its own branch too — these sessions have no
started_at, so the shared branch would have matched nothing. Queued sessions stay exempt: waiting for a slot is not staleness.Type of change
How was this tested?
docker compose exec -T web make check_all— green in full.Six tests added. The quota-guard ones were checked against the un-fixed code and reproduce the production error exactly.
Checklist
make check_allpasses locally.