[docker-radv] Fix startup issues (#5230)

**- Why I did it**

PR https://github.com/Azure/sonic-buildimage/pull/4599 introduced two bugs in the startup of the router advertiser container:

1. References to the `wait_for_intf.sh` script were changed to `wait_for_link.sh`, but the actual script was not renamed
2. The `ipv6_found` Jinja2 variable added to the supervisor config file goes out of scope before it is read.

**- How I did it**
1. Rename the `wait_for_intf.sh` script to `wait_for_link.sh`
2. Use the Jinja2 "namespace" construct to fix the scope issue

**- How to verify it**

Ensure all processes in the radv container start properly under the correct conditions (i.e., whether or not there is at least one VLAN with an IPv6 address assigned).
This commit is contained in:
Joe LeVeque 2020-08-21 13:12:01 -07:00 committed by GitHub
parent 6f4ef03b29
commit 97d44214cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 18 deletions

View File

@ -25,7 +25,7 @@ RUN apt-get clean -y && \
rm -rf /debs rm -rf /debs
COPY ["docker-init.sh", "/usr/bin/"] COPY ["docker-init.sh", "/usr/bin/"]
COPY ["radvd.conf.j2", "wait_for_intf.sh.j2", "docker-router-advertiser.supervisord.conf.j2", "/usr/share/sonic/templates/"] COPY ["radvd.conf.j2", "wait_for_link.sh.j2", "docker-router-advertiser.supervisord.conf.j2", "/usr/share/sonic/templates/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"] COPY ["critical_processes", "/etc/supervisor"]

View File

@ -8,10 +8,10 @@ CFGGEN_PARAMS=" \
-d \ -d \
-t /usr/share/sonic/templates/docker-router-advertiser.supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \ -t /usr/share/sonic/templates/docker-router-advertiser.supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
-t /usr/share/sonic/templates/radvd.conf.j2,/etc/radvd.conf \ -t /usr/share/sonic/templates/radvd.conf.j2,/etc/radvd.conf \
-t /usr/share/sonic/templates/wait_for_intf.sh.j2,/usr/bin/wait_for_intf.sh \ -t /usr/share/sonic/templates/wait_for_link.sh.j2,/usr/bin/wait_for_link.sh \
" "
sonic-cfggen $CFGGEN_PARAMS sonic-cfggen $CFGGEN_PARAMS
chmod +x /usr/bin/wait_for_intf.sh chmod +x /usr/bin/wait_for_link.sh
exec /usr/bin/supervisord exec /usr/bin/supervisord

View File

@ -26,20 +26,21 @@ stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true dependent_startup=true
{# Router advertiser should only run on ToR (T0) devices #} {# Router advertiser should only run on ToR (T0) devices which have #}
{% if DEVICE_METADATA.localhost.type == "ToRRouter" %} {# at least one VLAN interface which has an IPv6 address asigned #}
{%- set vlan_v6 = namespace(count=0) -%}
{% if VLAN_INTERFACE %} {%- if DEVICE_METADATA.localhost.type == "ToRRouter" -%}
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %} {%- if VLAN_INTERFACE -%}
{%- for (name, prefix) in VLAN_INTERFACE|pfx_filter -%}
{# If this VLAN has an IPv6 address... #} {# If this VLAN has an IPv6 address... #}
{% if prefix | ipv6 %} {%- if prefix | ipv6 -%}
{% set ipv6_found = true %} {%- set vlan_v6.count = vlan_v6.count + 1 -%}
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
{% endif %} {%- endif -%}
{%- endif -%}
{# Enusre at least one ipv6 vlan interface #} {%- if vlan_v6.count > 0 %}
{% if ipv6_found == true %}
[program:wait_for_link] [program:wait_for_link]
command=/usr/bin/wait_for_link.sh command=/usr/bin/wait_for_link.sh
priority=3 priority=3
@ -60,6 +61,4 @@ stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
dependent_startup=true dependent_startup=true
dependent_startup_wait_for=wait_for_link:exited dependent_startup_wait_for=wait_for_link:exited
{% endif %} {% endif -%}
{% endif %}