Skip to content

fix(deploy): preserve-live worker verify and rollback tolerate HPA replicas and CronJob history - #25752

Merged
Git-on-my-level merged 5 commits into
mainfrom
fix/worker-image-only-autoscale-tolerance
Nov 19, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
fix/worker-image-only-autoscale-tolerance

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What

.github/scripts/worker_image_only.py is the preserve-live writer for gcp_diarizer.yml. Its post-roll verify and its rollback precondition (the fresh baseline must equal the receipt's after identity plus consumers) compared:

  • a hash of each Deployment's entire .spec, which includes the HPA-owned replica count;
  • every Job that uses the worker image, including the hourly CronJob-spawned record-seal Jobs.

Rescaling and Job history rotation therefore refused both operations even though no release action changed anything.

Production evidence (read-only, ro-prod):

  • The target spec hash changed between two reads on 2026-11-18 with the image unchanged (replicas 16 → 14). The record-seal-sweeper CronJob (0 * * * *) rotates its Job history every hour.
  • record-seal-worker has its own HPA (1-16).
  • Run 43619755069 (2026-11-14) moved the worker image and then failed verify with post-roll runtime/consumer drift.
  • Release (SCA-2944) has held the worker roll that the backlog-release runbook needs because the documented inverse was not dependable while the worker autoscales.

Change

  • Identity hashes exclude .spec.replicas only on the two HPA-scaled Deployments: the worker and record-seal-worker (HPA_DEPLOYMENTS). The exclusion applies only while the same namespace read proves exactly one live HPA (minReplicas >= 1) targeting each of them through apps/v1. Those HPAs are bound by UID and spec hash, so removing, retargeting or reconfiguring one refuses. The operator-scaled T4 fallback, StatefulSets and every other workload keep it bound. Nothing else is excluded.
  • The inventory omits Jobs whose single controller (with a uid) is a CronJob present in the same namespace read, whose name is <cronjob>-<digits>, and whose run equals that CronJob's jobTemplate. The pod spec and template annotations must be identical, labels may differ only by the four controller-generated labels (which must carry this Job's own UID and name), the selector must be exactly the controller's batch.kubernetes.io/controller-uid selector, and every Job field must equal the template or a controller default. That is CronJob run history. Any other Job (different digest, parallelism, suspend, a hand-made name) stays bound. The CronJob itself stays bound, so a jobTemplate, schedule or image change still refuses. Owned Jobs are still image-validated (a mutable image refuses).
  • An activated T4 fallback was previously caught only through the replica-inclusive sibling hash. It is now checked directly, containers and init containers, on the early read, on the final pre-write read and in verify.
  • The admission dry-run and the CAS write still compare the full spec, replicas included. The CAS patch is now rebuilt from a fresh target read just before the server dry-run and the write, which must keep the admitted identity, so an HPA rescale before that fresh read no longer causes a resourceVersion conflict. A rescale after it still refuses through the CAS test (pinned by a test). The printed patch is the one actually sent.
  • Still fail closed:
    • any image/digest change on the target or any bound sibling;
    • a changed object UID;
    • any other spec field, on the target, siblings or CronJobs;
    • a standalone Job, or a Job whose controller CronJob is absent from the read.
  • Receipts written before this change hash the full spec and no longer match. Take a fresh inventory and forward receipt.

Tests

python3 .github/scripts/test_worker_image_only.py passes: 48 tests, 30 new. Before the fix, the four tolerance tests and the replay errored with the production refusal, and the T4-at-verify test failed.

  • Passes:
    • HPA replica change before deploy;
    • replica changes on the target and on record-seal-worker across verify and rollback;
    • CronJob Job created/deleted between every read (deploy, verify, rollback, verify);
    • replay of the 2026-11-14 receipt shape: two CronJobs, T4, record-seal-worker, seven CronJob-owned Jobs and an HPA-scaled target, with rescale plus history rotation during the roll.
  • Fails closed:
    • target image change, sibling or CronJob image change;
    • target or CronJob UID change;
    • minReadySeconds, nodeSelector, CronJob schedule or sibling serviceAccount change;
    • a standalone Job or an unknown-controller Job;
    • a mutable image on an owned Job;
    • T4 activated on the old image after the roll, or between the early check and the final pre-write read (no write);
    • an active T4 init container on the old image;
    • replica changes on an unlisted Deployment or a StatefulSet;
    • an owned Job on a different digest than its CronJob;
    • a uid-less controller reference.
  • Two existing tests that used replicas as their example of drift now use non-autoscaled fields.

