fix rollUp

This commit is contained in:
Stavros kois
2023-02-13 20:46:04 +02:00
parent f5689dc400
commit a424e56cf5
9 changed files with 156 additions and 141 deletions

View File

@@ -24,30 +24,6 @@ tests:
revisionHistoryLimit: 3
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
- it: should apply defaults to rollingUpdate
set:
workload:
workload-name:
enabled: true
primary: true
type: DaemonSet
replicas: 2
revisionHistoryLimit: 4
strategy: RollingUpdate
podSpec: {}
asserts:
- documentIndex: *daemonSetDoc
isSubset:
path: spec.updateStrategy
content:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
- it: should apply spec correctly
set:
@@ -73,3 +49,45 @@ tests:
rollingUpdate:
maxSurge: 5
maxUnavailable: 5
- it: should apply maxSurge with 0
set:
workload:
workload-name:
enabled: true
primary: true
type: DaemonSet
strategy: RollingUpdate
rollingUpdate:
maxSurge: 0
podSpec: {}
asserts:
- documentIndex: *daemonSetDoc
isSubset:
path: spec
content:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
- it: should apply maxUnavailable with 0
set:
workload:
workload-name:
enabled: true
primary: true
type: DaemonSet
strategy: RollingUpdate
rollingUpdate:
maxUnavailable: 0
podSpec: {}
asserts:
- documentIndex: *daemonSetDoc
isSubset:
path: spec
content:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0

View File

@@ -28,22 +28,3 @@ tests:
asserts:
- failedTemplate:
errorMessage: DaemonSet - Expected <rollingUpdate> to be a dictionary, but got [string]
- it: should fail with both maxSurge and maxUnavailable set to 0
set:
fallbackDefaults:
maxSurge: 0
maxUnavailable: 0
workload:
workload-name:
enabled: true
primary: true
type: DaemonSet
strategy: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 0
podSpec: {}
asserts:
- failedTemplate:
errorMessage: DaemonSet - Cannot have <maxSurge> and <maxUnavailable> both set to 0

View File

@@ -26,27 +26,6 @@ tests:
strategy:
type: Recreate
- it: should apply defaults to rollingUpdate
set:
workload:
workload-name:
enabled: true
primary: true
type: Deployment
replicas: 2
revisionHistoryLimit: 4
strategy: RollingUpdate
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
isSubset:
path: spec.strategy
content:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
- it: should apply spec correctly
set:
workload:
@@ -73,3 +52,45 @@ tests:
rollingUpdate:
maxSurge: 5
maxUnavailable: 5
- it: should apply maxSurge with 0
set:
workload:
workload-name:
enabled: true
primary: true
type: Deployment
strategy: RollingUpdate
rollingUpdate:
maxSurge: 0
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
isSubset:
path: spec
content:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
- it: should apply maxUnavailable with 0
set:
workload:
workload-name:
enabled: true
primary: true
type: Deployment
strategy: RollingUpdate
rollingUpdate:
maxUnavailable: 0
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
isSubset:
path: spec
content:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0

View File

@@ -28,22 +28,3 @@ tests:
asserts:
- failedTemplate:
errorMessage: Deployment - Expected <rollingUpdate> to be a dictionary, but got [string]
- it: should fail with both maxSurge and maxUnavailable set to 0
set:
fallbackDefaults:
maxSurge: 0
maxUnavailable: 0
workload:
workload-name:
enabled: true
primary: true
type: Deployment
strategy: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 0
podSpec: {}
asserts:
- failedTemplate:
errorMessage: Deployment - Cannot have <maxSurge> and <maxUnavailable> both set to 0

View File

@@ -24,30 +24,6 @@ tests:
revisionHistoryLimit: 3
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
partition: 1
- it: should apply defaults to rollingUpdate
set:
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
replicas: 2
revisionHistoryLimit: 4
strategy: RollingUpdate
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
isSubset:
path: spec.updateStrategy
content:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
partition: 1
- it: should apply spec correctly
set:
@@ -73,3 +49,45 @@ tests:
rollingUpdate:
partition: 5
maxUnavailable: 5
- it: should apply partition with 0
set:
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
strategy: RollingUpdate
rollingUpdate:
partition: 0
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
isSubset:
path: spec
content:
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
- it: should apply maxUnavailable with 0
set:
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
strategy: RollingUpdate
rollingUpdate:
maxUnavailable: 0
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
isSubset:
path: spec
content:
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0

View File

