diff --git a/hack/e2e-apps/vminstance.bats b/hack/e2e-apps/vminstance.bats index eb5996bf..60513e8e 100644 --- a/hack/e2e-apps/vminstance.bats +++ b/hack/e2e-apps/vminstance.bats @@ -18,8 +18,8 @@ spec: EOF sleep 5 kubectl -n tenant-test wait hr vm-disk-$name --timeout=5s --for=condition=ready - kubectl -n tenant-test wait dv vm-disk-$name --timeout=150s --for=condition=ready - kubectl -n tenant-test wait pvc vm-disk-$name --timeout=100s --for=jsonpath='{.status.phase}'=Bound + kubectl -n tenant-test wait dv vm-disk-$name --timeout=250s --for=condition=ready + kubectl -n tenant-test wait pvc vm-disk-$name --timeout=200s --for=jsonpath='{.status.phase}'=Bound } @test "Create a VM Instance" { diff --git a/hack/e2e-install-cozystack.bats b/hack/e2e-install-cozystack.bats index 23d1b6c4..50b6a071 100644 --- a/hack/e2e-install-cozystack.bats +++ b/hack/e2e-install-cozystack.bats @@ -123,6 +123,7 @@ EOF @test "Configure Tenant and wait for applications" { # Patch root tenant and wait for its releases + kubectl patch tenants/root -n tenant-root --type merge -p '{"spec":{"host":"example.org","ingress":true,"monitoring":true,"etcd":true,"isolated":true, "seaweedfs": true}}' timeout 60 sh -ec 'until kubectl get hr -n tenant-root etcd ingress monitoring seaweedfs tenant-root >/dev/null 2>&1; do sleep 1; done' @@ -188,9 +189,22 @@ spec: ingress: false isolated: true monitoring: false - resourceQuotas: {} + resourceQuotas: + cpu: "60" + memory: "128Gi" + storage: "100Gi" seaweedfs: false EOF kubectl wait hr/tenant-test -n tenant-root --timeout=1m --for=condition=ready kubectl wait namespace tenant-test --timeout=20s --for=jsonpath='{.status.phase}'=Active + # Wait for ResourceQuota to appear and assert values + timeout 60 sh -ec 'until [ "$(kubectl get quota -n tenant-test --no-headers 2>/dev/null | wc -l)" -ge 1 ]; do sleep 1; done' + kubectl get quota -n tenant-test \ + -o jsonpath='{range .items[*]}{.spec.hard.requests\.memory}{" "}{.spec.hard.requests\.storage}{"\n"}{end}' \ + | grep -qx '137438953472 100Gi' + + # Assert LimitRange defaults for containers + kubectl get limitrange -n tenant-test \ + -o jsonpath='{range .items[*].spec.limits[*]}{.default.cpu}{" "}{.default.memory}{" "}{.defaultRequest.cpu}{" "}{.defaultRequest.memory}{"\n"}{end}' \ + | grep -qx '250m 128Mi 25m 128Mi' } diff --git a/packages/apps/tenant/templates/quota.yaml b/packages/apps/tenant/templates/quota.yaml index 43941f56..6962d7c3 100644 --- a/packages/apps/tenant/templates/quota.yaml +++ b/packages/apps/tenant/templates/quota.yaml @@ -7,4 +7,21 @@ metadata: spec: hard: {{- include "cozy-lib.resources.flatten" (list .Values.resourceQuotas $) | nindent 6 }} +--- +apiVersion: v1 +kind: LimitRange +metadata: + name: tenant-range-limits + namespace: {{ include "tenant.name" . }} +spec: + limits: + - default: + cpu: "250m" + memory: "128Mi" + ephemeral-storage: "2Gi" + defaultRequest: + cpu: "25m" + memory: "128Mi" + ephemeral-storage: "50Mi" + type: Container {{- end }} diff --git a/packages/library/cozy-lib/templates/_resources.tpl b/packages/library/cozy-lib/templates/_resources.tpl index 9c335e53..637d04f6 100644 --- a/packages/library/cozy-lib/templates/_resources.tpl +++ b/packages/library/cozy-lib/templates/_resources.tpl @@ -179,8 +179,10 @@ {{- range $section, $values := $res }} {{- range $k, $v := $values }} {{- $key := printf "%s.%s" $section $k }} - {{- $_ := set $out $key $v }} + {{- if ne $key "limits.storage" }} + {{- $_ := set $out $key $v }} + {{- end }} {{- end }} {{- end }} -{{- dict "resourceQuotas" $out | toYaml }} +{{- $out | toYaml }} {{- end }}