fix(k8s): use k8s-native resource quantity units in default manifest - #143
Merged
Conversation
build_default_k8s_manifest copied the ECS Fargate CPU-unit/MiB defaults
("256"/"512") used by the ECS path's build_default_manifest. k8s
Quantity has no such bare-number convention: resource_requirements()
(k8s_driver.rs) feeds these straight into a Quantity, so an unsuffixed
"256" cpu request means 256 whole cores (not 0.25 vCPU) and "512"
memory means 512 bytes (not 512Mi) — unschedulable on any real node.
This is why a freshly provisioned k8s instance (Hera, via the "New
fleet" wizard's provision_agent_k8s path) sat in Pending forever with
0 restarts: it never got past scheduling.
manifest.rs's validate() already only enforces the ECS CPU whitelist
for Runtime::Ecs and explicitly defers k8s cpu/memory format checking
to "K8S API at deploy time" — the default builder just never emitted
k8s-shaped values for that deferred check to catch.
Fix: use k8s-native quantity strings ("250m"/"512Mi") sized to the
same ~0.25 vCPU / 512Mi as the Fargate default.
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
Root cause of the
Herapod (namespaceopenab-studio) sitting inPendingforever withRestarts=0since this morning's fleet-name-collision incident (see #142).build_default_k8s_manifest(crates/studio-cp/src/lib.rs) reused the ECS Fargate CPU-unit/MiB default values ("256"/"512") thatbuild_default_manifest(the ECS-path sibling) uses. Those bare numbers are a valid, meaningful convention on the ECS side —manifest.rs'sVALID_ECS_CPUwhitelist is exactly["256", "512", "1024", "2048", "4096"], Fargate's CPU units (256 = 0.25 vCPU).k8s has no such convention.
resource_requirements()(crates/oabctl/src/k8s_driver.rs) feedsresources.cpu/.memorystraight into a k8sQuantitywith no ECS-aware conversion — an unsuffixed"256"parses as 256 whole CPU cores, and"512"as 512 bytes. A pod requesting 256 cores can't be scheduled on any real node, so it sits inPendingindefinitely (Restarts=0because it never gets past scheduling to even pull the image).manifest.rs'svalidate()doesn't catch this: the ECS CPU whitelist check only runs forRuntime::Ecs; forRuntime::Kubernetesit explicitly defers ("K8S: cpu/memory format validated at deploy time by K8S API") — the default builder just never emitted k8s-shaped values for that deferred check to actually validate.Fix
build_default_k8s_manifest's defaults now use k8s-native quantity strings, sized to the same ~0.25 vCPU / 512Mi as the Fargate default:This is the
provision_agent_k8swizard path (the "New fleet" k8s flow) — exactly what createdHera.Not fixed here
Herapod is stillPendingwith the old bad resource request baked into its Deployment spec — this PR only fixes new provisions going forward. Brett will need to redeploy/recreateHera(or manually patch the Deployment's resources) to pick this up; the pod won't self-heal.Test plan
k8s_manifest_resources_carry_k8s_unit_suffixesasserting the k8s manifest's cpu/memory carry k8s unit suffixescargo test -p studio-cp --lib— 34/34 passing