[update graph] adapt to warm reboot scenario (#2353)

* [update graph] adapt to warm reboot scenario

When migrating configuration, always copy config files from old_config
to /etc/sonic. But if warm reboot is detected, then skip configuration
operations.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>

* log file copies and misses
This commit is contained in:
Ying Xie 2018-12-06 10:24:50 -08:00 committed by GitHub
parent 7a74ff0c01
commit 6ba93acd9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,29 @@ reload_minigraph()
pfcwd start_default pfcwd start_default
} }
function copy_config_files()
{
for file in $@; do
if [ -f /etc/sonic/old_config/${file} ]; then
logger "Copying SONiC configuration ${file} ..."
cp /etc/sonic/old_config/${file} /etc/sonic/
else
logger "Missing SONiC configuration ${file} ..."
fi
done
}
function check_system_warm_boot()
{
SYSTEM_WARM_START=`/usr/bin/redis-cli -n 4 hget "WARM_RESTART|system" enable`
# SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful.
if [[ x"$SYSTEM_WARM_START" == x"true" ]]; then
WARM_BOOT="true"
else
WARM_BOOT="false"
fi
}
if [ ! -f /etc/sonic/updategraph.conf ]; then if [ ! -f /etc/sonic/updategraph.conf ]; then
echo "No updategraph.conf found, generating a default one." echo "No updategraph.conf found, generating a default one."
@ -26,21 +49,18 @@ fi
. /etc/sonic/updategraph.conf . /etc/sonic/updategraph.conf
check_system_warm_boot
if [ -f /tmp/pending_config_migration ]; then if [ -f /tmp/pending_config_migration ]; then
if [ "$enabled" = "true" ]; then copy_config_files minigraph.xml snmp.yml acl.json config_db.json
if [ x"${WARM_BOOT}" == x"true" ]; then
echo "Warm reboot detected..."
elif [ "$enabled" = "true" ]; then
echo "Use minigraph.xml from old system..." echo "Use minigraph.xml from old system..."
cp /etc/sonic/old_config/minigraph.xml /etc/sonic/
if [ -f /etc/sonic/old_config/snmp.yml ]; then
cp /etc/sonic/old_config/snmp.yml /etc/sonic/
fi
if [ -f /etc/sonic/old_config/acl.json ]; then
cp /etc/sonic/old_config/acl.json /etc/sonic/
fi
reload_minigraph reload_minigraph
sonic-cfggen -d --print-data > /etc/sonic/config_db.json sonic-cfggen -d --print-data > /etc/sonic/config_db.json
else else
echo "Use config_db.json from old system..." echo "Use config_db.json from old system..."
cp /etc/sonic/old_config/config_db.json /etc/sonic/
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
fi fi
rm -f /tmp/pending_config_migration rm -f /tmp/pending_config_migration