From 83b288a650739cac27b9bebb6d0d1f534b04f4bc Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Wed, 1 Sep 2021 17:30:34 +0530 Subject: [PATCH] feat: use pg_ready for k8s migration job init-check (#34) 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. --- charts/chatwoot/Chart.yaml | 2 +- charts/chatwoot/templates/migrations-job.yaml | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/charts/chatwoot/Chart.yaml b/charts/chatwoot/Chart.yaml index ad5f115..64061a8 100644 --- a/charts/chatwoot/Chart.yaml +++ b/charts/chatwoot/Chart.yaml @@ -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" diff --git a/charts/chatwoot/templates/migrations-job.yaml b/charts/chatwoot/templates/migrations-job.yaml index c220ec1..85540f6 100644 --- a/charts/chatwoot/templates/migrations-job.yaml +++ b/charts/chatwoot/templates/migrations-job.yaml @@ -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"