From 0dcc834757507baa93131ca799cf0fddcf2eeddd Mon Sep 17 00:00:00 2001 From: Robert Hunter <70445595+hrivera-ntap@users.noreply.github.com> Date: Mon, 21 Aug 2023 03:06:06 -0400 Subject: [PATCH] fix: allow updateStrategy.rollingUpdate.maxUnavailable to be passed in as an int or string --- traefik/templates/daemonset.yaml | 10 ++++++--- traefik/tests/daemonset-config_test.yaml | 27 +++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/traefik/templates/daemonset.yaml b/traefik/templates/daemonset.yaml index 3125f22c7..4814ac5ff 100644 --- a/traefik/templates/daemonset.yaml +++ b/traefik/templates/daemonset.yaml @@ -9,9 +9,13 @@ {{- if eq (default .Chart.AppVersion .Values.image.tag) "latest" }} {{- fail "\n\n ERROR: latest tag should not be used" }} {{- end }} - {{- if eq (.Values.updateStrategy.type) "RollingUpdate" }} - {{- if and (lt .Values.updateStrategy.rollingUpdate.maxUnavailable 1.0) (.Values.hostNetwork) }} - {{- fail "maxUnavailable should be greater than 1 when using hostNetwork." }} + {{- with .Values.updateStrategy }} + {{- if eq (.type) "RollingUpdate" }} + {{- if not (contains "%" (toString .rollingUpdate.maxUnavailable)) }} + {{- if and ($.Values.hostNetwork) (lt (float64 .rollingUpdate.maxUnavailable) 1.0) }} + {{- fail "maxUnavailable should be greater than 1 when using hostNetwork." }} + {{- end }} + {{- end }} {{- end }} {{- end }} diff --git a/traefik/tests/daemonset-config_test.yaml b/traefik/tests/daemonset-config_test.yaml index 065d73001..ea47c1520 100644 --- a/traefik/tests/daemonset-config_test.yaml +++ b/traefik/tests/daemonset-config_test.yaml @@ -103,7 +103,7 @@ tests: - equal: path: spec.template.spec.containers[0].lifecycle.postStart.httpGet.scheme value: HTTP - - it: should fail when hostNetwork and default maxUnavailable 0 + - it: should fail when hostNetwork and default maxUnavailable 0 (int) set: deployment: kind: DaemonSet @@ -115,6 +115,31 @@ tests: asserts: - failedTemplate: errorMessage: "maxUnavailable should be greater than 1 when using hostNetwork." + - it: should fail when hostNetwork and maxUnavailable 0 (string) + set: + deployment: + kind: DaemonSet + updateStrategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: "0" + hostNetwork: true + asserts: + - failedTemplate: + errorMessage: "maxUnavailable should be greater than 1 when using hostNetwork." + - it: should not fail when hostNetwork and maxUnavailable is a percentage + set: + deployment: + kind: DaemonSet + updateStrategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: "10%" + hostNetwork: true + asserts: + - equal: + path: spec.updateStrategy.rollingUpdate.maxUnavailable + value: "10%" - it: should have an OnDelete updateStrategy when set set: deployment: