feat(api): ScaleToZero desiredState mode + idleTimeout (Phase 3 foundation) - #28
Merged
Conversation
…oundation) Phase 3 (wake-on-traffic / scale-to-zero) API foundation. Design: plans repo projects/imp/docs/plans/2026-07-08-phase3-wake-on-traffic-design.md. - shared_types.go: new VMDesiredStateScaleToZero enum value. Unlike Running/ Suspended it is a *mode* (suspend-when-idle, resume-on-traffic), not a fixed target — status.Phase cycles underneath while desiredState stays ScaleToZero. A flip-based design would flap because handleRunning re-suspends the instant it sees desiredState=Suspended. - impvm_types.go: spec.idleTimeout (*metav1.Duration, default 5m) governs the no-traffic window before auto-suspend; status.lastActivityTime for observability. - webhook: idleTimeout floored at 10s to avoid thrashing the resume latency; create/update tests. - Regenerated deepcopy + config CRD. Also resyncs charts/imp-crds/templates/impvms.yaml from config/crd/bases: the Helm CRD had drifted since before Phase 1 (missing desiredState, expireAfter, rescheduleOnNodeLoss, expiresAt) with no sync automation, so the published chart could not install any suspend/resume feature. Resync is purely additive and the only intentional delta from the base remains the resource-policy annotation. Follow-up: add a make target so the chart CRDs regenerate from config/crd/bases and stop drifting.
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.
Phase 3 (wake-on-traffic / scale-to-zero) API foundation only — the datapath (activator, idle detector, auto-suspend/resume) lands in later PRs. Design + task plan:
syscode-ai-internal-plans/projects/imp/docs/plans/2026-07-08-phase3-wake-on-traffic-{design,plan}.md.What this adds
VMDesiredStateScaleToZero— a newdesiredStateenum value. UnlikeRunning/Suspendedit's a mode (suspend-when-idle, resume-on-traffic), not a fixed target:status.Phasecycles Running↔Suspended underneath whiledesiredStatestaysScaleToZero. A flip-based design would flap, sincehandleRunningre-suspends the instant it seesdesiredState=Suspended.spec.idleTimeout(*metav1.Duration, default 5m) — no-traffic window before auto-suspend; only meaningful forScaleToZero.status.lastActivityTime— observability for idle detection.idleTimeoutfloored at 10s (below the resume latency it would thrash); create/update tests.Chart drift repair (heads up — larger-than-expected chart diff)
charts/imp-crds/templates/impvms.yamlhad drifted since before Phase 1 — it was missingdesiredState,expireAfter,rescheduleOnNodeLoss,expiresAt— with no sync automation anywhere (no Makefile/CI/script target; history shows manual sync commits). So the published Helm chart could not install any suspend/resume feature, mine included. This PR resyncs the chart fromconfig/crd/bases: purely additive (+58/-0), the only intentional delta from the base remains thehelm.sh/resource-policy: keepannotation.Follow-up (not in this PR): add a
make sync-chart-crdstarget so the chart CRDs regenerate fromconfig/crd/basesand stop drifting.Verification
make manifests generateclean; CRD enum + fields presentgo build ./...(host +GOOS=linux),go test ./api/... ./internal/controller/... ./internal/webhook/...greenstartedAt) unaffected