fix(autoscaler): reject Price expander for Hetzner provider - #4661
Conversation
The Hetzner cloud provider in the upstream cluster-autoscaler does not implement the pricing API, causing a fatal crash when --expander=price is passed. Add provider-aware validation in ValidateAutoscalerConfig to reject AutoscalerExpanderPrice for ProviderHetzner with a clear error message suggesting LeastWaste or Random as alternatives. Fixes #4660 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds provider-aware autoscaler validation to prevent a known crash scenario in upstream cluster-autoscaler when using the Hetzner cloud provider with the Price expander (pricing API not implemented), returning an actionable validation error instead of allowing a CrashLoopBackOff.
Changes:
- Introduces a new sentinel error
ErrExpanderNotSupportedForProviderfor unsupported provider/expander combinations. - Adds
validateExpanderForProviderand wires it intoValidateAutoscalerConfigto rejectPriceon Hetzner with suggested alternatives. - Extends autoscaler validation tests with coverage for Hetzner/Docker provider combinations and allowed expanders.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/apis/cluster/v1alpha1/validation.go | Adds provider-aware expander validation and invokes it from ValidateAutoscalerConfig. |
| pkg/apis/cluster/v1alpha1/errors.go | Adds a new sentinel error for unsupported expander/provider combinations. |
| pkg/apis/cluster/v1alpha1/autoscaler_test.go | Adds test cases covering the Hetzner Price rejection and valid alternatives. |
✅MegaLinter analysis: Success✅ Linters with no issuesactionlint, git_diff, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint See detailed reports in MegaLinter artifacts
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: f9c0c09 | Previous: c9821bf | Ratio |
|---|---|---|---|
BenchmarkCluster_MarshalJSON/FullProductionCluster (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) |
169864 ns/op 20670 B/op 465 allocs/op |
79803 ns/op 20660 B/op 465 allocs/op |
2.13 |
BenchmarkCluster_MarshalJSON/FullProductionCluster (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) - ns/op |
169864 ns/op |
79803 ns/op |
2.13 |
BenchmarkYAMLEncode/Minimal (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) |
158808 ns/op 21320 B/op 388 allocs/op |
70570 ns/op 21320 B/op 388 allocs/op |
2.25 |
BenchmarkYAMLEncode/Minimal (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) - ns/op |
158808 ns/op |
70570 ns/op |
2.25 |
BenchmarkYAMLEncode/FullProductionCluster (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) |
178517 ns/op 32448 B/op 433 allocs/op |
80784 ns/op 32448 B/op 433 allocs/op |
2.21 |
BenchmarkYAMLEncode/FullProductionCluster (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) - ns/op |
178517 ns/op |
80784 ns/op |
2.21 |
BenchmarkJSONEncode (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) |
107993 ns/op 15832 B/op 384 allocs/op |
68209 ns/op 15831 B/op 384 allocs/op |
1.58 |
BenchmarkJSONEncode (github.com/devantler-tech/ksail/v7/pkg/apis/cluster/v1alpha1) - ns/op |
107993 ns/op |
68209 ns/op |
1.58 |
This comment was automatically generated by workflow using github-action-benchmark.
The Hetzner cloud provider does not implement the pricing API, so AutoscalerExpanderPrice causes a fatal crash. KSail now rejects this combination at validation time (fix #4661). Update the hetzner.mdx autoscaler reference to remove Price from the valid expander list and add a note explaining the constraint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Hetzner cloud provider in upstream cluster-autoscaler does not implement the pricing API. KSail now rejects Price as an expander for Hetzner clusters (see fix #4661). Update docs to reflect the supported strategies: LeastWaste, LeastNodes, Random. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…4664) * docs: note Price expander unsupported for Hetzner provider The Hetzner cloud provider does not implement the pricing API, so AutoscalerExpanderPrice causes a fatal crash. KSail now rejects this combination at validation time (fix #4661). Update the hetzner.mdx autoscaler reference to remove Price from the valid expander list and add a note explaining the constraint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * docs: clarify Price expander rejected at validation not runtime Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Summary
The Hetzner cloud provider in the upstream cluster-autoscaler does not implement the pricing API, causing a fatal crash (
CrashLoopBackOff) when--expander=priceis passed:This PR adds provider-aware validation in
ValidateAutoscalerConfigto rejectAutoscalerExpanderPricewhen the provider is Hetzner, with a clear error message suggestingLeastWasteorRandomas alternatives.Changes
pkg/apis/cluster/v1alpha1/errors.go— NewErrExpanderNotSupportedForProvidersentinel errorpkg/apis/cluster/v1alpha1/validation.go— NewvalidateExpanderForProviderfunction called fromValidateAutoscalerConfig; rejectsPricefor Hetzner with helpful alternative suggestionspkg/apis/cluster/v1alpha1/autoscaler_test.go— 3 new test cases: Price+Hetzner (error), Price+Docker (ok), LeastWaste+Hetzner (ok)Validation
go build ./...✅go test ./pkg/apis/cluster/v1alpha1/...✅ (26/26 pass)Fixes #4660