Skip to content

Commit

Permalink
[update graph] adapt to warm reboot scenario (#2353)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
yxieca authored Dec 6, 2018
1 parent 7a74ff0 commit 6ba93ac
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions files/image_config/updategraph/updategraph
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ reload_minigraph()
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
echo "No updategraph.conf found, generating a default one."
Expand All @@ -26,21 +49,18 @@ fi

. /etc/sonic/updategraph.conf

check_system_warm_boot

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..."
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
sonic-cfggen -d --print-data > /etc/sonic/config_db.json
else
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
fi
rm -f /tmp/pending_config_migration
Expand Down

0 comments on commit 6ba93ac

Please sign in to comment.