diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index b139eb570b3a..3ecb83890a21 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -429,9 +429,9 @@ start() { {%- endif %} {%- if docker_container_name == "swss" %} -e ASIC_VENDOR={{ sonic_asic_platform }} \ -{%- if enable_asan == "y" %} - -v /var/log/asan/:/var/log/asan \ {%- endif -%} +{%- if docker_container_name in ["swss", "syncd"] and enable_asan == "y" %} + -v /var/log/asan/:/var/log/asan \ {%- endif -%} {%- if docker_container_name == "bgp" %} -v /etc/sonic/frr/$DEV:/etc/frr:rw \ @@ -493,7 +493,7 @@ stop() { {%- elif docker_container_name == "teamd" %} # Longer timeout of 60 sec to wait for Portchannels to be cleaned. /usr/local/bin/container stop -t 60 $DOCKERNAME - {%- elif docker_container_name == "swss" and enable_asan == "y" %} + {%- elif docker_container_name in ["swss", "syncd"] and enable_asan == "y" %} /usr/local/bin/container stop -t 60 $DOCKERNAME {%- else %} /usr/local/bin/container stop $DOCKERNAME diff --git a/files/build_templates/sonic_version.yml.j2 b/files/build_templates/sonic_version.yml.j2 index 6e3f3acac95a..bc6fb54189d4 100644 --- a/files/build_templates/sonic_version.yml.j2 +++ b/files/build_templates/sonic_version.yml.j2 @@ -26,4 +26,6 @@ built_by: {{ built_by }} {{ name }}: {{ version }} {% endfor -%} {% endif -%} - +{% if ENABLE_ASAN == "y" -%} +asan: 'yes' +{% endif -%} diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index 404db43c70aa..386f00e3fe31 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -31,6 +31,9 @@ RUN apt-get update && \ libxml2 \ python-pip \ python-dev \ +{%- if ENABLE_ASAN == "y" %} + libasan5 \ +{%- endif %} python-setuptools RUN pip2 install --upgrade pip @@ -58,8 +61,12 @@ RUN apt-get clean -y && \ apt-get autoremove -y && \ rm -rf /debs -COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] +COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor/"] +RUN mkdir -p /etc/supervisor/conf.d/ +RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf +RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2 + ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/mellanox/docker-syncd-mlnx/supervisord.conf b/platform/mellanox/docker-syncd-mlnx/supervisord.conf.j2 similarity index 89% rename from platform/mellanox/docker-syncd-mlnx/supervisord.conf rename to platform/mellanox/docker-syncd-mlnx/supervisord.conf.j2 index 6fd59606062d..cc07096b20c6 100644 --- a/platform/mellanox/docker-syncd-mlnx/supervisord.conf +++ b/platform/mellanox/docker-syncd-mlnx/supervisord.conf.j2 @@ -37,3 +37,6 @@ stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=rsyslogd:running +{% if ENABLE_ASAN == "y" %} +environment=ASAN_OPTIONS="log_path=/var/log/asan/syncd-asan.log" +{% endif %}