[#106] service/storage: Add healthcheck

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-06-29 22:38:01 +03:00 committed by Alex Vanin
parent 140734d457
commit 1611844989
2 changed files with 50 additions and 0 deletions

View file

@ -16,6 +16,8 @@ services:
- ./01.key:/01.key - ./01.key:/01.key
- ./../../vendor/hosts:/etc/hosts - ./../../vendor/hosts:/etc/hosts
- storage_s01:/storage - storage_s01:/storage
- ./../../vendor/neofs-cli:/neofs-cli
- ./healthcheck.sh:/healthcheck.sh
stop_signal: SIGKILL stop_signal: SIGKILL
env_file: [ ".env", ".storage.env" ] env_file: [ ".env", ".storage.env" ]
environment: environment:
@ -25,6 +27,12 @@ services:
- NEOFS_CONTROL_GRPC_ENDPOINT=s01.${LOCAL_DOMAIN}:8081 - NEOFS_CONTROL_GRPC_ENDPOINT=s01.${LOCAL_DOMAIN}:8081
- NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:RU MSK - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:RU MSK
- NEOFS_NODE_ATTRIBUTE_1=Price:22 - NEOFS_NODE_ATTRIBUTE_1=Price:22
healthcheck:
test: ["CMD-SHELL", "/healthcheck.sh"]
interval: 2s
timeout: 1s
retries: 5
start_period: 10s
storage02: storage02:
image: ${NODE_IMAGE}:${NODE_VERSION} image: ${NODE_IMAGE}:${NODE_VERSION}
@ -40,6 +48,8 @@ services:
- ./02.key:/02.key - ./02.key:/02.key
- ./../../vendor/hosts:/etc/hosts - ./../../vendor/hosts:/etc/hosts
- storage_s02:/storage - storage_s02:/storage
- ./../../vendor/neofs-cli:/neofs-cli
- ./healthcheck.sh:/healthcheck.sh
stop_signal: SIGKILL stop_signal: SIGKILL
env_file: [ ".env", ".storage.env" ] env_file: [ ".env", ".storage.env" ]
environment: environment:
@ -49,6 +59,12 @@ services:
- NEOFS_CONTROL_GRPC_ENDPOINT=s02.${LOCAL_DOMAIN}:8081 - NEOFS_CONTROL_GRPC_ENDPOINT=s02.${LOCAL_DOMAIN}:8081
- NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:RU LED - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:RU LED
- NEOFS_NODE_ATTRIBUTE_1=Price:33 - NEOFS_NODE_ATTRIBUTE_1=Price:33
healthcheck:
test: ["CMD-SHELL", "/healthcheck.sh"]
interval: 2s
timeout: 1s
retries: 5
start_period: 10s
storage03: storage03:
image: ${NODE_IMAGE}:${NODE_VERSION} image: ${NODE_IMAGE}:${NODE_VERSION}
@ -64,6 +80,8 @@ services:
- ./03.key:/03.key - ./03.key:/03.key
- ./../../vendor/hosts:/etc/hosts - ./../../vendor/hosts:/etc/hosts
- storage_s03:/storage - storage_s03:/storage
- ./../../vendor/neofs-cli:/neofs-cli
- ./healthcheck.sh:/healthcheck.sh
stop_signal: SIGKILL stop_signal: SIGKILL
env_file: [ ".env", ".storage.env" ] env_file: [ ".env", ".storage.env" ]
environment: environment:
@ -73,6 +91,12 @@ services:
- NEOFS_CONTROL_GRPC_ENDPOINT=s03.${LOCAL_DOMAIN}:8081 - NEOFS_CONTROL_GRPC_ENDPOINT=s03.${LOCAL_DOMAIN}:8081
- NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:SE STO - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:SE STO
- NEOFS_NODE_ATTRIBUTE_1=Price:11 - NEOFS_NODE_ATTRIBUTE_1=Price:11
healthcheck:
test: ["CMD-SHELL", "/healthcheck.sh"]
interval: 2s
timeout: 1s
retries: 5
start_period: 10s
storage04: storage04:
image: ${NODE_IMAGE}:${NODE_VERSION} image: ${NODE_IMAGE}:${NODE_VERSION}
@ -88,6 +112,8 @@ services:
- ./04.key:/04.key - ./04.key:/04.key
- ./../../vendor/hosts:/etc/hosts - ./../../vendor/hosts:/etc/hosts
- storage_s04:/storage - storage_s04:/storage
- ./../../vendor/neofs-cli:/neofs-cli
- ./healthcheck.sh:/healthcheck.sh
stop_signal: SIGKILL stop_signal: SIGKILL
env_file: [ ".env", ".storage.env" ] env_file: [ ".env", ".storage.env" ]
environment: environment:
@ -97,6 +123,25 @@ services:
- NEOFS_CONTROL_GRPC_ENDPOINT=s04.${LOCAL_DOMAIN}:8081 - NEOFS_CONTROL_GRPC_ENDPOINT=s04.${LOCAL_DOMAIN}:8081
- NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:FI HEL - NEOFS_NODE_ATTRIBUTE_0=UN-LOCODE:FI HEL
- NEOFS_NODE_ATTRIBUTE_1=Price:44 - 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: volumes:
storage_s01: storage_s01:

View file

@ -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