From 1611844989db4ba4c6ba0f302255194d906776fe Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 29 Jun 2021 22:38:01 +0300 Subject: [PATCH] [#106] service/storage: Add healthcheck Signed-off-by: Alex Vanin --- services/storage/docker-compose.yml | 45 +++++++++++++++++++++++++++++ services/storage/healthcheck.sh | 5 ++++ 2 files changed, 50 insertions(+) create mode 100755 services/storage/healthcheck.sh diff --git a/services/storage/docker-compose.yml b/services/storage/docker-compose.yml index 18bf34e..bbda2bb 100644 --- a/services/storage/docker-compose.yml +++ b/services/storage/docker-compose.yml @@ -16,6 +16,8 @@ services: - ./01.key:/01.key - ./../../vendor/hosts:/etc/hosts - storage_s01:/storage + - ./../../vendor/neofs-cli:/neofs-cli + - ./healthcheck.sh:/healthcheck.sh stop_signal: SIGKILL env_file: [ ".env", ".storage.env" ] environment: @@ -25,6 +27,12 @@ services: - NEOFS_CONTROL_GRPC_ENDPOINT=s01.${LOCAL_DOMAIN}:8081 - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:RU MSK - NEOFS_NODE_ATTRIBUTE_1=Price:22 + healthcheck: + test: ["CMD-SHELL", "/healthcheck.sh"] + interval: 2s + timeout: 1s + retries: 5 + start_period: 10s storage02: image: ${NODE_IMAGE}:${NODE_VERSION} @@ -40,6 +48,8 @@ services: - ./02.key:/02.key - ./../../vendor/hosts:/etc/hosts - storage_s02:/storage + - ./../../vendor/neofs-cli:/neofs-cli + - ./healthcheck.sh:/healthcheck.sh stop_signal: SIGKILL env_file: [ ".env", ".storage.env" ] environment: @@ -49,6 +59,12 @@ services: - NEOFS_CONTROL_GRPC_ENDPOINT=s02.${LOCAL_DOMAIN}:8081 - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:RU LED - NEOFS_NODE_ATTRIBUTE_1=Price:33 + healthcheck: + test: ["CMD-SHELL", "/healthcheck.sh"] + interval: 2s + timeout: 1s + retries: 5 + start_period: 10s storage03: image: ${NODE_IMAGE}:${NODE_VERSION} @@ -64,6 +80,8 @@ services: - ./03.key:/03.key - ./../../vendor/hosts:/etc/hosts - storage_s03:/storage + - ./../../vendor/neofs-cli:/neofs-cli + - ./healthcheck.sh:/healthcheck.sh stop_signal: SIGKILL env_file: [ ".env", ".storage.env" ] environment: @@ -73,6 +91,12 @@ services: - NEOFS_CONTROL_GRPC_ENDPOINT=s03.${LOCAL_DOMAIN}:8081 - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:SE STO - NEOFS_NODE_ATTRIBUTE_1=Price:11 + healthcheck: + test: ["CMD-SHELL", "/healthcheck.sh"] + interval: 2s + timeout: 1s + retries: 5 + start_period: 10s storage04: image: ${NODE_IMAGE}:${NODE_VERSION} @@ -88,6 +112,8 @@ services: - ./04.key:/04.key - ./../../vendor/hosts:/etc/hosts - storage_s04:/storage + - ./../../vendor/neofs-cli:/neofs-cli + - ./healthcheck.sh:/healthcheck.sh stop_signal: SIGKILL env_file: [ ".env", ".storage.env" ] environment: @@ -97,6 +123,25 @@ services: - NEOFS_CONTROL_GRPC_ENDPOINT=s04.${LOCAL_DOMAIN}:8081 - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:FI HEL - NEOFS_NODE_ATTRIBUTE_1=Price:44 + healthcheck: + test: ["CMD-SHELL", "/healthcheck.sh"] + interval: 2s + timeout: 1s + retries: 5 + start_period: 10s + + sn-healthcheck: + container_name: sn-healthcheck + image: debian:10 + depends_on: + storage01: + condition: service_healthy + storage02: + condition: service_healthy + storage03: + condition: service_healthy + storage04: + condition: service_healthy volumes: storage_s01: diff --git a/services/storage/healthcheck.sh b/services/storage/healthcheck.sh new file mode 100755 index 0000000..58f23ce --- /dev/null +++ b/services/storage/healthcheck.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +EXPECTED="Health status: READY" +GOT=`/neofs-cli -r $NEOFS_CONTROL_GRPC_ENDPOINT --binary-key $NEOFS_NODE_KEY control healthcheck | grep "Health"` +if [ "$EXPECTED" = "$GOT" ]; then exit 0; else exit 1; fi