Skip to content

Commit aecd913

Browse files
mlok-nokiamssonicbld
authored andcommitted
[Chassis][multiasic] Fix the sonic-db-cli core files issue on multiasic platform after the c++ implementation of sonic-db-cli (sonic-net#13207)
Fixe sonic-net#12047. After the c++ implementation of the sonic-db-cli, sonic-db-cli PING command tries to initialize the global database for all instances database starting. If all instance database-config.json are not ready yet. it will crash and generate core file. PR sonic-net/sonic-swss-common#701 only fix the crash and the process abortion. Signed-off-by: mlok <[email protected]>
1 parent 1098f6e commit aecd913

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

files/build_templates/docker_image_ctl.j2

+10-8
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ function waitForAllInstanceDatabaseConfigJsonFilesReady()
144144
fi
145145
done
146146
done
147-
fi
147+
fi
148+
# Delay a second to allow all instance database_config.json files to be completely generated and fully accessible.
149+
# This delay is needed to make sure that the database_config.json files are correctly rendered from j2 template
150+
# files ( renderning takes some time )
151+
sleep 1
148152
fi
149153
}
150-
# delay a second to allow the file to be fully accessible
151-
sleep 1
152154
{%- endif %}
153155

154156
function postStartAction()
@@ -214,6 +216,10 @@ function postStartAction()
214216
# then we catch python exception of file not valid
215217
# that comes to syslog which is unwanted so wait till database
216218
# config is ready and then ping
219+
# sonic-db-cli try to initialize the global database. If in multiasic platform, inital global
220+
# database will try to access to all other instance database-config.json. If other instance
221+
# database-config.json files are not ready yet, it will generate the sonic-db-cli core files.
222+
waitForAllInstanceDatabaseConfigJsonFilesReady
217223
until [[ ($(docker exec -i database$DEV pgrep -x -c supervisord) -gt 0) && ($($SONIC_DB_CLI PING | grep -c PONG) -gt 0) &&
218224
($(docker exec -i database$DEV sonic-db-cli PING | grep -c PONG) -gt 0) ]]; do
219225
sleep 1;
@@ -223,11 +229,7 @@ function postStartAction()
223229
mv $WARM_DIR/dump.rdb $WARM_DIR/dump.rdb.old
224230
else
225231
# If there is a config_db.json dump file, load it.
226-
if [ -r /etc/sonic/config_db$DEV.json ]; then
227-
228-
# For multi-asic, all /var/run/redis$DEV/sonic-db/database_config.json need to ready
229-
# for loading config with --write-to-db
230-
waitForAllInstanceDatabaseConfigJsonFilesReady
232+
if [ -r /etc/sonic/config_db$DEV.json ]; then
231233

232234
if [ -r /etc/sonic/init_cfg.json ]; then
233235
$SONIC_CFGGEN -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db$DEV.json --write-to-db

0 commit comments

Comments
 (0)