From 37d85627959865920f5e7713ca6f92d33f154ec5 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Mon, 13 Feb 2023 19:18:35 +0200 Subject: [PATCH] fix an edge case --- .../common-test/ci/statefulset-values.yaml | 4 +- .../validation/_workloadValidation.tpl | 7 ++- .../1.0.0/templates/spawner/_workload.tpl | 5 ++ library/common/1.0.0/values.yaml | 54 +++++++++---------- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/library/common-test/ci/statefulset-values.yaml b/library/common-test/ci/statefulset-values.yaml index da2a6bbbfa..76db296fc1 100644 --- a/library/common-test/ci/statefulset-values.yaml +++ b/library/common-test/ci/statefulset-values.yaml @@ -12,8 +12,8 @@ service: workload: main: - type: StatefulSet - pod: + type: DaemonSet + podSpec: containers: main: args: diff --git a/library/common/1.0.0/templates/lib/workload/validation/_workloadValidation.tpl b/library/common/1.0.0/templates/lib/workload/validation/_workloadValidation.tpl index f80b0a8baf..25df76a277 100644 --- a/library/common/1.0.0/templates/lib/workload/validation/_workloadValidation.tpl +++ b/library/common/1.0.0/templates/lib/workload/validation/_workloadValidation.tpl @@ -21,8 +21,7 @@ {{- $hasEnabled = true -}} {{/* And workload is primary */}} - {{- if and (hasKey $workload "primary") ($workload.primary) -}} - + {{- if $workload.primary -}} {{/* Fail if there is already a primary workload */}} {{- if $hasPrimary -}} {{- fail "Workload - Only one workload can be primary" -}} @@ -35,9 +34,9 @@ {{- end -}} - {{/* Require at least one primary workload, if any enabled */}} + {{/* Require at one primary workload, if any enabled */}} {{- if and $hasEnabled (not $hasPrimary) -}} - {{- fail "Workload - At least one enabled workload must be primary" -}} + {{- fail "Workload - One enabled workload must be primary" -}} {{- end -}} {{- end -}} diff --git a/library/common/1.0.0/templates/spawner/_workload.tpl b/library/common/1.0.0/templates/spawner/_workload.tpl index 16a3031082..444de4167d 100644 --- a/library/common/1.0.0/templates/spawner/_workload.tpl +++ b/library/common/1.0.0/templates/spawner/_workload.tpl @@ -31,6 +31,11 @@ {{/* Short name is the one that defined on the chart, used on selectors */}} {{- $_ := set $objectData "shortName" $name -}} + {{/* Set the podSpec so it doesn't fail on nil pointer */}} + {{- if not (hasKey $objectData "podSpec") -}} + {{ $_ := set $objectData "podSpec" dict }} + {{- end -}} + {{/* Call class to create the object */}} {{- if eq $objectData.type "Deployment" -}} {{- include "ix.v1.common.class.deployment" (dict "rootCtx" $ "objectData" $objectData) -}} diff --git a/library/common/1.0.0/values.yaml b/library/common/1.0.0/values.yaml index 6a6cb407b2..0f8f18551c 100644 --- a/library/common/1.0.0/values.yaml +++ b/library/common/1.0.0/values.yaml @@ -149,7 +149,6 @@ workload: enabled: true primary: true imageSelector: image - # TODO: Currently implementing probes: liveness: enabled: true @@ -163,32 +162,33 @@ workload: enabled: true type: http port: "{{ .Values.service.main.ports.main.port }}" - securityContext: - runAsNonRoot: true - runAsUser: 568 - runAsGroup: 568 - readOnlyRootFilesystem: true - allowPrivilegeEscalation: false - privileged: false - capabilities: - add: [] - drop: - - ALL - env: {} - envList: [] - envFrom: [] - resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi - initContainers: - init-cont-name: - enabled: false - type: install - # ...containerSpec + # # TODO: Currently implementing + # securityContext: + # runAsNonRoot: true + # runAsUser: 568 + # runAsGroup: 568 + # readOnlyRootFilesystem: true + # allowPrivilegeEscalation: false + # privileged: false + # capabilities: + # add: [] + # drop: + # - ALL + # env: {} + # envList: [] + # envFrom: [] + # resources: + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + # initContainers: + # init-cont-name: + # enabled: false + # type: install + # # ...containerSpec # TODO: portal: {}