From 87558ffb9aa086ae6ce57249c7b34835bd4946cd Mon Sep 17 00:00:00 2001 From: Arvinth C <54614142+ArvinthC3000@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:49:22 +0530 Subject: [PATCH] Adding health check for backup gateway (#8297) * Adding health check for backup gateway Signed-off-by: Arvinth C * Health check log Signed-off-by: Arvinth C * Addinf root ca in seperate file for backup gateway Signed-off-by: Arvinth C * Addinf root ca in seperate file for backup gateway Signed-off-by: Arvinth C * trigger build Signed-off-by: Arvinth C * Pipeline fix Signed-off-by: Arvinth C --------- Signed-off-by: Arvinth C --- .../backup-gateway/habitat/config/root-ca.crt | 1 + .../backup-gateway/habitat/hooks/health-check | 20 +++++++++++++++++++ components/backup-gateway/habitat/plan.sh | 1 + 3 files changed, 22 insertions(+) create mode 100644 components/backup-gateway/habitat/config/root-ca.crt create mode 100644 components/backup-gateway/habitat/hooks/health-check diff --git a/components/backup-gateway/habitat/config/root-ca.crt b/components/backup-gateway/habitat/config/root-ca.crt new file mode 100644 index 00000000000..8b8d1a1d675 --- /dev/null +++ b/components/backup-gateway/habitat/config/root-ca.crt @@ -0,0 +1 @@ +{{cfg.tls.root_cert_contents}} diff --git a/components/backup-gateway/habitat/hooks/health-check b/components/backup-gateway/habitat/hooks/health-check new file mode 100644 index 00000000000..8eadbc5c46f --- /dev/null +++ b/components/backup-gateway/habitat/hooks/health-check @@ -0,0 +1,20 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + +exec 2>&1 + +curlOpts="-sS --fail --max-time 2 -o /dev/null -s -w %{http_code}" +curlOpts="$curlOpts --cert {{pkg.svc_config_path}}/public.crt" +curlOpts="$curlOpts --key {{pkg.svc_config_path}}/private.key" +curlOpts="$curlOpts --cacert {{pkg.svc_config_path}}/root-ca.crt" +curlOpts="$curlOpts --resolve backup-gateway:{{cfg.service.port}}:127.0.0.1" +curlOpts="$curlOpts --noproxy backup-gateway" + +# shellcheck disable=SC2086 +output=$(curl $curlOpts https://backup-gateway:{{cfg.service.port}}/minio/health/ready 2>&1) +res=$? +echo "health check status code: $output" +if [[ "$res" != "0" ]]; then + echo "health check curl command returned exit code $res:" + echo "$output" + exit 2 +fi diff --git a/components/backup-gateway/habitat/plan.sh b/components/backup-gateway/habitat/plan.sh index 5e297d3412e..d0e5be445ee 100644 --- a/components/backup-gateway/habitat/plan.sh +++ b/components/backup-gateway/habitat/plan.sh @@ -13,6 +13,7 @@ pkg_deps=( chef/automate-platform-tools ) + pkg_exports=( [port]=service.port )