From 68b1028db9d40484b5c5c9bc1089f7ad45427d4d Mon Sep 17 00:00:00 2001 From: Kyle Schochenmaier Date: Thu, 5 Nov 2020 16:32:19 -0600 Subject: [PATCH] pass health checks controller flag only when enabled (#673) * pass health checks flag only when enabled Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com> Co-authored-by: Iryna Shustava --- templates/connect-inject-deployment.yaml | 4 +++- test/unit/connect-inject-deployment.bats | 16 ++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/templates/connect-inject-deployment.yaml b/templates/connect-inject-deployment.yaml index 4cc2caa47..d6d7f21a3 100644 --- a/templates/connect-inject-deployment.yaml +++ b/templates/connect-inject-deployment.yaml @@ -85,8 +85,10 @@ spec: -envoy-image="{{ .Values.global.imageEnvoy }}" \ -consul-k8s-image="{{ default .Values.global.imageK8S .Values.connectInject.image }}" \ -listen=:8080 \ - -enable-health-checks-controller={{ .Values.connectInject.healthChecks.enabled }} \ + {{- if .Values.connectInject.healthChecks.enabled }} + -enable-health-checks-controller=true \ -health-checks-reconcile-period={{ .Values.connectInject.healthChecks.reconcilePeriod }} \ + {{- end }} {{- if .Values.connectInject.overrideAuthMethodName }} -acl-auth-method="{{ .Values.connectInject.overrideAuthMethodName }}" \ {{- else if .Values.global.acls.manageSystemACLs }} diff --git a/test/unit/connect-inject-deployment.bats b/test/unit/connect-inject-deployment.bats index 0315605cc..53c56044d 100755 --- a/test/unit/connect-inject-deployment.bats +++ b/test/unit/connect-inject-deployment.bats @@ -88,8 +88,11 @@ load _helpers yq '.spec.template.spec.containers[0].command' | tee /dev/stderr) local actual=$(echo "$cmd" | - yq 'any(contains("-enable-health-checks-controller=false"))' | tee /dev/stderr) - [ "${actual}" = "true" ] + yq 'any(contains("-enable-health-checks-controller"))' | tee /dev/stderr) + [ "${actual}" = "false" ] + local actual=$(echo "$cmd" | + yq 'any(contains("-health-checks-reconcile-period"))' | tee /dev/stderr) + [ "${actual}" = "false" ] } @test "connectInject/Deployment: health checks can be enabled" { @@ -116,15 +119,16 @@ load _helpers yq '.spec.template.spec.containers[0].command' | tee /dev/stderr) local actual=$(echo "$cmd" | - yq 'any(contains("-enable-health-checks-controller=false"))' | tee /dev/stderr) - [ "${actual}" = "true" ] + yq 'any(contains("-enable-health-checks-controller"))' | tee /dev/stderr) + [ "${actual}" = "false" ] } -@test "connectInject/Deployment: health checks reconcile period set by default" { +@test "connectInject/Deployment: health checks reconcile period set by default when health checks are enabled" { cd `chart_dir` local cmd=$(helm template \ -s templates/connect-inject-deployment.yaml \ --set 'connectInject.enabled=true' \ + --set 'connectInject.healthChecks.enabled=true' \ . | tee /dev/stderr | yq '.spec.template.spec.containers[0].command' | tee /dev/stderr) @@ -1423,4 +1427,4 @@ load _helpers yq -r '.spec.template.spec.priorityClassName' | tee /dev/stderr) [ "${actual}" = "name" ] -} \ No newline at end of file +}