Skip to content

Commit

Permalink
[docker-radv] Fix startup issues (sonic-net#5230)
Browse files Browse the repository at this point in the history
**- Why I did it**

PR sonic-net#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).
  • Loading branch information
jleveque authored and santhosh-kt committed Feb 25, 2021
1 parent 679a386 commit 21f4b38
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dockers/docker-router-advertiser/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN apt-get clean -y && \
rm -rf /debs

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 ["critical_processes", "/etc/supervisor"]

Expand Down
4 changes: 2 additions & 2 deletions dockers/docker-router-advertiser/docker-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ CFGGEN_PARAMS=" \
-d \
-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/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

chmod +x /usr/bin/wait_for_intf.sh
chmod +x /usr/bin/wait_for_link.sh

exec /usr/bin/supervisord
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

{# Router advertiser should only run on ToR (T0) devices #}
{% if DEVICE_METADATA.localhost.type == "ToRRouter" %}

{% if VLAN_INTERFACE %}
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
{# Router advertiser should only run on ToR (T0) devices which have #}
{# at least one VLAN interface which has an IPv6 address asigned #}
{%- set vlan_v6 = namespace(count=0) -%}
{%- if DEVICE_METADATA.localhost.type == "ToRRouter" -%}
{%- if VLAN_INTERFACE -%}
{%- for (name, prefix) in VLAN_INTERFACE|pfx_filter -%}
{# If this VLAN has an IPv6 address... #}
{% if prefix | ipv6 %}
{% set ipv6_found = true %}
{% endif %}
{% endfor %}
{% endif %}
{%- if prefix | ipv6 -%}
{%- set vlan_v6.count = vlan_v6.count + 1 -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}

{# Enusre at least one ipv6 vlan interface #}
{% if ipv6_found == true %}
{%- if vlan_v6.count > 0 %}
[program:wait_for_link]
command=/usr/bin/wait_for_link.sh
priority=3
Expand All @@ -60,6 +61,4 @@ stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=wait_for_link:exited
{% endif %}

{% endif %}
{% endif -%}

0 comments on commit 21f4b38

Please sign in to comment.