mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-03 21:53:20 +09:00
fix(kubernetes-nodes): surge one worker at a time during a pool rollout (#5399)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, security (a fix that comes through a security advisory), docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Fixes merged to `main` reach the release lines the backport batch runs for automatically, so do not open backport PRs by hand: https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md --> ## What this PR does A worker pool rollout (instance type, image or version change) currently surges up to `maxReplicas` new VMs before draining an old one, so a pool running 8 workers under a ceiling of 10 can reach 18 VMs at its peak. Those VMs land in the tenant's namespace: today they count against its `ResourceQuota`, and under [tenant quotas as reservation limits](https://github.com/cozystack/community/pull/48), where a pool reserves `maxReplicas` workers, they are capacity nobody reserved. This PR fixes the surge at one Machine per pool. The surge is treated as platform margin rather than tenant budget: rollouts are mostly platform-driven, and charging them to the tenant would block a platform upgrade for any tenant whose pool sits at its ceiling. Bounding that margin is what this PR does. `maxUnavailable` is untouched, so a node is still only drained once its replacement is up (#5153). The value is the open question for maintainers. **1** keeps the loan to a single worker per pool and is what this PR ships; a large pool then rolls one worker at a time. **2** halves the rollout time of a large pool at twice the margin. I would rather not make it a chart value, since tenants write the values and would then size the platform's margin themselves. Tested with `helm unittest` on `kubernetes-nodes`; the three golden renders change only in `maxSurge`. Refs: cozystack/community#48, cozystack/cozystack#5397 ### Screenshots Not a UI change. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> I walked the trigger map against the diff: one template line, its comment and its tests. No values key, schema, default, version enum or release name changes. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(kubernetes-nodes): a worker pool rollout now adds one replacement worker at a time instead of up to the pool's maxReplicas, bounding the extra capacity a rollout uses in the tenant's namespace. Large pools roll out more slowly. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Behavior Changes** * Rolling updates now allow a fixed surge of one worker at a time, regardless of the pool’s maximum replica count. Pools with higher replica limits no longer increase the surge allowance. This change applies even when the pool’s minimum and maximum replica counts are both set to five. The existing default and explicitly configured `maxUnavailable` behavior remain unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
3 files changed
+17
-8
No files matched your search
@@ -1066,15 +1066,21 @@ spec:
|
||||
joined. A pool with passed-through GPUs keeps 1: its replacement VM
|
||||
may need the very GPU the old node holds, and would wait for it
|
||||
forever. A Proxmox template's GPU is invisible here, hence the
|
||||
maxUnavailable override. CAPI refuses maxSurge and maxUnavailable both
|
||||
at 0, and maxReplicas may be 0, hence the floor of 1. */}}
|
||||
maxUnavailable override.
|
||||
maxSurge is one Machine whatever the pool's size. A tenant's quota
|
||||
reserves maxReplicas workers, and the surge runs on top of whatever
|
||||
the pool runs, so it is capacity the platform lends during a rollout;
|
||||
a fixed surge bounds that loan to one worker per pool. It is not a
|
||||
value because tenants write the values, and would then size the
|
||||
platform's margin themselves. CAPI refuses maxSurge and
|
||||
maxUnavailable both at 0, so it cannot be 0 either. */}}
|
||||
{{- $maxUnavailable := ternary 1 0 (not (empty $group.gpus)) }}
|
||||
{{- if not (kindIs "invalid" $.Values.maxUnavailable) }}
|
||||
{{- $maxUnavailable = $.Values.maxUnavailable | int }}
|
||||
{{- end }}
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: {{ max 1 ($group.maxReplicas | int) }}
|
||||
maxSurge: 1
|
||||
maxUnavailable: {{ $maxUnavailable }}
|
||||
type: RollingUpdate
|
||||
selector:
|
||||
|
||||
@@ -99,7 +99,7 @@ matches the golden render of a GPU pool:
|
||||
cluster.x-k8s.io/deployment-name: kubernetes-myk8s-md0
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 3
|
||||
maxSurge: 1
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
@@ -254,7 +254,7 @@ matches the golden render of a kubelet-override pool:
|
||||
cluster.x-k8s.io/deployment-name: kubernetes-myk8s-md0
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 3
|
||||
maxSurge: 1
|
||||
maxUnavailable: 0
|
||||
type: RollingUpdate
|
||||
template:
|
||||
@@ -411,7 +411,7 @@ matches the golden render of the pool objects:
|
||||
cluster.x-k8s.io/deployment-name: kubernetes-myk8s-md0
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 3
|
||||
maxSurge: 1
|
||||
maxUnavailable: 0
|
||||
type: RollingUpdate
|
||||
template:
|
||||
|
||||
@@ -36,8 +36,11 @@ tests:
|
||||
path: spec.strategy.rollingUpdate.maxSurge
|
||||
value: 1
|
||||
|
||||
- it: surges up to the pool ceiling
|
||||
# The tenant's quota reserves maxReplicas workers; the surge runs on top
|
||||
# of them, so it is bounded to one worker whatever the pool's size.
|
||||
- it: surges one worker at a time whatever the pool ceiling
|
||||
set:
|
||||
minReplicas: 5
|
||||
maxReplicas: 5
|
||||
documentSelector:
|
||||
path: kind
|
||||
@@ -45,7 +48,7 @@ tests:
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.strategy.rollingUpdate.maxSurge
|
||||
value: 5
|
||||
value: 1
|
||||
- equal:
|
||||
path: spec.strategy.rollingUpdate.maxUnavailable
|
||||
value: 0
|
||||
|
||||
Reference in new issue
Block a user