Repository navigation
fix(kubernetes): make MachineHealthCheck maxUnhealthy configurable - #2752
mattia-eleuteri wants to merge 1 commit into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where auto-remediation for worker nodes in tenant clusters was effectively disabled due to a hardcoded Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR adds a per-node-group ChangesConfigurable maxUnhealthy Field for Worker Node Groups
🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers:
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Trivy (0.69.3)Trivy execution timed out Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces the maxUnhealthy parameter to the worker node groups configuration in the Kubernetes application package. This parameter allows users to specify the maximum number of unhealthy nodes (as an integer or percentage) tolerated before the MachineHealthCheck stops auto-remediation. The changes include updates to the README documentation, the Helm templates, the values schema, default values, and the corresponding CozyRDS definition. One low-severity issue was identified in the Helm template where quoting the rendered maxUnhealthy value is recommended to prevent YAML parsing issues when percentage strings are evaluated.
| spec: | ||
| clusterName: {{ $.Release.Name }} | ||
| maxUnhealthy: 0 | ||
| maxUnhealthy: {{ $group.maxUnhealthy | default "100%" }} |
There was a problem hiding this comment.
Quoting the maxUnhealthy value is highly recommended. In Kubernetes, maxUnhealthy can be either an integer or a percentage string (e.g., "10%"). Unquoted percentage values like 100% or 10% can sometimes cause parsing issues in YAML or be misinterpreted by some parsers. Quoting the rendered value ensures it is always treated as a valid string/scalar.
maxUnhealthy: {{ $group.maxUnhealthy | default "100%" | quote }}There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/apps/kubernetes/values.yaml (1)
31-43:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
maxUnhealthytype currently blocks integer valuesLine 31 defines
maxUnhealthyasstring, so generated validation/docs enforce string-only and reject valid integer inputs (for examplemaxUnhealthy: 1) despite the PR contract saying integer or percentage.Use an int-or-string type in the source definition so generated schema/CRD accept both forms consistently.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/apps/kubernetes/values.yaml` around lines 31 - 43, Update the documented/type annotation for the NodeGroup field `maxUnhealthy` from a plain string to an int-or-string type so generated schema/CRD accepts both integer and percentage forms; modify the comment line that currently reads "`@field` {string} maxUnhealthy" to use an int-or-string type (e.g. "`@field` {int-or-string} maxUnhealthy" or the project's equivalent int|string union) so the `nodeGroups`/`NodeGroup` validation allows values like `1` and `"100%"`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/apps/kubernetes/values.yaml`:
- Around line 31-43: Update the documented/type annotation for the NodeGroup
field `maxUnhealthy` from a plain string to an int-or-string type so generated
schema/CRD accepts both integer and percentage forms; modify the comment line
that currently reads "`@field` {string} maxUnhealthy" to use an int-or-string type
(e.g. "`@field` {int-or-string} maxUnhealthy" or the project's equivalent
int|string union) so the `nodeGroups`/`NodeGroup` validation allows values like
`1` and `"100%"`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4f27b1ec-6912-4aa8-afb7-0bac975fadad
📒 Files selected for processing (5)
packages/apps/kubernetes/README.mdpackages/apps/kubernetes/templates/cluster.yamlpackages/apps/kubernetes/values.schema.jsonpackages/apps/kubernetes/values.yamlpackages/system/kubernetes-rd/cozyrds/kubernetes.yaml
702a622 to
6a3bfc9
Compare
6a3bfc9 to
3340c17
Compare
|
Rebased onto latest Addressed review feedback:
|
3340c17 to
960a1fb
Compare
Andrei Kvapil (kvaps)
left a comment
There was a problem hiding this comment.
LGTM, thank you!
|
Heads-up — this has drifted ~200 commits behind To resolve: git rebase origin/main
# take main's side for the generated file, then regenerate it from the merged source:
cd packages/apps/kubernetes && make generate
git add -A && git rebase --continue
|
The MachineHealthCheck was hardcoded to maxUnhealthy: 0. In Cluster API semantics this blocks all remediation: as soon as a single machine is unhealthy the threshold is exceeded, so crashed worker nodes are never auto-replaced. Expose maxUnhealthy per node group (integer or percentage) with a default of "100%" so auto-remediation works out of the box while staying tunable for sensitive pools. Signed-off-by: mattia-eleuteri <[email protected]>
960a1fb to
6a9047d
Compare
|
myasnikovdaniil rebased onto latest |
|
Closing this: configurable worker MHC |
Adds per-node-group overrides for the worker MachineHealthCheck tuning introduced as a cluster-wide `nodeHealthCheck` by #2931. **What:** optional `nodeGroups[name].maxUnhealthy` and `nodeGroups[name].nodeStartupTimeout`; when unset a group inherits the cluster-wide `nodeHealthCheck.*` (no behaviour change). The per-group value reuses the existing int-or-string validation; an invalid override fails the render naming the offending group. **Why:** the MachineHealthCheck is rendered per node group, so groups can warrant different remediation tolerances (e.g. a stateful group at `0%`, stateless at `50%`). This is the per-group granularity of the standalone proposal (#2752 / #2935), rebuilt on top of #2931's `nodeHealthCheck`. **Notes:** stacked on `phase1-talos-migration` (#2931) — retarget to `main` once it merges. Supersedes #2935 (original author credited as co-author). helm-unittest covers per-group override (percent + bare int), `nodeStartupTimeout` override, fallback-when-unset, and invalid-override rejection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added per-node-group overrides for health-check settings: `maxUnhealthy` and `nodeStartupTimeout`, with automatic fallback to cluster-wide `nodeHealthCheck` when unset. * **Bug Fixes** * Improved `maxUnhealthy` parsing/rendering to support both bare integers and percentage strings, including more precise validation errors for the exact override path. * **Documentation** * Updated kubernetes app docs and values schemas (including CRD chart-values schema) to document the new override fields. * **Tests** * Added MachineHealthCheck rendering tests for override, fallback, and invalid `maxUnhealthy` (e.g., `"abc"`) cases. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
What this PR does
MachineHealthCheckwas rendered with a hardcodedmaxUnhealthy: 0. In Cluster API semantics this blocks all remediation (the threshold is exceeded as soon as a single machine is unhealthy), so crashed worker nodes in tenant clusters were never auto-replaced.maxUnhealthyas a per-node-group field (integer or percentage), defaulting to"100%", so auto-remediation works out of the box and stays tunable for sensitive pools.values.schema.json, README and the-rdCRD accordingly.Release note
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation