Add the annia pause lever to the oz console #90
Labels
No labels
blocked
bug
duplicate
effort
high
effort
low
effort
medium
effort
minimal
enhancement
help wanted
invalid
pr
feedback
pr
reviewing
question
status
backlog
status
document
status
done
status
implement
status
pending
status
planning
status
reviewing
waiting
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
tepichord/milner#90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Naina:
Overview
Annia's
annia-wakeupScaledJob can crash-loop, and the only lever today is opening Headlamp and editing YAML. This adds a one-press pause/resume to the oz console: a section that readsautoscaling.keda.sh/pausedon the ScaledJob, and a POST button that sets it with"true"or removes it. The console's identity gainsget/patchonscaledjobs.keda.shinannia— and nothing else. Existing identity verified: the console runs as ServiceAccountpreview-consoleinpreview-systemand today holds read verbs plus onepatchverb (onnamespaces) and nodelete9.Technical Approach
oz/src/lib/annia.ts— one constant for the target, one for the annotation.autoscaling.keda.sh/pausedis KEDA's ownPausedAnnotationconstant1.request()—get()hard-codes the/api/v1prefix and cannot reach a CRD2,2 (get()at#L134,request()at#L103, same file).NeedToBePausedByAnnotationtreats a present-but-unparseable value as paused3."true"to pause, JSONnullto remove the key4.oz/src/routes/api/pause/+server.ts, same order asapi/delete/+server.ts5:paused, handled beforeapplySimulated's numeric-PR guard7:<section>outside{#if data.rows}, rendered in both modes8 (the template's guard is{#if data.rows && data.rows.length > 0}):gitops/clusters/milner/preview-system/rbac.yamlbeside the existing console Role:The
preview-consoleServiceAccount and its namespace are as the plan states9. Theannianamespace this Role targets does not exist in this repo yet — there is noapps/annia/directory and nonamespace: anniamanifest — so the Role can only reconcile once #25 lands12.preview-system/oz.yaml0.1.7→0.1.8, and its comment, orci/oz-tag-guard.shfails the pull request10,11.Implementation Details
oz/src/lib/annia.tsisPausedByAnnotation,readPaused,setPausedoz/src/lib/annia.test.tsTransportoz/src/routes/api/pause/+server.tsoz/src/routes/+page.server.tsanniafield in every return;pausein the preview noticeoz/src/routes/+page.svelteoz/src/lib/preview-mode.tspausedinSimulatedState,pausebranch, resetgitops/clusters/milner/preview-system/rbac.yamlpreview-console-annia-pausegitops/clusters/milner/preview-system/oz.yaml0.1.7→0.1.8docs/preview-environment.md§11htests/test_static.pytest_preview_console_rbac_is_boundedcovers the annia Role14Dependencies: none new.
Constraints:
get/patchonly — nodelete,list, orwatch, and no verbs onjobsorpods.KubernetesClient; the press logs and simulates.nullunderapplication/merge-patch+json(RFC 7386).status.conditions[Paused].nix build ./oz#test)16.Out-of-scope notes:
Flagged for the human reviewer:
backoffLimitcannot be verified.annia-wakeupdoes not exist in this repo — #25 is unmerged12 — and as #25 is planned it declaresrestartPolicy: Neverbut omitsbackoffLimit, which then defaults to 613.Verified at check-assumptions time:
annia-wakeupappears nowhere in this tree, #25 is open, and #25's planning comment (id 9029) declaresrestartPolicy: Neverand omitsbackoffLimitunderjobTargetRef.template.spec— so the default of 6 applies12,13. Pausing stops KEDA's scale loop but never kills a running Job, so a crash loop keeps retrying inside the current Job untilbackoffLimitis reached. The issue's fix is one line in #25'sscaledjob.yaml:If #25 ships without it, stopping the in-flight Job needs a second grant (
deleteonjobs.batchinannia) and UI this issue deliberately does not add.annia.tscarries a comment recording both.Pausedcondition is not shown: it needs no extra RBAC but must never decide the button's target state.Acceptance Criteria
oz.*: the section reads running; one press adds the annotation and shows paused; a second press removes it and shows running.nix build ./oz#test,python3 -m pytest tests/test_static.py, andci/oz-tag-guard.shall pass with the tag at0.1.8.Testing Plan
annia.test.ts—isPausedByAnnotation: absent →false;"true"/"1"→true;"false"/"0"/"f"→false;""/"yes"→true(KEDA's fail-safe).annia.test.ts— fake transport asserts the path/apis/keda.sh/v1alpha1/namespaces/annia/scaledjobs/annia-wakeupand methodGETfor the read,PATCHfor the write.annia.test.ts— pause body carries"autoscaling.keda.sh/paused": "true"(a string); resume body carriesnull, and the client sendsapplication/merge-patch+json.preview-mode.test.ts—applySimulated(state, 'pause', '')flipspausedand leavesactive/expired/built/frontDooruntouched;resetSimulatedState()clears it.tests/test_static.py— the annia Role's rules are exactlykeda.sh/scaledjobswith{get, patch}, andpreview-consolestill holds nodeleteanywhere.kubectl get scaledjob -n annia annia-wakeup -o jsonpath='{.metadata.annotations}'before and after.Related Issues/PRs
annia-wakeupScaledJob this page reads, and thebackoffLimit: 0line it needs."false"resume was broken; this removes the key instead.Pausedcondition; why the annotation is the source of truth.Research Findings
/apis/keda.sh/v1alpha1/namespaces/annia/scaledjobs/annia-wakeup;KubernetesClient.get()/patch()cannot reach it (they prefix/api/v1), whilerequest()can."false"resume (fixed by #5257, shipped 2.13.0); removal is chosen because it works on every version."true"; resume isnullin a merge patch, which removes the key (RFC 7386).Pausedcondition does flip back toFalsein 2.20.x, but drift reports persisted through March 2025, so the page treats the condition as untrusted decoration.checkIfPausedreturns beforedeletePreviousVersionScaleJobs— so a running Job is never killed, and with the defaultbackoffLimit: 6a crash loop continues inside it.Pre-Mortem
backoffLimit(default 6), so pressing Pause halts KEDA's scale loop while the in-flight Job keeps retrying. UnlessbackoffLimit: 0lands in #25 or this issue adds the secondjobs.batchgrant it deliberately excludes, the feature ships green and useless.annianamespace itself does not exist in this repo yet, so the Role/RoleBinding have nothing to bind to and Flux either errors or silently applies a dead grant. The threekubectl auth can-iacceptance checks then cannot pass either, so nobody notices the console'sget/patchpath was never proven.+page.server.tsreturn path is missed and the page 500s in a state no test covers — the plan requires theanniafield on every return including the!userearly return, and the page dereferencesdata.annia.pausedunconditionally. A missed branch, or forgetting theapplySimulatednumeric-PR carve-out for preview mode, breaks the console page while the new unit tests still pass.