fix(kro): default omitted replicas to 1 instead of 0 - #1278
Open
magic-peach wants to merge 1 commit into
Open
magic-peach wants to merge 1 commit into
magic-peach wants to merge 1 commit into
Conversation
Deployments and StatefulSets without an explicit spec.replicas are healthy with 1 running pod, since Kubernetes defaults the field to 1. The sub-resource health and resolved values helpers were defaulting to 0 instead, so a healthy single replica resource showed a red error badge and 1/0 ready. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
magic-peach
requested review from
ashu8912,
illume,
joaquimrocha,
skoeva,
sniok,
vyncent-t and
yolossn
as code owners
September 5, 2026 11:06
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches Kubernetes defaults and includes focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes kro health reporting when Kubernetes defaults omitted Deployment or StatefulSet replicas to one.
Changes:
- Default omitted replica counts to
1. - Add regression coverage for health and resolved-value labels.
| File | Description |
|---|---|
kro/src/resources/subResources.ts |
Applies Kubernetes replica defaults. |
kro/src/resources/subResources.test.ts |
Tests omitted-replica behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Fixes the kro plugin's sub-resource health check treating a healthy Deployment or StatefulSet as unhealthy when
spec.replicasis omitted from the manifest.Related Issue
Fixes #1259
Changes
kro/src/resources/subResources.ts: defaultdesiredreplicas to1instead of0for theDeploymentandStatefulSetcases in bothgetSubResourceHealthandgetResolvedValues, matching Kubernetes' own default for an omittedspec.replicas.kro/src/resources/subResources.test.ts: added coverage for a Deployment/StatefulSet withspec.replicasomitted and one ready replica, asserting a success status and "1/1 ready" instead of the previous "1/0 ready" error.Steps to Test
cd kro && npm installnpx vitest run src/resources/subResources.test.ts- all tests pass, including the new cases.ResourceGraphDefinitionwith a Deployment that omitsspec.replicas, create an instance, and check the Instance Detail page's Sub-resources section shows a green success badge with "1/1 ready" once the pod is up, instead of a red error badge showing "1/0 ready".Screenshots (if applicable)
N/A, no visual change beyond the badge color/label for this specific case, and I did not have a live cluster to capture a screenshot against.
Notes for the Reviewer
spec.replicas: 0still returns an error status is unchanged and still passes, since?? 1only applies when the field is missing/undefined, not when it is explicitly0.