diff --git a/library/common-test/tests/addons/autoperms_test.yaml b/library/common-test/tests/addons/autoperms_test.yaml index 1d71e40e..8e2162d6 100644 --- a/library/common-test/tests/addons/autoperms_test.yaml +++ b/library/common-test/tests/addons/autoperms_test.yaml @@ -175,6 +175,7 @@ tests: name: tmp emptyDir: medium: Memory + sizeLimit: 8Gi - documentIndex: *jobDoc contains: path: spec.template.spec.containers[0].volumeMounts @@ -511,6 +512,7 @@ tests: name: tmp emptyDir: medium: Memory + sizeLimit: 8Gi - documentIndex: *jobDoc contains: path: spec.template.spec.containers[0].volumeMounts diff --git a/library/common-test/tests/defaults/defaults-test.yaml b/library/common-test/tests/defaults/defaults-test.yaml index 7afd386c..a5ace589 100644 --- a/library/common-test/tests/defaults/defaults-test.yaml +++ b/library/common-test/tests/defaults/defaults-test.yaml @@ -90,17 +90,21 @@ tests: - name: devshm emptyDir: medium: Memory + sizeLimit: 8Gi - name: shared emptyDir: {} - name: tmp emptyDir: medium: Memory + sizeLimit: 8Gi - name: varlogs emptyDir: medium: Memory + sizeLimit: 8Gi - name: varrun emptyDir: medium: Memory + sizeLimit: 8Gi - documentIndex: *deploymentDoc isSubset: path: spec.template.spec.containers[0] diff --git a/library/common-test/tests/pod/volume_emptyDIr_test.yaml b/library/common-test/tests/pod/volume_emptyDIr_test.yaml index a64bcd8d..841b3076 100644 --- a/library/common-test/tests/pod/volume_emptyDIr_test.yaml +++ b/library/common-test/tests/pod/volume_emptyDIr_test.yaml @@ -81,6 +81,7 @@ tests: name: emptyDir-vol emptyDir: medium: Memory + sizeLimit: 8Gi - it: should pass with emptyDir volume with size set set: @@ -107,6 +108,65 @@ tests: emptyDir: sizeLimit: 3Gi + - it: should pass with emptyDir volume with medium Memory and size from resource limits + set: + resources: + limits: + memory: 500Mi + workload: + workload-name1: + enabled: true + primary: true + type: Deployment + podSpec: {} + persistence: + emptyDir-vol: + enabled: true + type: emptyDir + medium: Memory + asserts: + - documentIndex: &deploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *deploymentDoc + contains: + path: spec.template.spec.volumes + content: + name: emptyDir-vol + emptyDir: + medium: Memory + sizeLimit: 500Mi + + - it: should pass with emptyDir volume with medium Memory and size override + set: + resources: + limits: + memory: 500Mi + workload: + workload-name1: + enabled: true + primary: true + type: Deployment + podSpec: {} + persistence: + emptyDir-vol: + enabled: true + type: emptyDir + medium: Memory + size: 1Gi + asserts: + - documentIndex: &deploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *deploymentDoc + contains: + path: spec.template.spec.volumes + content: + name: emptyDir-vol + emptyDir: + medium: Memory + sizeLimit: 1Gi + # Failures - it: should fail with invalid medium in emptyDir set: diff --git a/library/common/templates/lib/pod/volumes/_emptyDir.tpl b/library/common/templates/lib/pod/volumes/_emptyDir.tpl index 481cdf0f..cdf0bc1b 100644 --- a/library/common/templates/lib/pod/volumes/_emptyDir.tpl +++ b/library/common/templates/lib/pod/volumes/_emptyDir.tpl @@ -23,6 +23,8 @@ objectData: The object data to be used to render the volume. {{- $formats := "(Suffixed with E/P/T/G/M/K - eg. 1G), (Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi), (Plain Integer in bytes - eg. 1024), (Exponent - eg. 134e6)" -}} {{- fail (printf "Persistence Expected [size] to have one of the following formats [%s], but got [%s]" $formats $size) -}} {{- end -}} + {{- else if eq $medium "Memory" -}} + {{- $size = $rootCtx.Values.resources.limits.memory -}} {{- end -}} {{- if and $medium (ne $medium "Memory") -}}