Skip to content

Commit

Permalink
[multi-asic] Fixed the docker mount point check for multi-asic (#5848)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
abdosi committed Nov 9, 2020
1 parent 2284dd7 commit c453381
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -179,9 +179,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 {{docker_container_name}}$DEV 2>/dev/null`
Expand All @@ -191,7 +196,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 {{docker_container_name}}$DEV container"
{%- else %}
Expand Down

0 comments on commit c453381

Please sign in to comment.