From 3c0fe2d1a01f232498d5bdd44c4824db34bd3a34 Mon Sep 17 00:00:00 2001 From: Travis Raines Date: Wed, 1 Dec 2021 10:08:18 -0800 Subject: [PATCH] fix(init) rework wait-for-db socket workaround Use a temporary prefix directory for wait-for-db instead of removing problem files. For unclear reasons, versions of Kong that should include https://trac.nginx.org/nginx/ticket/753 are still leaving old socket files behind in the prefix after wait-for-db completes. Additional sockets in newer Kong versions result in a new variant of https://github.com/Kong/charts/issues/295, preventing startup when using Postgres. Since we don't actually need anything wait-for-db writes to the prefix, we can write to a temporary prefix instead to avoid this class of issue entirely. --- charts/kong/templates/_helpers.tpl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/charts/kong/templates/_helpers.tpl b/charts/kong/templates/_helpers.tpl index 8decfaab6..4c573fb67 100644 --- a/charts/kong/templates/_helpers.tpl +++ b/charts/kong/templates/_helpers.tpl @@ -529,7 +529,6 @@ The name of the service used for the ingress controller's validation webhook {{- end -}} {{- define "kong.wait-for-db" -}} -{{ $sockFile := (printf "%s/stream_rpc.sock" (default "/usr/local/kong" .Values.env.prefix)) }} - name: wait-for-db image: {{ include "kong.getRepoTag" .Values.image }} imagePullPolicy: {{ .Values.image.pullPolicy }} @@ -537,10 +536,9 @@ The name of the service used for the ingress controller's validation webhook {{ toYaml .Values.containerSecurityContext | nindent 4 }} env: {{- include "kong.env" . | nindent 2 }} -{{/* TODO: the rm command here is a workaround for https://github.com/Kong/charts/issues/295 - It should be removed once that's fixed. +{{/* TODO the prefix override is to work around https://github.com/Kong/charts/issues/295 Note that we use args instead of command here to /not/ override the standard image entrypoint. */}} - args: [ "/bin/sh", "-c", "export KONG_NGINX_DAEMON=on; until kong start; do echo 'waiting for db'; sleep 1; done; kong stop; rm -fv {{ $sockFile | squote }}"] + args: [ "/bin/sh", "-c", "export KONG_NGINX_DAEMON=on; export KONG_PREFIX=`mktemp -d`; until kong start; do echo 'waiting for db'; sleep 1; done; kong stop"] volumeMounts: {{- include "kong.volumeMounts" . | nindent 4 }} {{- include "kong.userDefinedVolumeMounts" . | nindent 4 }}