Skip to content

Commit

Permalink
feat: use pg_ready for k8s migration job init-check (#34)
Browse files Browse the repository at this point in the history
nslookup of DB hostname was used as DB init check for migration job. This was
causing the migration job container to fail multiple times. NSLOOKUP being 
successful does not equate to DB is ready to accept connections.

This PR changed that to use the pg_ready tool which is a much more reliable 
metric to assess DB ready status.
  • Loading branch information
vishnu-narayanan authored Sep 1, 2021
1 parent fc33f07 commit 83b288a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/chatwoot/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sources:
- http://www.chatwoot.com

# This is the chart version.
version: 0.6.3
version: 0.6.4

# This is the application version.
appVersion: "v1.19.0"
15 changes: 13 additions & 2 deletions charts/chatwoot/templates/migrations-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ spec:
restartPolicy: Never
initContainers:
- name: init-postgres
image: busybox:1.28
command: ["sh", "-c", "until nslookup {{ template "chatwoot.postgresql.host" . }} ; do echo waiting for {{ template "chatwoot.postgresql.host" . }}; sleep 2; done;"]
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/bin/sh"]
args:
- -c
- >-
PG_READY="pg_isready -h {{ template "chatwoot.postgresql.host" . }} -p {{ template "chatwoot.postgresql.port" . }}";
until $PG_READY;
do
sleep 2;
done;
echo "Database ready to accept connections." ;
- name: init-redis
image: busybox:1.28
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["sh", "-c", "until nslookup {{ template "chatwoot.redis.host" . }} ; do echo waiting for {{ template "chatwoot.redis.host" . }} ; sleep 2; done;"]
containers:
- name: "db-migrate-job"
Expand Down

0 comments on commit 83b288a

Please sign in to comment.