Skip to content

Commit

Permalink
fix(init) rework wait-for-db socket workaround
Browse files Browse the repository at this point in the history
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
#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.
  • Loading branch information
Travis Raines committed Dec 1, 2021
1 parent 07818dc commit 040662d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions charts/kong/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -529,18 +529,17 @@ 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)) }}
{{ $sockFile := (printf "%s/*.sock" (default "/usr/local/kong" .Values.env.prefix)) }}
- name: wait-for-db
image: {{ include "kong.getRepoTag" .Values.image }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{ 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 }}
Expand Down

0 comments on commit 040662d

Please sign in to comment.