From 5368fb35c21f5442a749b99fbf3cc6e20d5b61e0 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Mon, 9 Nov 2020 13:03:00 -0800 Subject: [PATCH] [multi-asic] Fixed the docker mount point check for multi-asic (#5848) API getMount() API was not updated to handle multi-asic platforms Updated API getMount() to return abspath() for Docker Mount Point and use that one for mount point comparison Signed-off-by: Abhishek Dosi --- files/build_templates/docker_image_ctl.j2 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 62846354fd08..3766dc918bab 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -45,7 +45,7 @@ function updateSyslogConf() function getMountPoint() { - echo $1 | python -c "import sys, json, os; mnts = [x for x in json.load(sys.stdin)[0]['Mounts'] if x['Destination'] == '/usr/share/sonic/hwsku']; print '' if len(mnts) == 0 else os.path.basename(mnts[0]['Source'])" 2>/dev/null + echo $1 | python -c "import sys, json, os; mnts = [x for x in json.load(sys.stdin)[0]['Mounts'] if x['Destination'] == '/usr/share/sonic/hwsku']; print '' if len(mnts) == 0 else os.path.abspath(mnts[0]['Source'])" 2>/dev/null } function getBootType() @@ -189,9 +189,14 @@ start() { {%- if docker_container_name == "database" %} # Don't mount HWSKU in {{docker_container_name}} container. HWSKU="" + MOUNTPATH="" {%- else %} # Obtain our HWSKU as we will mount directories with these names in each docker HWSKU=${HWSKU:-`$SONIC_CFGGEN -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`} + MOUNTPATH="/usr/share/sonic/device/$PLATFORM/$HWSKU" + if [ "$DEV" ]; then + MOUNTPATH="$MOUNTPATH/$DEV" + fi {%- endif %} DOCKERCHECK=`docker inspect --type container ${DOCKERNAME} 2>/dev/null` if [ "$?" -eq "0" ]; then @@ -200,7 +205,7 @@ start() { {%- else %} DOCKERMOUNT=`getMountPoint "$DOCKERCHECK"` {%- endif %} - if [ x"$DOCKERMOUNT" == x"$HWSKU" ]; then + if [ x"$DOCKERMOUNT" == x"$MOUNTPATH" ]; then {%- if docker_container_name == "database" %} echo "Starting existing ${DOCKERNAME} container" {%- else %}