From 8576911a57e90ffee1a0b3dd0b33d308cc40a617 Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Fri, 4 Dec 2020 10:09:35 -0800 Subject: [PATCH] [database-chassis]: Fix the way database-chassis start (#6099) The service crash when the platform boots due to missing waits. /usr/bin/database.sh tries to operate on a missing socket and fails. We now wait for the chassis database to be ready the same way we do database. --- dockers/docker-database/docker-database-init.sh | 2 -- files/build_templates/docker_image_ctl.j2 | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dockers/docker-database/docker-database-init.sh b/dockers/docker-database/docker-database-init.sh index 30a65af89b..139815924f 100755 --- a/dockers/docker-database/docker-database-init.sh +++ b/dockers/docker-database/docker-database-init.sh @@ -50,8 +50,6 @@ if [[ $DATABASE_TYPE == "chassisdb" ]]; then # Docker init for database-chassis echo "Init docker-database-chassis..." update_chassisdb_config -j $db_cfg_file_tmp -k -p $chassis_db_port - mkdir -p /var/run/redis/sonic-db - cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db # generate all redis server supervisord configuration file sonic-cfggen -j $db_cfg_file_tmp -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf rm $db_cfg_file_tmp diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 477fd897bf..dc714e5b5c 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -144,6 +144,10 @@ function postStartAction() # Add redis UDS to the redis group and give read/write access to the group REDIS_SOCK="/var/run/redis${DEV}/redis.sock" else + until [[ ($(docker exec -i ${DOCKERNAME} pgrep -x -c supervisord) -gt 0) && + ($(docker exec -i ${DOCKERNAME} $SONIC_DB_CLI CHASSIS_APP_DB PING | grep -c True) -gt 0) ]]; do + sleep 1 + done REDIS_SOCK="/var/run/redis-chassis/redis_chassis.sock" fi chgrp -f redis $REDIS_SOCK && chmod -f 0760 $REDIS_SOCK