Skip to content

Commit

Permalink
Revert "[docker-teamd]: Manage teamd and teamsyncd processes with sup…
Browse files Browse the repository at this point in the history
…ervisor (#1137)" (#1156)

This reverts commit a6edef2.

The reason to revert this commit is that it breaks the current nightly test as
no port channel interfaces are get created after boot. teamd failed to start and
complained about 'Cannot allocate memory' possibly due to nlmsg_alloc function
failure.

Will revert this commit to investigate it further before moving to supervisor.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shuotian Cheng authored Nov 16, 2017
1 parent d376506 commit c93c008
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 240 deletions.
7 changes: 4 additions & 3 deletions dockers/docker-teamd/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ RUN dpkg -i \
debs/{{ deb }}{{' '}}
{%- endfor %}

COPY ["docker-teamd-init.sh", "docker-teamd-start.sh", "teamd.sh", "/usr/bin/"]
COPY ["docker-teamd.supervisord.conf.j2", "teamd.j2", "/usr/share/sonic/templates/"]
COPY ["start.sh", "teamd.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["teamd.j2", "/usr/share/sonic/templates/"]

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

ENTRYPOINT ["/usr/bin/docker-teamd-init.sh"]
ENTRYPOINT ["/usr/bin/supervisord"]
43 changes: 0 additions & 43 deletions dockers/docker-teamd/docker-teamd-init.sh

This file was deleted.

9 changes: 0 additions & 9 deletions dockers/docker-teamd/docker-teamd-start.sh

This file was deleted.

52 changes: 0 additions & 52 deletions dockers/docker-teamd/docker-teamd.supervisord.conf.j2

This file was deleted.

35 changes: 35 additions & 0 deletions dockers/docker-teamd/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

TEAMD_CONF_PATH=/etc/teamd

rm -rf $TEAMD_CONF_PATH
mkdir -p $TEAMD_CONF_PATH

SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')

# Align last byte
if [ "$SONIC_ASIC_TYPE" == "mellanox" -o "$SONIC_ASIC_TYPE" == "centec" ]; then
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
aligned_last_byte=$(python -c "print format(int(int('$last_byte', 16) & 0b11000000), '02x')") # put mask and take away the 0x prefix
MAC_ADDRESS=$(python -c "print '$MAC_ADDRESS'[:-2] + '$aligned_last_byte'") # put aligned byte into the end of MAC
fi

for pc in `sonic-cfggen -d -v "PORTCHANNEL.keys() | join(' ') if PORTCHANNEL"`; do
sonic-cfggen -d -a '{"pc":"'$pc'","hwaddr":"'$MAC_ADDRESS'"}' -t /usr/share/sonic/templates/teamd.j2 > $TEAMD_CONF_PATH/$pc.conf
# bring down all member ports before starting teamd
for member in $(sonic-cfggen -d -v "PORTCHANNEL['$pc']['members'] | join(' ')" ); do
if [ -L /sys/class/net/$member ]; then
ip link set $member down
fi
done
done

mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status

rm -f /var/run/rsyslogd.pid

supervisorctl start rsyslogd

supervisorctl start teamd
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

[group:isc-dhcp-relay]
programs=isc-dhcp-relay-Vlan1000

[program:isc-dhcp-relay-Vlan1000]
command=/usr/sbin/dhcrelay -d -m discard -a %%h:%%p %%P --name-alias-map-file /tmp/port-name-alias-map.txt -i Vlan1000 -i PortChannel02 -i PortChannel03 -i PortChannel04 -i PortChannel01 192.0.0.1 192.0.0.2
[program:teamd]
command=/usr/bin/teamd.sh
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog


27 changes: 20 additions & 7 deletions dockers/docker-teamd/teamd.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/usr/bin/env bash

TEAMD_CONF_FILE=$1
TEAMD_CONF_PATH=/etc/teamd

function start_app {
rm -f /var/run/teamd/*
if [ "$(ls -A $TEAMD_CONF_PATH)" ]; then
for f in $TEAMD_CONF_PATH/*; do
teamd -f $f -d
done
fi
teamsyncd &
}

function clean_up {
teamd -f $TEAMD_CONF_FILE -k
exit $?
if [ "$(ls -A $TEAMD_CONF_PATH)" ]; then
for f in $TEAMD_CONF_PATH/*; do
teamd -f $f -k
done
fi
pkill -9 teamsyncd
exit
}

trap clean_up SIGTERM SIGKILL

teamd -f $TEAMD_CONF_FILE &
TEAMD_PID=$!
wait $TEAMD_PID
exit $?
start_app
read

This file was deleted.

28 changes: 0 additions & 28 deletions src/sonic-config-engine/tests/sample_output/wait_for_intf.sh

This file was deleted.

30 changes: 3 additions & 27 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ def test_alias_map(self):
data = json.loads(output)
self.assertEqual(data["Ethernet4"], "fortyGigE0/4")

def test_dhcp_relay(self):
# Test generation of wait_for_intf.sh
template_path = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-dhcp-relay', 'wait_for_intf.sh.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + template_path + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'wait_for_intf.sh'), self.output_file))

# Test generation of docker-dhcp-relay.supervisord.conf
template_path = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-dhcp-relay', 'docker-dhcp-relay.supervisord.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + template_path + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'docker-dhcp-relay.supervisord.conf'), self.output_file))

def test_lldp(self):
lldpd_conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-lldp-sv2', 'lldpd.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + lldpd_conf_template + ' > ' + self.output_file
Expand All @@ -62,7 +49,7 @@ def test_render_teamd(self, pc, minigraph, sample_output):

# Test T0 minigraph
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -v "PORTCHANNEL.keys() | join(\' \') if PORTCHANNEL"'
output = self.run_script(argument) # Mock the output via docker-teamd-init.sh in docker-teamd
output = self.run_script(argument) # Mock the output via config.sh in docker-teamd
pc_list = output.split()

for i in range(1, 5):
Expand All @@ -71,27 +58,16 @@ def test_render_teamd(self, pc, minigraph, sample_output):
sample_output = os.path.join(self.test_dir, 'sample_output', 't0_sample_output', pc_name + '.conf')
test_render_teamd(self, pc_name, self.t0_minigraph, sample_output)

# Test port channel test minigraph (for testing proper 'min_ports' attribute generation)
# Test port channel test minigraph
argument = '-m ' + self.pc_minigraph + ' -p ' + self.t0_port_config + ' -v "PORTCHANNEL.keys() | join(\' \') if PORTCHANNEL"'
output = self.run_script(argument) # Mock the output via docker-teamd-init.sh in docker-teamd
output = self.run_script(argument) # Mock the output via config.sh in docker-teamd
pc_list = output.split()

pc_name = 'PortChannel01'
self.assertTrue(pc_name in pc_list)
sample_output = os.path.join(self.test_dir, 'sample_output', 'pc_sample_output', pc_name + '.conf')
test_render_teamd(self, pc_name, self.pc_minigraph, sample_output)

# Test generation of docker-teamd.supervisord.conf
template_path = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-teamd', 'docker-teamd.supervisord.conf.j2')
teamd_conf_dir = os.path.join(self.test_dir, 'sample_output', 't0_sample_output')

lags_dict = {}
lags_dict['lags'] = [{'name': os.path.basename(file).split('.')[0], 'file': os.path.join(teamd_conf_dir, file)} for file in sorted(os.listdir(teamd_conf_dir))]
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'' + json.dumps(lags_dict) + '\' -t ' + template_path + ' > ' + self.output_file

self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'docker-teamd.supervisord.conf'), self.output_file))

def test_ipinip(self):
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file
Expand Down

0 comments on commit c93c008

Please sign in to comment.