Skip to content

Commit b1c3ab7

Browse files
mlok-nokiajudyjoseph
authored andcommitted
[VoQ][config] Multiasic Supervisor card fails to load config_db#.json in chassis when system is reboot (#10106)
Supervisor card fails to load config_db#.json in chassis when system reboot. This is an intermittent issue, fixes #10105
1 parent df660f2 commit b1c3ab7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

files/build_templates/docker_image_ctl.j2

+33
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,34 @@ function setPlatformLagIdBoundaries()
125125
docker exec -i ${DOCKERNAME} $SONIC_DB_CLI CHASSIS_APP_DB SET "SYSTEM_LAG_ID_END" "$lag_id_end"
126126
fi
127127
}
128+
function waitForAllInstanceDatabaseConfigJsonFilesReady()
129+
{
130+
if [ ! -z "$DEV" ]; then
131+
cnt=0
132+
SONIC_DB_GLOBAL_JSON="/var/run/redis/sonic-db/database_global.json"
133+
if [ -f "$SONIC_DB_GLOBAL_JSON" ]; then
134+
# Create a separate python script to get a list of location of all instance database_config.json file
135+
redis_database_cfg_list=`/usr/bin/python -c "import sys; import os; import json; f=open(sys.argv[1]); \
136+
global_db_dir = os.path.dirname(sys.argv[1]); data=json.load(f); \
137+
print(\" \".join([os.path.normpath(global_db_dir+'/'+elem['include']) \
138+
for elem in data['INCLUDES'] if 'namespace' in elem])); f.close()" $SONIC_DB_GLOBAL_JSON`
139+
for file in $redis_database_cfg_list
140+
do
141+
while [ ! -f $file ]
142+
do
143+
sleep 1
144+
cnt=$(( $cnt + 1))
145+
if [ $cnt -ge 60 ]; then
146+
echo "Error: $file not found"
147+
break
148+
fi
149+
done
150+
done
151+
fi
152+
fi
153+
}
154+
# delay a second to allow the file to be fully accessible
155+
sleep 1
128156
{%- endif %}
129157

130158
function postStartAction()
@@ -161,6 +189,11 @@ function postStartAction()
161189
else
162190
# If there is a config_db.json dump file, load it.
163191
if [ -r /etc/sonic/config_db$DEV.json ]; then
192+
193+
# For multi-asic, all /var/run/redis$DEV/sonic-db/database_config.json need to ready
194+
# for loading config with --write-to-db
195+
waitForAllInstanceDatabaseConfigJsonFilesReady
196+
164197
if [ -r /etc/sonic/init_cfg.json ]; then
165198
$SONIC_CFGGEN -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db$DEV.json --write-to-db
166199
else

0 commit comments

Comments
 (0)