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

Add bmp container init workflow. #18946

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 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
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 @@ -532,6 +532,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \
SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=$(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD) \
SONIC_INCLUDE_SYSTEM_TELEMETRY=$(INCLUDE_SYSTEM_TELEMETRY) \
SONIC_INCLUDE_SYSTEM_GNMI=$(INCLUDE_SYSTEM_GNMI) \
SONIC_INCLUDE_SYSTEM_BMP=$(INCLUDE_SYSTEM_BMP) \
SONIC_INCLUDE_SYSTEM_EVENTD=$(INCLUDE_SYSTEM_EVENTD) \
INCLUDE_DHCP_RELAY=$(INCLUDE_DHCP_RELAY) \
INCLUDE_DHCP_SERVER=$(INCLUDE_DHCP_SERVER) \
Expand Down
34 changes: 34 additions & 0 deletions dockers/docker-sonic-bmp/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% 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

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

# Pass the image_version to container
ENV IMAGE_VERSION=$image_version

RUN apt-get update


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

COPY ["bmp.sh", "bmpcfgd", "openbmpd", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["openbmpd.conf.j2", "/usr/share/sonic/templates/"]

RUN chmod +x /usr/bin/bmp.sh
RUN chmod +x /usr/bin/bmpcfgd
RUN chmod +x /usr/bin/openbmpd

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

ENTRYPOINT ["/usr/local/bin/supervisord"]
5 changes: 5 additions & 0 deletions dockers/docker-sonic-bmp/base_image_files/monit_bmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
###############################################################################
## Monit configuration for bmp container
###############################################################################
check program container_memory_bmp with path "/usr/bin/memory_checker bmp 419430400"
if status == 3 for 10 times within 20 cycles then exec "/usr/bin/docker exec bmp supervisorctl restart openbmpd"
10 changes: 10 additions & 0 deletions dockers/docker-sonic-bmp/base_image_files/redis-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

DOCKER_EXEC_FLAGS="i"

# Determine whether stdout is on a terminal
if [ -t 1 ] ; then
DOCKER_EXEC_FLAGS+="t"
fi

docker exec -$DOCKER_EXEC_FLAGS bmp redis-cli "$@"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you use this file?

26 changes: 26 additions & 0 deletions dockers/docker-sonic-bmp/bmp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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 /etc/bmp

is_multi_asic=$(python3 -c "from sonic_py_common.multi_asic import is_multi_asic; print(is_multi_asic())")

if [[ $is_multi_asic == "True" ]]; then
export multiASIC=true
else
export multiASIC=false
fi

ENABLE_MULTI_ASIC=$multiASIC j2 /usr/share/sonic/templates/openbmpd.conf.j2 > /etc/bmp/openbmpd.conf


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
20 changes: 20 additions & 0 deletions dockers/docker-sonic-bmp/openbmpd.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
base:
admin_id: hostname
listen_port: 5000
listen_mode: v4
buffers:
router: 15
heartbeat:
interval: 5
startup:
max_concurrent_routers: 2
initial_router_time: 60
calculate_baseline: true
pat_enabled: false
debug:
general: false
bmp: false
bgp: false
msgbus: false
redis:
multiAsic: {{ENABLE_MULTI_ASIC}}
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
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
autostart=true
autorestart=false
buffer_size=1024

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

[program:bmp]
command=/usr/bin/bmp.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/bmpcfgd
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=bmp:exited

[program:openbmpd]
command=/usr/bin/openbmpd -c /etc/bmp/openbmpd.conf
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=bmpcfgd:running
3 changes: 3 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ DEFAULT_VS_PREPARE_MEM = yes
# INCLUDE_SYSTEM_GNMI - build docker-sonic-gnmi for system gnmi support
INCLUDE_SYSTEM_GNMI = y

# INCLUDE_SYSTEM_BMP - build docker-sonic-bmp for system bmp support
INCLUDE_SYSTEM_BMP = y

# INCLUDE_SYSTEM_EVENTD - build docker-eventd for system eventd support
INCLUDE_SYSTEM_EVENTD = y

Expand Down
10 changes: 10 additions & 0 deletions rules/docker-bmp.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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)))
40 changes: 40 additions & 0 deletions rules/docker-bmp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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)_DEPENDS += $(LIBSWSSCOMMON) \
$(SONIC_DB_CLI)

$(DOCKER_BMP)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS)

$(DOCKER_BMP)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BOOKWORM)

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

$(DOCKER_BMP)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)

SONIC_DOCKER_IMAGES += $(DOCKER_BMP)
SONIC_BOOKWORM_DOCKERS += $(DOCKER_BMP)
ifeq ($(INCLUDE_SYSTEM_BMP), y)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_BMP)
endif

SONIC_DOCKER_DBG_IMAGES += $(DOCKER_BMP_DBG)
SONIC_BOOKWORM_DBG_DOCKERS += $(DOCKER_BMP_DBG)
ifeq ($(INCLUDE_SYSTEM_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)
$(DOCKER_BMP)_BASE_IMAGE_FILES += redis-cli:/usr/bin/redis-cli:monit_bmp:/etc/monit/conf.d
6 changes: 6 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ ifeq ($(SONIC_INCLUDE_SYSTEM_GNMI),y)
INCLUDE_SYSTEM_GNMI = y
endif

ifeq ($(SONIC_INCLUDE_SYSTEM_BMP),y)
INCLUDE_SYSTEM_BMP = y
endif

ifeq ($(SONIC_INCLUDE_SYSTEM_EVENTD),y)
INCLUDE_SYSTEM_EVENTD = y
endif
Expand Down Expand Up @@ -439,6 +443,7 @@ $(info "INCLUDE_MGMT_FRAMEWORK" : "$(INCLUDE_MGMT_FRAMEWORK)")
$(info "INCLUDE_ICCPD" : "$(INCLUDE_ICCPD)")
$(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)")
$(info "INCLUDE_SYSTEM_GNMI" : "$(INCLUDE_SYSTEM_GNMI)")
$(info "INCLUDE_SYSTEM_BMP" : "$(INCLUDE_SYSTEM_BMP)")
$(info "INCLUDE_SYSTEM_EVENTD" : "$(INCLUDE_SYSTEM_EVENTD)")
$(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)")
$(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)")
Expand Down Expand Up @@ -1433,6 +1438,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export sonic_su_prod_signing_tool="/sonic/scripts/$(shell basename -- $(SECURE_UPGRADE_PROD_SIGNING_TOOL))"
export include_system_telemetry="$(INCLUDE_SYSTEM_TELEMETRY)"
export include_system_gnmi="$(INCLUDE_SYSTEM_GNMI)"
export include_system_bmp="$(INCLUDE_SYSTEM_BMP)"
export include_system_eventd="$(INCLUDE_SYSTEM_EVENTD)"
export build_reduce_image_size="$(BUILD_REDUCE_IMAGE_SIZE)"
export include_restapi="$(INCLUDE_RESTAPI)"
Expand Down
Loading