Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build bmp container into sonic-buildimage #18946

Merged
merged 49 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
7a16e26
Add bmp container init workflow.
FengPan-Frank May 13, 2024
75f40be
Add bmp container init workflow.
FengPan-Frank May 13, 2024
dcc5ce9
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 14, 2024
0879370
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 14, 2024
078a1f7
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 16, 2024
ef759dc
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 16, 2024
862d2f4
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 23, 2024
173c023
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 23, 2024
9aed10e
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank May 23, 2024
a095920
Merge branch 'sonic-net:master' into bmp_init
FengPan-Frank Jul 31, 2024
8d0a4ec
Merge branch 'master' into bmp_init
FengPan-Frank Nov 8, 2024
e4cfde1
integration change
FengPan-Frank Nov 8, 2024
9b23a95
integration change
FengPan-Frank Nov 8, 2024
dff6708
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 8, 2024
87d5eb3
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 8, 2024
c053190
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 8, 2024
e0d8cd7
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 8, 2024
67d38fc
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 14, 2024
7b1d536
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 14, 2024
f590880
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 14, 2024
7b72433
Fix bug
FengPan-Frank Nov 14, 2024
62d5359
Fix bug
FengPan-Frank Nov 14, 2024
33e3ebb
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 18, 2024
6c8d8f3
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 18, 2024
e356174
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 18, 2024
332f74f
Merge branch 'sonic-net:master' into bmp_init
FengPan-Frank Nov 19, 2024
b909777
debug
FengPan-Frank Nov 19, 2024
3fd12e4
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 19, 2024
fdecfb0
fix submodule
FengPan-Frank Nov 19, 2024
22ad972
Merge branch 'sonic-net:master' into bmp_init
FengPan-Frank Nov 19, 2024
808f8c0
skip bmpcfgd test temporarily
FengPan-Frank Nov 19, 2024
d1c3e10
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 19, 2024
cd6af6f
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 19, 2024
9d8b842
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 20, 2024
b48c9a4
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 20, 2024
676b867
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 20, 2024
b13fe8e
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 20, 2024
0f9b171
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 20, 2024
f140130
Launch bmp container by default
FengPan-Frank Nov 21, 2024
c70e767
Merge branch 'sonic-net:master' into bmp_init
FengPan-Frank Nov 21, 2024
d92aaca
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
d17acb2
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
45d9fff
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
cfc4d2b
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
c3db6bd
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
6841079
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
47bb5b6
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
0a6eb6b
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
f98ed10
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
[submodule "src/sonic-gnmi"]
path = src/sonic-gnmi
url = https://github.com/sonic-net/sonic-gnmi.git
[submodule "src/sonic-bmp"]
path = src/sonic-bmp
url = https://github.com/sonic-net/sonic-bmp.git
[submodule "src/sonic-genl-packet"]
path = src/sonic-genl-packet
url = https://github.com/sonic-net/sonic-genl-packet
Expand Down
1 change: 1 addition & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \
INCLUDE_DHCP_RELAY=$(INCLUDE_DHCP_RELAY) \
INCLUDE_DHCP_SERVER=$(INCLUDE_DHCP_SERVER) \
INCLUDE_MACSEC=$(INCLUDE_MACSEC) \
INCLUDE_BMP=$(INCLUDE_BMP) \
SONIC_INCLUDE_RESTAPI=$(INCLUDE_RESTAPI) \
SONIC_INCLUDE_MUX=$(INCLUDE_MUX) \
ENABLE_TRANSLIB_WRITE=$(ENABLE_TRANSLIB_WRITE) \
Expand Down
57 changes: 57 additions & 0 deletions dockers/docker-sonic-bmp/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}

ARG docker_container_name
ARG image_version
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

# Pass the image_version to container
ENV IMAGE_VERSION=$image_version

RUN apt-get update && \
apt-get install -f -y \
python3-dev \
build-essential

RUN mkdir -p /var/run

RUN pip3 install psutil
# TODO issue on remote rsyslog server in non-host container
RUN rm -f /etc/supervisor/conf.d/containercfgd.conf

