Skip to content

Commit 21f4b38

Browse files
jlevequesanthosh-kt
authored andcommitted
[docker-radv] Fix startup issues (sonic-net#5230)
**- 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).
1 parent 679a386 commit 21f4b38

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

dockers/docker-router-advertiser/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN apt-get clean -y && \
2525
rm -rf /debs
2626

2727
COPY ["docker-init.sh", "/usr/bin/"]
28-
COPY ["radvd.conf.j2", "wait_for_intf.sh.j2", "docker-router-advertiser.supervisord.conf.j2", "/usr/share/sonic/templates/"]
28+
COPY ["radvd.conf.j2", "wait_for_link.sh.j2", "docker-router-advertiser.supervisord.conf.j2", "/usr/share/sonic/templates/"]
2929
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
3030
COPY ["critical_processes", "/etc/supervisor"]
3131

dockers/docker-router-advertiser/docker-init.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ CFGGEN_PARAMS=" \
88
-d \
99
-t /usr/share/sonic/templates/docker-router-advertiser.supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
1010
-t /usr/share/sonic/templates/radvd.conf.j2,/etc/radvd.conf \
11-
-t /usr/share/sonic/templates/wait_for_intf.sh.j2,/usr/bin/wait_for_intf.sh \
11+
-t /usr/share/sonic/templates/wait_for_link.sh.j2,/usr/bin/wait_for_link.sh \
1212
"
1313
sonic-cfggen $CFGGEN_PARAMS
1414

15-
chmod +x /usr/bin/wait_for_intf.sh
15+
chmod +x /usr/bin/wait_for_link.sh
1616

1717
exec /usr/bin/supervisord

dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2

+14-15
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ stdout_logfile=syslog
2626
stderr_logfile=syslog
2727
dependent_startup=true
2828

29-
{# Router advertiser should only run on ToR (T0) devices #}
30-
{% if DEVICE_METADATA.localhost.type == "ToRRouter" %}
31-
32-
{% if VLAN_INTERFACE %}
33-
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
29+
{# Router advertiser should only run on ToR (T0) devices which have #}
30+
{# at least one VLAN interface which has an IPv6 address asigned #}
31+
{%- set vlan_v6 = namespace(count=0) -%}
32+
{%- if DEVICE_METADATA.localhost.type == "ToRRouter" -%}
33+
{%- if VLAN_INTERFACE -%}
34+
{%- for (name, prefix) in VLAN_INTERFACE|pfx_filter -%}
3435
{# If this VLAN has an IPv6 address... #}
35-
{% if prefix | ipv6 %}
36-
{% set ipv6_found = true %}
37-
{% endif %}
38-
{% endfor %}
39-
{% endif %}
36+
{%- if prefix | ipv6 -%}
37+
{%- set vlan_v6.count = vlan_v6.count + 1 -%}
38+
{%- endif -%}
39+
{%- endfor -%}
40+
{%- endif -%}
41+
{%- endif -%}
4042

41-
{# Enusre at least one ipv6 vlan interface #}
42-
{% if ipv6_found == true %}
43+
{%- if vlan_v6.count > 0 %}
4344
[program:wait_for_link]
4445
command=/usr/bin/wait_for_link.sh
4546
priority=3
@@ -60,6 +61,4 @@ stdout_logfile=syslog
6061
stderr_logfile=syslog
6162
dependent_startup=true
6263
dependent_startup_wait_for=wait_for_link:exited
63-
{% endif %}
64-
65-
{% endif %}
64+
{% endif -%}

0 commit comments

Comments
 (0)