mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
fix(kubernetes-nodes): refuse minReplicas above maxReplicas on GPU class pools
CAPI starts a new pool at its min-size annotation without comparing it with the max, so a pool with minReplicas above maxReplicas has no consistent size. With class entries that also breaks the count times maxReplicas GPUs the pool is meant to hold, so the chart stops instead of rendering it. Pools without class entries keep rendering as before, and no released pool can carry class entries. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
2 files changed
+154
No files matched your search
@@ -38,6 +38,16 @@
|
||||
{{- if not (has $substrate (list "kubevirt" "proxmox")) }}
|
||||
{{- fail (printf "substrate %q is not supported; use \"kubevirt\" or \"proxmox\"" $substrate) }}
|
||||
{{- end }}
|
||||
{{- /* CAPI starts a new pool at its min-size annotation without comparing it
|
||||
with the max, so a pool with class entries and minReplicas above
|
||||
maxReplicas would run more GPUs than count times maxReplicas. */}}
|
||||
{{- $hasClassEntries := false }}
|
||||
{{- range (.Values.gpus | default list) }}
|
||||
{{- if and (kindIs "map" .) .className }}{{ $hasClassEntries = true }}{{ end }}
|
||||
{{- end }}
|
||||
{{- if and $hasClassEntries (gt (int64 .Values.minReplicas) (int64 .Values.maxReplicas)) }}
|
||||
{{- fail (printf "minReplicas (%v) must not exceed maxReplicas (%v) on a pool with GPU class entries" .Values.minReplicas .Values.maxReplicas) }}
|
||||
{{- end }}
|
||||
{{- $isProxmox := eq $substrate "proxmox" }}
|
||||
{{- $vpc := "" }}
|
||||
{{- with dig "name" "" (.Values.network | default dict) }}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
suite: worker pool replica bounds with GPU class entries
|
||||
# CAPI starts a new pool at its min-size annotation without comparing it with
|
||||
# the max, so minReplicas above maxReplicas on a pool with class entries would
|
||||
# run more GPUs than count times maxReplicas. Pools without class entries
|
||||
# render as they always did.
|
||||
templates:
|
||||
- templates/nodegroup.yaml
|
||||
release:
|
||||
name: kubernetes-nodes-myk8s-md0
|
||||
namespace: tenant-test
|
||||
set:
|
||||
cluster: myk8s
|
||||
_cluster:
|
||||
cluster-domain: cozy.local
|
||||
gpu-vm-enabled: "true"
|
||||
version: "v1.35"
|
||||
instanceType: ""
|
||||
diskSize: 20Gi
|
||||
storageClass: replicated
|
||||
resources:
|
||||
cpu: "2"
|
||||
memory: 4Gi
|
||||
tests:
|
||||
- it: refuses minReplicas above maxReplicas on a pool with class entries
|
||||
set:
|
||||
minReplicas: 4
|
||||
maxReplicas: 3
|
||||
gpus:
|
||||
- className: h100
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: minReplicas \(4\) must not exceed maxReplicas \(3\) on a pool with GPU class entries
|
||||
|
||||
- it: renders a pool without GPUs whose minReplicas is above maxReplicas as before
|
||||
set:
|
||||
minReplicas: 4
|
||||
maxReplicas: 3
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size"]
|
||||
value: "4"
|
||||
|
||||
- it: renders a raw-name GPU pool whose minReplicas is above maxReplicas as before
|
||||
set:
|
||||
minReplicas: 4
|
||||
maxReplicas: 3
|
||||
gpus:
|
||||
- name: nvidia.com/AD102GL_L40S
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size"]
|
||||
value: "3"
|
||||
|
||||
- it: accepts minReplicas equal to maxReplicas without GPUs
|
||||
set:
|
||||
minReplicas: 3
|
||||
maxReplicas: 3
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size"]
|
||||
value: "3"
|
||||
|
||||
- it: accepts minReplicas equal to maxReplicas with class entries
|
||||
kubernetesProvider: &gpuClassProvider
|
||||
scheme:
|
||||
"cluster.x-k8s.io/v1beta1/MachineSet":
|
||||
gvr:
|
||||
group: "cluster.x-k8s.io"
|
||||
version: "v1beta1"
|
||||
resource: "machinesets"
|
||||
namespaced: true
|
||||
"infrastructure.cluster.x-k8s.io/v1alpha1/KubevirtMachineTemplate":
|
||||
gvr:
|
||||
group: "infrastructure.cluster.x-k8s.io"
|
||||
version: "v1alpha1"
|
||||
resource: "kubevirtmachinetemplates"
|
||||
namespaced: true
|
||||
"cozystack.io/v1alpha1/GPUClass":
|
||||
gvr:
|
||||
group: "cozystack.io"
|
||||
version: "v1alpha1"
|
||||
resource: "gpuclasses"
|
||||
namespaced: false
|
||||
objects:
|
||||
# The pool lists these kinds; the fake client needs one of each to
|
||||
# know them.
|
||||
- apiVersion: cluster.x-k8s.io/v1beta1
|
||||
kind: MachineSet
|
||||
metadata:
|
||||
name: unrelated
|
||||
namespace: tenant-other
|
||||
- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
|
||||
kind: KubevirtMachineTemplate
|
||||
metadata:
|
||||
name: unrelated
|
||||
namespace: tenant-other
|
||||
- apiVersion: cozystack.io/v1alpha1
|
||||
kind: GPUClass
|
||||
metadata:
|
||||
name: h100
|
||||
spec:
|
||||
vendor: nvidia
|
||||
model: H100
|
||||
mode: passthrough
|
||||
source:
|
||||
devicePlugin:
|
||||
resourceName: example.com/accelerator
|
||||
set:
|
||||
minReplicas: 3
|
||||
maxReplicas: 3
|
||||
gpus:
|
||||
- className: h100
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size"]
|
||||
value: "3"
|
||||
|
||||
- it: accepts a class pool that leaves minReplicas and maxReplicas at their defaults
|
||||
kubernetesProvider: *gpuClassProvider
|
||||
set:
|
||||
gpus:
|
||||
- className: h100
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: MachineDeployment
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size"]
|
||||
value: "0"
|
||||
- equal:
|
||||
path: metadata.annotations["cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size"]
|
||||
value: "10"
|
||||
Reference in new issue
Block a user