Repository navigation
fix(kubernetes): validate MachineHealthCheck condition timeouts at render time - #3901
Conversation
…nder time
The CAPI webhook validates nodeStartupTimeout with a 30s floor but does
not validate unhealthyConditions timeouts at all, so a zero or negative
readyUnknownTimeout or readyFalseTimeout applied and remediated a
Machine the moment its Ready condition flipped. Route both fields
through the same render-time duration guard as maxNodeProvisionTime,
extracted into a kubernetes.positiveDuration helper in each chart.
The guard now also accepts the canonical form a duration serializes
back to ("20m0s", "1h0m0s"): metav1.Duration prints that shape, so a
value copied from kubectl output previously failed the render. The
first segment must still be positive and later segments may be zero,
which keeps every accepted string a positive duration.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (18)
📝 WalkthroughWalkthroughThe change adds shared Helm validation for positive, whole-unit durations. It applies validation to node provisioning and readiness timeouts, adds coverage for accepted and rejected formats, and updates API, schema, values, OpenAPI, and README documentation. ChangesDuration validation
Estimated code review effort: 3 (Moderate) | ~20 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 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.72.0)Trivy execution failed: 2026-08-18T19:42:49Z FATAL Fatal error run error: fs scan error: scan error: scan failed: failed analysis: post analysis error: post analysis error: helm scan error: fs filter error: fs filter error: walk error range error: stat api/apps/v1alpha1/.golangci.yml: no such file or directory: range error: stat api/apps/v1alpha1/.golangci.yml: no such file or directory 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 |
What this PR does
Follow-up to #3898, closing two gaps in the render-time duration guard it introduced. Context: #3513.
First, the guard now also covers the MachineHealthCheck condition timeouts (
readyUnknownTimeout,readyFalseTimeout) in both the kubernetes and kubernetes-nodes charts. They need it more than the autoscaler annotation does: the CAPI webhook validatesnodeStartupTimeoutwith a 30s floor but does not validateunhealthyConditionstimeouts at all, so a zero or negative value used to apply silently and remediate a Machine the moment its Ready condition flipped, which for a KubeVirt worker means deleting the VM.Second, the guard accepts the canonical form a Go duration serializes back to ("20m0s", "1h0m0s").
metav1.Durationprints that shape, so a value copied fromkubectl get -o yamloutput previously failed the render. The first segment must still be positive and later segments may be zero, so every accepted string still parses to a positive duration and the overflow and fraction-to-zero rejections stay.Mechanically, the guard moves into a
kubernetes.positiveDurationnamed template in each chart's_helpers.tpl, and the error message format is unchanged. Tests cover the canonical form on all three fields and the rejection of unitless, zero, and negative condition timeouts in both charts. The previous test case that passed unitless values through verbatim is reworked into rejections: a unitless value used to fail only at CAPI decode on apply, and a zero or negative one did not fail anywhere.Downstream repositories
Release note
Summary by CodeRabbit
Bug Fixes
20m0sand1h0m0s.Documentation