Skip to content

feat(api): ScaleToZero desiredState mode + idleTimeout (Phase 3 foundation) - #28

Merged
syscod3 merged 1 commit into
mainfrom
feat/phase3-scaletozero-api
Jul 8, 2026
Merged

feat(api): ScaleToZero desiredState mode + idleTimeout (Phase 3 foundation)#28
syscod3 merged 1 commit into
mainfrom
feat/phase3-scaletozero-api

Conversation

@syscod3

@syscod3 syscod3 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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 new desiredState enum value. Unlike Running/Suspended it's a mode (suspend-when-idle, resume-on-traffic), not a fixed target: status.Phase cycles Running↔Suspended underneath while desiredState stays ScaleToZero. A flip-based design would flap, since handleRunning re-suspends the instant it sees desiredState=Suspended.
  • spec.idleTimeout (*metav1.Duration, default 5m) — no-traffic window before auto-suspend; only meaningful for ScaleToZero.
  • status.lastActivityTime — observability for idle detection.
  • WebhookidleTimeout floored at 10s (below the resume latency it would thrash); create/update tests.
  • Regenerated deepcopy + config CRD.

Chart drift repair (heads up — larger-than-expected chart diff)

charts/imp-crds/templates/impvms.yaml had drifted since before Phase 1 — it was missing desiredState, 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 from config/crd/bases: purely additive (+58/-0), the only intentional delta from the base remains the helm.sh/resource-policy: keep annotation.

Follow-up (not in this PR): add a make sync-chart-crds target so the chart CRDs regenerate from config/crd/bases and stop drifting.

Verification

  • make manifests generate clean; CRD enum + fields present
  • go build ./... (host + GOOS=linux), go test ./api/... ./internal/controller/... ./internal/webhook/... green
  • agent test package compiles; chart YAML valid; helm chart test (startedAt) unaffected
  • pre-commit golangci-lint passed

…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.
@syscod3
syscod3 merged commit 20be988 into main Jul 8, 2026
17 checks passed
@syscod3
syscod3 deleted the feat/phase3-scaletozero-api branch July 8, 2026 00:26
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