mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-23 21:25:44 +09:00
fix(cozy-lib): render tenant hugepages quota only as requests
A tenant with hugepages-2Mi or hugepages-1Gi in resourceQuotas got both requests.hugepages-<size> and limits.hugepages-<size> in tenant-quota. A ResourceQuota accepts huge pages only as hugepages-<size> or requests.hugepages-<size>, so the apiserver rejects tenant-quota and the tenant release fails to install or upgrade. Huge pages are not counted in limits.memory either, so without this key a VM whose memory is backed by huge pages runs outside the tenant quota. The limits side is dropped for hugepages-* the same way it already is for storage. sanitize still emits equal requests and limits, which is what a pod spec needs for huge pages, so only the quota rendering changes. Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Assisted-by: LLM
This commit is contained in:
1 parent
4087218a02
commit
38a32445f7
3 files changed
+36
No files matched your search
@@ -104,6 +104,7 @@ The `resourceQuotas` parameter allows you to limit resources available to the te
|
||||
- `memory` - Total memory (e.g., `"4Gi"` or `"512Mi"`)
|
||||
- `ephemeral-storage` - Ephemeral storage limit (e.g., `"10Gi"`)
|
||||
- `storage` - Total persistent storage (e.g., `"100Gi"`)
|
||||
- `hugepages-2Mi`, `hugepages-1Gi` - Total huge pages of that size (e.g., `"4Gi"`), converted to `requests.hugepages-<size>` only, as Kubernetes has no limits quota for huge pages
|
||||
|
||||
**Object count quotas** (passed as-is):
|
||||
- `pods` - Maximum number of pods
|
||||
|
||||
@@ -239,6 +239,12 @@
|
||||
{{- $out := "" }}
|
||||
{{- if and (eq $section "limits") (eq $type "storage") }}
|
||||
{{- $out = "" }}
|
||||
{{- /*
|
||||
A ResourceQuota accepts hugepages only as requests.hugepages-<size>,
|
||||
limits.hugepages-<size> is rejected and the whole quota with it.
|
||||
*/}}
|
||||
{{- else if and (eq $section "limits") (hasPrefix "hugepages-" $type) }}
|
||||
{{- $out = "" }}
|
||||
{{- else if and (eq $section "limits") (has $type $rawQuotaKeys) }}
|
||||
{{- $out = $type }}
|
||||
{{- else if not (has $type $rawQuotaKeys) }}
|
||||
|
||||
@@ -48,3 +48,32 @@ tests:
|
||||
|
||||
- notExists:
|
||||
path: spec.hard["requests.services.loadbalancers"]
|
||||
|
||||
- it: renders hugepages only as requests
|
||||
set:
|
||||
quota:
|
||||
hugepages-2Mi: "4Gi"
|
||||
hugepages-1Gi: "2Gi"
|
||||
_cluster: {}
|
||||
_namespace: {}
|
||||
|
||||
release:
|
||||
name: myrelease
|
||||
namespace: default
|
||||
revision: 1
|
||||
isUpgrade: false
|
||||
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.hard["requests.hugepages-2Mi"]
|
||||
value: "4Gi"
|
||||
|
||||
- equal:
|
||||
path: spec.hard["requests.hugepages-1Gi"]
|
||||
value: "2Gi"
|
||||
|
||||
- notExists:
|
||||
path: spec.hard["limits.hugepages-2Mi"]
|
||||
|
||||
- notExists:
|
||||
path: spec.hard["limits.hugepages-1Gi"]
|
||||
Reference in new issue
Block a user