@@ -14,17 +14,16 @@ objectData:
revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }}
updateStrategy:
type: {{ $strategy }}
{{- if eq $strategy "RollingUpdate" }}
{{- if not $objectData.rollingUpdate -}} {{/* Create the key if it does not exist, to avoid nil pointers */}}
{{- $_ := set $objectData "rollingUpdate" dict -}}
{{- end }}
{{- if and
(eq $objectData.strategy "RollingUpdate")
$objectData.rollingUpdate
(or (hasKey $objectData.rollingUpdate "maxUnavailable") (hasKey $objectData.rollingUpdate "maxSurge")) }}
rollingUpdate:
{{- $maxSurge := $objectData.rollingUpdate.maxSurge | default $rootCtx.Values.fallbackDefaults.maxSurge -}}
{{- $maxUnavailable := $objectData.rollingUpdate.maxUnavailable | default $rootCtx.Values.fallbackDefaults.maxUnavailable -}}
{{- if and (eq (int $maxSurge) 0) (eq (int $maxUnavailable) 0) -}}
{{- fail "DaemonSet - Cannot have <maxSurge> and <maxUnavailable> both set to 0" -}}
{{- end }}
maxUnavailable: {{ $maxUnavailable }}
maxSurge: {{ $maxSurge }}
{{- if hasKey $objectData.rollingUpdate "maxUnavailable" }}
maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable }}
{{- end -}}
{{- if hasKey $objectData.rollingUpdate "maxSurge" }}
maxSurge: {{ $objectData.rollingUpdate.maxSurge }}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -15,17 +15,16 @@ replicas: {{ $objectData.replicas | default 1 }}
revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }}
strategy:
type: {{ $strategy }}
{{- if eq $strategy "RollingUpdate" }}
{{- if not $objectData.rollingUpdate -}} {{/* Create the key if it does not exist, to avoid nil pointers */}}
{{- $_ := set $objectData "rollingUpdate" dict -}}
{{- end }}
{{- if and
(eq $objectData.strategy "RollingUpdate")
$objectData.rollingUpdate
(or (hasKey $objectData.rollingUpdate "maxUnavailable") (hasKey $objectData.rollingUpdate "partition")) }}
rollingUpdate:
{{- $maxSurge := $objectData.rollingUpdate.maxSurge | default $rootCtx.Values.fallbackDefaults.maxSurge -}}
{{- $maxUnavailable := $objectData.rollingUpdate.maxUnavailable | default $rootCtx.Values.fallbackDefaults.maxUnavailable -}}
{{- if and (eq (int $maxSurge) 0) (eq (int $maxUnavailable) 0) -}}
{{- fail "Deployment - Cannot have <maxSurge> and <maxUnavailable> both set to 0" -}}
{{- end }}
maxUnavailable: {{ $maxUnavailable }}
maxSurge: {{ $maxSurge }}
{{- if hasKey $objectData.rollingUpdate "maxUnavailable" }}
maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable }}
{{- end -}}
{{- if hasKey $objectData.rollingUpdate "maxSurge" }}
maxSurge: {{ $objectData.rollingUpdate.maxSurge }}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -16,12 +16,16 @@ revisionHistoryLimit: {{ $objectData.revisionHistoryLimit | default 3 }}
serviceName: {{ $objectData.name }}
updateStrategy:
type: {{ $strategy }}
{{- if eq $strategy "RollingUpdate" }}
{{- if and
(eq $objectData.strategy "RollingUpdate")
$objectData.rollingUpdate
(or (hasKey $objectData.rollingUpdate "maxUnavailable") (hasKey $objectData.rollingUpdate "partition")) }}
rollingUpdate:
{{- if not $objectData.rollingUpdate -}} {{/* Create the key if it does not exist, to avoid nil pointers */}}
{{- $_ := set $objectData "rollingUpdate" dict -}}
{{- end }}
maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable | default $rootCtx.Values.fallbackDefaults.maxUnavailable }}
partition: {{ $objectData.rollingUpdate.partition | default $rootCtx.Values.fallbackDefaults.partition }}
{{- if hasKey $objectData.rollingUpdate "maxUnavailable" }}
maxUnavailable: {{ $objectData.rollingUpdate.maxUnavailable }}
{{- end -}}
{{- if hasKey $objectData.rollingUpdate "partition" }}
partition: {{ $objectData.rollingUpdate.partition }}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@@ -17,12 +17,6 @@ fallbackDefaults:
# -- Define a storageClassName that will be used for all PVCs
# Can be overruled per PVC
storageClass:
# -- Default maxUnavailable
maxUnavailable: 1
# -- Default maxSurge
maxSurge: 0
# -- Default partition (StatefulSet only)
partition: 1
# -- Default probe type
probeType: http
# -- Default Service Protocol