Panels review-20261119t043424-48d8 (8 findings), review-20261119t050359-7770 (9) and review-20261119t055004-708a (4): all accepted and fixed in commits 2-4. Panel review-20261119t060937-9adc (9) was triaged in commit 5:

  • Accepted: F1 (terminating HPA), F2 (printed patch), F4, F5, F6 (chart tripwire and manifest trigger), F9.
  • Rejected: F3 (record-seal-repair runs the backend image, not the worker image, so its Jobs never enter the worker-image inventory); F7 (an extra admission-added annotation keeps the Job bound, which refuses rather than passes, and the live sweeper Jobs match exactly); F8 (a renamed or StatefulSet fallback keeps its replicas bound in the drift hash, so activation still refuses).

Live check (read-only, ro-prod): the target identity hash was identical (87d19f3…) at 04:31Z (10 replicas) and 05:32Z (8 replicas) and 06:07Z. The new inventory on prod returns the target plus record-seal-sweeper, T4, record-seal-worker and both HPAs, and omits the live sweeper Job history under the strict template match.

Permissions

No new permissions. The workflow's GKE identity omi-ci-deployer-prod holds roles/container.developer on based-hardware (read 2026-11-19 with ro-prod get-iam-policy), which includes get/list on autoscaling/horizontalpodautoscalers. An unavailable read still fails closed.

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

Deploy-tooling fix; the closest class (FC-readback-verifier-treats-omitted-proto-default-as-drift) covers proto-default serialization, not controller-owned fields.

🤖 Generated with Claude Code

Git-on-my-level and others added 5 commits November 19, 2026 11:31
…plicas and CronJob history

The image-only helper hashed each Deployment's whole spec, including the
HPA-owned replica count, and bound every CronJob-spawned Job. HPA rescaling or
hourly record-seal Job turnover therefore failed post-roll verify (run
43619755069 on 2026-11-14 moved the image, then refused with post-roll
runtime/consumer drift) and made the documented inverse unrunnable while the
worker autoscales. Identity hashes now exclude .spec.replicas on Deployments
and StatefulSets, and Jobs controlled by a CronJob in the same read are
omitted as run history. Image/digest, UID, other spec drift, standalone Jobs,
unknown-controller Jobs and an activated T4 fallback still refuse; the
admission dry-run and CAS write still compare the full spec.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…icas and mismatched owned Jobs

Panel review-20261119t043424-48d8 F1-F8: re-check the T4 fallback on the final
pre-write read (containers and init containers), exclude replicas only for the
worker and record-seal-worker, keep a CronJob-owned Job bound when its worker
images differ from the owner's jobTemplate, ignore uid-less owner references,
and tighten the turnover and replay tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…AS from a fresh read

Panel review-20261119t050359-7770 F1-F9: replica exclusion requires a live
HPA per listed Deployment, bound by UID and spec hash; a CronJob-owned Job is
omitted only when its generated name and whole run equal the owner's
jobTemplate (plus controller defaults); the CAS patch is rebuilt from a fresh
target read so an HPA rescale mid-deploy no longer conflicts; runbook covers
pre-change receipts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sion; fresh read before dry-run

Panel review-20261119t055004-708a F1-F4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chart tripwire

Panel review-20261119t060937-9adc F1, F2, F4, F5, F6, F9 (F3, F7, F8 rejected
with reasons in the PR).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 44b3877 into main Nov 19, 2026
66 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/worker-image-only-autoscale-tolerance branch November 19, 2026 07:17
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.

1 participant