{% if docker_bmp_debs.strip() -%}
# Copy locally-built Debian package dependencies
{{ copy_files("debs/", docker_bmp_debs.split(' '), "/debs/") }}

# Install locally-built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_bmp_debs.split(' ')) }}
{%- endif %}

{% if docker_bmp_whls.strip() %}
# Copy locally-built Python wheel dependencies
{{ copy_files("python-wheels/", docker_bmp_whls.split(' '), "/python-wheels/") }}

# Install locally-built Python wheel dependencies
{{ install_python_wheels(docker_bmp_whls.split(' ')) }}
{% endif %}

# Remove build stuff we don't need
RUN apt-get remove -y build-essential \
python3-dev

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

COPY ["docker_init.sh", "start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["rsyslog/rsyslog.conf.j2", "openbmpd.conf.j2", "/usr/share/sonic/templates/"]
COPY ["critical_processes", "/etc/supervisor/"]
COPY ["rsyslog/default.conf", "/etc/rsyslog.d"]

ENTRYPOINT ["/usr/bin/docker_init.sh"]
3 changes: 3 additions & 0 deletions dockers/docker-sonic-bmp/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group:sonic-bmp
program:openbmpd
program:bmpcfgd
18 changes: 18 additions & 0 deletions dockers/docker-sonic-bmp/docker_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash


# Generate supervisord config file
mkdir -p /etc/supervisor/conf.d/

udp_server_ip=$(ip -j -4 addr list lo scope host | jq -r -M '.[0].addr_info[0].local')
hostname=$(hostname)
# Generate the following files from templates:
# port-to-alias name map
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 \
-a "{\"udp_server_ip\": \"$udp_server_ip\", \"hostname\": \"$hostname\"}" \
> /etc/rsyslog.conf

# The docker container should start this script as PID 1, so now that supervisord is
# properly configured, we exec /usr/local/bin/supervisord so that it runs as PID 1 for the
# duration of the container's lifetime
exec /usr/local/bin/supervisord
18 changes: 18 additions & 0 deletions dockers/docker-sonic-bmp/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

if [ "${RUNTIME_OWNER}" == "" ]; then
RUNTIME_OWNER="kube"
fi

CTR_SCRIPT="/usr/share/sonic/scripts/container_startup.py"
if test -f ${CTR_SCRIPT}
then
${CTR_SCRIPT} -f bmp -o ${RUNTIME_OWNER} -v ${IMAGE_VERSION}
fi

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

TZ=$(cat /etc/timezone)
rm -rf /etc/localtime
ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
63 changes: 63 additions & 0 deletions dockers/docker-sonic-bmp/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python3 -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE
buffer_size=1024

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bmp --use-unix-socket-path
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
autostart=true
autorestart=unexpected
buffer_size=1024

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:start]
command=/usr/bin/start.sh
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[group:sonic-bmp]
programs=openbmpd,bmpcfgd

[program:bmpcfgd]
command=/usr/bin/openbmpd
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited

[program:openbmpd]
command=/usr/bin/openbmpd -c /etc/conf/openbmpd.conf
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=bmpcfgd:running
18 changes: 18 additions & 0 deletions files/build_templates/bmp.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=openbmp server container
After=bgp.service
BindsTo=sonic.target
After=sonic.target
StartLimitIntervalSec=1200
StartLimitBurst=3

[Service]
User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start
ExecStart=/usr/bin/{{ docker_container_name }}.sh wait
ExecStop=/usr/bin/{{ docker_container_name }}.sh stop
Restart=always
RestartSec=30

