Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 75104bb

Browse files
padmanarayanalguohan
authored andcommitted
[sflow]: Build infrastructure changes to support sflow docker and utilities (sonic-net#3251)
Introduce a new "sflow" container (if ENABLE_SFLOW is set). The new docker will include: hsflowd : host-sflow based daemon is the sFlow agent psample : Built from libpsample repository. Useful in debugging sampled packets/groups. sflowtool : Locally dump sflow samples (e.g. with a in-unit collector) In case of SONiC-VS, enable psample & act_sample kernel modules. VS' syncd needs iproute2=4.20.0-2~bpo9+1 & libcap2-bin=1:2.25-1 to support tc-sample tc-syncd is provided as a convenience tool for debugging (e.g. tc-syncd filter show ...)
1 parent ac1d2c1 commit 75104bb

File tree

28 files changed

+500
-0
lines changed

28 files changed

+500
-0
lines changed

dockers/docker-sflow/Dockerfile.j2

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
2+
FROM docker-config-engine-stretch
3+
4+
ARG docker_container_name
5+
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf
6+
7+
## Make apt-get non-interactive
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
RUN apt-get update && \
11+
apt-get install -f -y \
12+
dmidecode \
13+
libmnl0=1.0.4-2
14+
15+
{% if docker_sflow_debs.strip() -%}
16+
# Copy locally-built Debian package dependencies
17+
{{ copy_files("debs/", docker_sflow_debs.split(' '), "/debs/") }}
18+
19+
# Install locally-built Debian packages and implicitly install their dependencies
20+
{{ install_debian_packages(docker_sflow_debs.split(' ')) }}
21+
{%- endif %}
22+
23+
RUN apt-get clean -y && \
24+
apt-get autoclean -y && \
25+
apt-get autoremove -y && \
26+
rm -rf /debs
27+
28+
RUN sed -ri '/^DAEMON_ARGS=""/c DAEMON_ARGS="-c /var/log/hsflowd.crash"' /etc/init.d/hsflowd
29+
30+
COPY ["start.sh", "/usr/bin/"]
31+
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
32+
33+
ENTRYPOINT ["/usr/bin/supervisord"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
DOCKER_EXEC_FLAGS="i"
4+
5+
# Determine whether stdout is on a terminal
6+
if [ -t 1 ] ; then
7+
DOCKER_EXEC_FLAGS+="t"
8+
fi
9+
10+
docker exec -$DOCKER_EXEC_FLAGS sflow psample "$@"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
DOCKER_EXEC_FLAGS="i"
4+
5+
# Determine whether stdout is on a terminal
6+
if [ -t 1 ] ; then
7+
DOCKER_EXEC_FLAGS+="t"
8+
fi
9+
10+
docker exec -$DOCKER_EXEC_FLAGS sflow sflowtool "$@"

dockers/docker-sflow/start.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
rm -f /var/run/rsyslogd.pid
4+
5+
supervisorctl start rsyslogd
6+
7+
supervisorctl start sflowmgrd
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[supervisord]
2+
logfile_maxbytes=1MB
3+
logfile_backups=2
4+
nodaemon=true
5+
6+
[program:start.sh]
7+
command=/usr/bin/start.sh
8+
priority=1
9+
autostart=true
10+
autorestart=false
11+
stdout_logfile=syslog
12+
stderr_logfile=syslog
13+
14+
[program:rsyslogd]
15+
command=/usr/sbin/rsyslogd -n
16+
priority=2
17+
autostart=false
18+
autorestart=false
19+
stdout_logfile=syslog
20+
stderr_logfile=syslog
21+
22+
[program:sflowmgrd]
23+
command=/usr/bin/sflowmgrd
24+
priority=3
25+
autostart=false
26+
autorestart=false
27+
stdout_logfile=syslog
28+
stderr_logfile=syslog
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=sFlow container
3+
Requires=swss.service
4+
After=swss.service
5+
Before=ntp-config.service
6+
7+
[Service]
8+
User={{ sonicadmin_user }}
9+
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
10+
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
11+
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
12+
13+
[Install]
14+
WantedBy=multi-user.target

files/build_templates/sonic_debian_extension.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,14 @@ sudo cp $IMAGE_CONFIGS/platform/rc.local $FILESYSTEM_ROOT/etc/
300300
## copy blacklist file
301301
sudo cp $IMAGE_CONFIGS/platform/linux_kernel_bde.conf $FILESYSTEM_ROOT/etc/modprobe.d/
302302

303+
# Enable psample drivers to support sFlow on vs
304+
{% if sonic_asic_platform == "vs" %}
305+
sudo tee -a $FILESYSTEM_ROOT/etc/modules-load.d/modules.conf > /dev/null <<EOF
306+
psample
307+
act_sample
308+
EOF
309+
{% endif %}
310+
303311
## Bind docker path
304312
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
305313
sudo mkdir -p $FILESYSTEM_ROOT/dockerfs

platform/vs/docker-syncd-vs/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ENV DEBIAN_FRONTEND=noninteractive
88

99
RUN apt-get update
1010

11+
RUN apt-get install -f -y iproute2=4.20.0-2~bpo9+1 libcap2-bin=1:2.25-1
12+
1113
COPY \
1214
{% for deb in docker_syncd_vs_debs.split(' ') -%}
1315
debs/{{ deb }}{{' '}}

rules/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ FRR_USER_GID = 300
9595

9696
# Default VS build memory preparation
9797
DEFAULT_VS_PREPARE_MEM = yes
98+
99+
# ENABLE_SYSTEM_SFLOW - build docker-sonic-sflow for sFlow support
100+
ENABLE_SFLOW = y

rules/docker-sflow.mk

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# docker image for sFlow agent
2+
3+
DOCKER_SFLOW_STEM = docker-sflow
4+
DOCKER_SFLOW = $(DOCKER_SFLOW_STEM).gz
5+
DOCKER_SFLOW_DBG = $(DOCKER_SFLOW_STEM)-$(DBG_IMAGE_MARK).gz
6+
7+
$(DOCKER_SFLOW)_PATH = $(DOCKERS_PATH)/$(DOCKER_SFLOW_STEM)
8+
9+
$(DOCKER_SFLOW)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(HSFLOWD) $(SFLOWTOOL) $(PSAMPLE)
10+
$(DOCKER_SFLOW)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS)
11+
$(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG)
12+
$(DOCKER_SFLOW)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES)
13+
14+
$(DOCKER_SFLOW)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH)
15+
16+
SONIC_DOCKER_IMAGES += $(DOCKER_SFLOW)
17+
ifeq ($(ENABLE_SFLOW), y)
18+
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SFLOW)
19+
SONIC_STRETCH_DOCKERS += $(DOCKER_SFLOW)
20+
endif
21+
22+
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_SFLOW_DBG)
23+
ifeq ($(ENABLE_SFLOW), y)
24+
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_SFLOW_DBG)
25+
SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SFLOW_DBG)
26+
endif
27+
28+
$(DOCKER_SFLOW)_CONTAINER_NAME = sflow
29+
$(DOCKER_SFLOW)_RUN_OPT += --net=host --privileged -t
30+
$(DOCKER_SFLOW)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
31+
$(DOCKER_SFLOW)_RUN_OPT += -v /host/warmboot:/var/warmboot
32+
33+
$(DOCKER_SFLOW)_BASE_IMAGE_FILES += psample:/usr/bin/psample
34+
$(DOCKER_SFLOW)_BASE_IMAGE_FILES += sflowtool:/usr/bin/sflowtool
35+

0 commit comments

Comments
 (0)