Skip to content

Commit 7313e7d

Browse files
Shuotian Chenglguohan
Shuotian Cheng
authored andcommitted
[teamd]: Add teammgrd in docker-teamd (#2064)
Remove the teamd.j2 templates used for starting the teamd. Add teammgrd instead to manage all port channel related configuration changes. Remove front panel port related configurations in interfaces.j2 templates as well. Remove teamd.sh script and use teammgrd to start all the teamd processes. Remove all the logics in the start.sh script as well. Update the sonic-swss submodule. Signed-off-by: Shu0T1an ChenG <[email protected]>
1 parent 890baed commit 7313e7d

File tree

12 files changed

+26
-183
lines changed

12 files changed

+26
-183
lines changed

dockers/docker-teamd/Dockerfile.j2

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ RUN dpkg -i \
2525
debs/{{ deb }}{{' '}}
2626
{%- endfor %}
2727

28-
COPY ["start.sh", "teamd.sh", "/usr/bin/"]
28+
COPY ["start.sh", "/usr/bin/"]
2929
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
30-
COPY ["teamd.j2", "/usr/share/sonic/templates/"]
3130

3231
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
3332
RUN rm -rf /debs

dockers/docker-teamd/start.sh

+4-34
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,10 @@
11
#!/usr/bin/env bash
22

3-
TEAMD_CONF_PATH=/etc/teamd
4-
5-
rm -rf $TEAMD_CONF_PATH
6-
mkdir -p $TEAMD_CONF_PATH
7-
8-
SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
9-
10-
if [ "$SONIC_ASIC_TYPE" == "mellanox" ]; then
11-
MAC_ADDRESS=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac)
12-
else
13-
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
14-
fi
15-
16-
# Align last byte
17-
if [ "$SONIC_ASIC_TYPE" == "mellanox" -o "$SONIC_ASIC_TYPE" == "centec" ]; then
18-
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
19-
aligned_last_byte=$(python -c "print format(int(int('$last_byte', 16) & 0b11000000), '02x')") # put mask and take away the 0x prefix
20-
MAC_ADDRESS=$(python -c "print '$MAC_ADDRESS'[:-2] + '$aligned_last_byte'") # put aligned byte into the end of MAC
21-
fi
22-
23-
for pc in `sonic-cfggen -d -v "PORTCHANNEL.keys() | join(' ') if PORTCHANNEL"`; do
24-
sonic-cfggen -d -a '{"pc":"'$pc'","hwaddr":"'$MAC_ADDRESS'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
25-
# bring down all member ports before starting teamd
26-
for member in $(sonic-cfggen -d -v "PORTCHANNEL['$pc']['members'] | join(' ')" ); do
27-
if [ -L /sys/class/net/$member ]; then
28-
ip link set $member down
29-
fi
30-
done
31-
done
32-
33-
mkdir -p /var/sonic
34-
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
35-
363
rm -f /var/run/rsyslogd.pid
4+
rm -f /var/run/teamd/*
375

386
supervisorctl start rsyslogd
397

40-
supervisorctl start teamd
8+
supervisorctl start teammgrd
9+
10+
supervisorctl start teamsyncd

dockers/docker-teamd/supervisord.conf

+10-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@ autorestart=false
1919
stdout_logfile=syslog
2020
stderr_logfile=syslog
2121

22-
[program:teamd]
23-
command=/usr/bin/teamd.sh
22+
[program:teammgrd]
23+
command=/usr/bin/teammgrd
24+
priority=3
25+
autostart=false
26+
autorestart=false
27+
stdout_logfile=syslog
28+
stderr_logfile=syslog
29+
30+
[program:teamsyncd]
31+
command=/usr/bin/teamsyncd
2432
priority=3
2533
autostart=false
2634
autorestart=false

dockers/docker-teamd/teamd.j2

-25
This file was deleted.

dockers/docker-teamd/teamd.sh

-28
This file was deleted.

files/image_config/interfaces/interfaces.j2

-16
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,3 @@ iface eth0 inet dhcp
4848
{% endif %}
4949
#
5050
{% endblock mgmt_interface %}
51-
{% block front_panel_interfaces %}
52-
{% if PORTCHANNEL %}
53-
# "|| true" is added to suppress the error when interface is already a member of LAG
54-
# "ip link show | grep -q master" is added to ensure interface is enslaved
55-
{% for pc in PORTCHANNEL.keys()|sort %}
56-
{% for member in PORTCHANNEL[pc]['members'] %}
57-
allow-hotplug {{ member }}
58-
iface {{ member }} inet manual
59-
pre-up teamdctl {{ pc }} port add {{ member }} || true
60-
post-up ip link show {{ member }} | grep -q master && ifconfig {{ member }} up
61-
post-down ifconfig {{ member }} down
62-
#
63-
{% endfor %}
64-
{% endfor %}
65-
{% endif %}
66-
{% endblock front_panel_interfaces %}

platform/vs/docker-sonic-vs/start.sh

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ supervisorctl start teamsyncd
4343

4444
supervisorctl start fpmsyncd
4545

46+
supervisorctl start teammgrd
47+
4648
supervisorctl start portmgrd
4749

4850
supervisorctl start intfmgrd

platform/vs/docker-sonic-vs/supervisord.conf

+8
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ autorestart=false
9999
stdout_logfile=syslog
100100
stderr_logfile=syslog
101101

102+
[program:teammgrd]
103+
command=/usr/bin/teammgrd
104+
priority=12
105+
autostart=false
106+
autorestart=false
107+
stdout_logfile=syslog
108+
stderr_logfile=syslog
109+
102110
[program:zebra]
103111
command=/usr/lib/quagga/zebra -A 127.0.0.1
104112
priority=13

src/sonic-config-engine/tests/sample_output/interfaces

-26
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,4 @@ iface eth0 inet6 static
4747
down ip -6 route delete 2603:10e2:0:2902::/64 dev eth0 table default
4848
down ip -6 rule delete from 2603:10e2:0:2902::8/128 table default
4949
#
50-
# "|| true" is added to suppress the error when interface is already a member of LAG
51-
# "ip link show | grep -q master" is added to ensure interface is enslaved
52-
allow-hotplug fortyGigE0/112
53-
iface fortyGigE0/112 inet manual
54-
pre-up teamdctl PortChannel01 port add fortyGigE0/112 || true
55-
post-up ip link show fortyGigE0/112 | grep -q master && ifconfig fortyGigE0/112 up
56-
post-down ifconfig fortyGigE0/112 down
57-
#
58-
allow-hotplug fortyGigE0/116
59-
iface fortyGigE0/116 inet manual
60-
pre-up teamdctl PortChannel02 port add fortyGigE0/116 || true
61-
post-up ip link show fortyGigE0/116 | grep -q master && ifconfig fortyGigE0/116 up
62-
post-down ifconfig fortyGigE0/116 down
63-
#
64-
allow-hotplug fortyGigE0/120
65-
iface fortyGigE0/120 inet manual
66-
pre-up teamdctl PortChannel03 port add fortyGigE0/120 || true
67-
post-up ip link show fortyGigE0/120 | grep -q master && ifconfig fortyGigE0/120 up
68-
post-down ifconfig fortyGigE0/120 down
69-
#
70-
allow-hotplug fortyGigE0/124
71-
iface fortyGigE0/124 inet manual
72-
pre-up teamdctl PortChannel04 port add fortyGigE0/124 || true
73-
post-up ip link show fortyGigE0/124 | grep -q master && ifconfig fortyGigE0/124 up
74-
post-down ifconfig fortyGigE0/124 down
75-
#
7650

src/sonic-config-engine/tests/sample_output/pc_sample_output/PortChannel01.conf

-20
This file was deleted.

src/sonic-config-engine/tests/test_j2files.py

-29
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,6 @@ def test_config_frr(self):
7575
self.run_script(argument)
7676
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'frr.conf'), self.output_file))
7777

78-
def test_teamd(self):
79-
80-
def test_render_teamd(self, pc, minigraph, sample_output):
81-
teamd_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-teamd', 'teamd.j2')
82-
argument = '-m ' + minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"pc\":\"' + pc + '\",\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + teamd_file + ' > ' + self.output_file
83-
self.run_script(argument)
84-
self.assertTrue(filecmp.cmp(sample_output, self.output_file))
85-
86-
# Test T0 minigraph
87-
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -v "PORTCHANNEL.keys() | join(\' \') if PORTCHANNEL"'
88-
output = self.run_script(argument) # Mock the output via config.sh in docker-teamd
89-
pc_list = output.split()
90-
91-
for i in range(1, 5):
92-
pc_name = 'PortChannel0' + str(i)
93-
self.assertTrue(pc_name in pc_list)
94-
sample_output = os.path.join(self.test_dir, 'sample_output', 't0_sample_output', pc_name + '.conf')
95-
test_render_teamd(self, pc_name, self.t0_minigraph, sample_output)
96-
97-
# Test port channel test minigraph
98-
argument = '-m ' + self.pc_minigraph + ' -p ' + self.t0_port_config + ' -v "PORTCHANNEL.keys() | join(\' \') if PORTCHANNEL"'
99-
output = self.run_script(argument) # Mock the output via config.sh in docker-teamd
100-
pc_list = output.split()
101-
102-
pc_name = 'PortChannel01'
103-
self.assertTrue(pc_name in pc_list)
104-
sample_output = os.path.join(self.test_dir, 'sample_output', 'pc_sample_output', pc_name + '.conf')
105-
test_render_teamd(self, pc_name, self.pc_minigraph, sample_output)
106-
10778
def test_ipinip(self):
10879
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
10980
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file

src/sonic-swss

0 commit comments

Comments
 (0)