[Install]
WantedBy=sonic.target
1 change: 1 addition & 0 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
{%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", true, "enabled")) %}{% endif %}
{%- if include_macsec == "y" %}{% do features.append(("macsec", "{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' and DEVICE_RUNTIME_METADATA['MACSEC_SUPPORTED'] %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}{% endif %}
{%- if include_system_gnmi == "y" %}{% do features.append(("gnmi", "enabled", true, "enabled")) %}{% endif %}
{%- if include_bmp == "y" %}{% do features.append(("bmp", "enabled", true, "enabled")) %}{% endif %}
FengPan-Frank marked this conversation as resolved.
Show resolved Hide resolved
{%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %}
{%- if include_system_eventd == "y" and BUILD_REDUCE_IMAGE_SIZE == "y" %}
{% do features.append(("eventd","disabled", false, "enabled")) %}
Expand Down
3 changes: 3 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ INCLUDE_DHCP_RELAY = y
# INCLUDE_DHCP_SERVER - build and install dhcp-server package
INCLUDE_DHCP_SERVER ?= n

# INCLUDE_BMP - build and install sonic-bmp package
FengPan-Frank marked this conversation as resolved.
Show resolved Hide resolved
INCLUDE_BMP = y

# INCLUDE_P4RT - build docker-p4rt for P4RT support
INCLUDE_P4RT = n

Expand Down
11 changes: 11 additions & 0 deletions rules/docker-bmp.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

DPATH := $($(DOCKER_BMP)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-bmp.mk rules/docker-bmp.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

$(DOCKER_BMP)_CACHE_MODE := GIT_CONTENT_SHA
$(DOCKER_BMP)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(DOCKER_BMP)_DEP_FILES := $(DEP_FILES)

$(eval $(call add_dbg_docker,$(DOCKER_BMP),$(DOCKER_BMP_DBG)))
36 changes: 36 additions & 0 deletions rules/docker-bmp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# docker image for BMP agent

DOCKER_BMP_STEM = docker-sonic-bmp
DOCKER_BMP = $(DOCKER_BMP_STEM).gz
DOCKER_BMP_DBG = $(DOCKER_BMP_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_BMP)_PATH = $(DOCKERS_PATH)/$(DOCKER_BMP_STEM)

$(DOCKER_BMP)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS)

$(DOCKER_BMP)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE)

$(DOCKER_BMP)_VERSION = 1.0.0
$(DOCKER_BMP)_PACKAGE_NAME = bmp

$(DOCKER_BMP)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES)

SONIC_DOCKER_IMAGES += $(DOCKER_BMP)
SONIC_BULLSEYE_DOCKERS += $(DOCKER_BMP)
ifeq ($(INCLUDE_BMP), y)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_BMP)
endif

SONIC_DOCKER_DBG_IMAGES += $(DOCKER_BMP_DBG)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_BMP_DBG)
ifeq ($(INCLUDE_BMP), y)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_BMP_DBG)
endif

$(DOCKER_BMP)_CONTAINER_NAME = bmp
$(DOCKER_BMP)_RUN_OPT += -t
$(DOCKER_BMP)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_BMP)_RUN_OPT += -v /etc/timezone:/etc/timezone:ro
$(DOCKER_BMP)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw

$(DOCKER_BMP)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
2 changes: 2 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ $(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)")
$(info "INCLUDE_NAT" : "$(INCLUDE_NAT)")
$(info "INCLUDE_DHCP_RELAY" : "$(INCLUDE_DHCP_RELAY)")
$(info "INCLUDE_DHCP_SERVER" : "$(INCLUDE_DHCP_SERVER)")
$(info "INCLUDE_BMP" : "$(INCLUDE_BMP)")
$(info "INCLUDE_P4RT" : "$(INCLUDE_P4RT)")
$(info "INCLUDE_KUBERNETES" : "$(INCLUDE_KUBERNETES)")
$(info "INCLUDE_KUBERNETES_MASTER" : "$(INCLUDE_KUBERNETES_MASTER)")
Expand Down Expand Up @@ -1433,6 +1434,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export enable_asan="$(ENABLE_ASAN)"
export include_macsec="$(INCLUDE_MACSEC)"
export include_dhcp_server="$(INCLUDE_DHCP_SERVER)"
export include_bmp="$(INCLUDE_BMP)"
export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)"
export include_iccpd="$(INCLUDE_ICCPD)"
export pddf_support="$(PDDF_SUPPORT)"
Expand Down
Loading