Skip to content

Commit

Permalink
[kong] handle DB-backed stream listen issue
Browse files Browse the repository at this point in the history
#295 requires a workaround that
behaves differently depending on whether a DB-backed instance has or
does not have stream listens configured.

At the end of wait-for-db, this workaround removes the problem socket
file if it exists, or does nothing if it does not.

test5-values.yaml is a new DB-backed test that does not include stream
listens, as the only existing DB-backed test did include stream listens.
  • Loading branch information
Travis Raines committed Feb 25, 2021
1 parent abaa697 commit 4f0891b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions charts/kong/ci/test2-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This tests the following unrelated aspects of Ingress Controller
# - ingressController deploys with a database
# - stream listens work
ingressController:
enabled: true
installCRDs: false
Expand Down
43 changes: 43 additions & 0 deletions charts/kong/ci/test5-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This tests the following unrelated aspects of Ingress Controller
# - ingressController deploys with a database
# - TODO database-backed proxy works _without_ stream listens
# This test is a duplicate of test2-values.yaml to handle the https://github.com/Kong/charts/issues/295
# workaround when the socket file is _not_ created
ingressController:
enabled: true
installCRDs: false
env:
anonymous_reports: "false"
postgresql:
enabled: true
postgresqlUsername: kong
postgresqlDatabase: kong
service:
port: 5432
env:
anonymous_reports: "off"
database: "postgres"
# - ingress resources are created without hosts
admin:
type: NodePort
ingress:
enabled: true
hosts: []
path: /
proxy:
type: NodePort
ingress:
enabled: true
hostname: proxy.kong.example
annotations: {}
path: /

# - PDB is enabled
podDisruptionBudget:
enabled: true
# update strategy
updateStrategy:
type: "RollingUpdate"
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
5 changes: 3 additions & 2 deletions charts/kong/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,15 @@ 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 }}
env:
{{- include "kong.env" . | nindent 2 }}
{{/* TODO: the rm command here is a workaround for https://github.com/Kong/kong/issues/6827
{{/* TODO: the rm command here is a workaround for https://github.com/Kong/charts/issues/295
It should be removed once that's fixed */}}
command: [ "/bin/sh", "-c", "until kong start; do echo 'waiting for db'; sleep 1; done; kong stop; rm {{ .Values.env.prefix | default "/usr/local/kong" }}/stream_rpc.sock" ]
command: [ "/bin/sh", "-c", "until kong start; do echo 'waiting for db'; sleep 1; done; kong stop; if [ -f {{ $sockFile }} ]; then rm {{ $sockFile }}; else true; fi"]
volumeMounts:
{{- include "kong.volumeMounts" . | nindent 4 }}
resources:
Expand Down

0 comments on commit 4f0891b

Please sign in to comment.