Skip to content

Commit

Permalink
fix: allow updateStrategy.rollingUpdate.maxUnavailable to be passed i…
Browse files Browse the repository at this point in the history
…n as an int or string
  • Loading branch information
hrivera-ntap authored Aug 21, 2023
1 parent 607b808 commit 0dcc834
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
10 changes: 7 additions & 3 deletions traefik/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
27 changes: 26 additions & 1 deletion traefik/tests/daemonset-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 0dcc834

Please sign in to comment.