-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
FengPan-Frank
wants to merge
10
commits into
sonic-net:master
Choose a base branch
from
FengPan-Frank:bmp_init
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7a16e26
Add bmp container init workflow.
FengPan-Frank 75f40be
Add bmp container init workflow.
FengPan-Frank dcc5ce9
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank 0879370
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank 078a1f7
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank ef759dc
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank 862d2f4
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank 173c023
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank 9aed10e
Merge branch 'bmp_init' of https://github.com/FengPan-Frank/sonic-bui…
FengPan-Frank a095920
Merge branch 'sonic-net:master' into bmp_init
FengPan-Frank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
group:sonic-bmp | ||
program:openbmpd | ||
program:bmpcfgd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will turn this on as last step after bmp/bmpcfgd PR are merged. |
||
INCLUDE_BMP = y | ||
|
||
# INCLUDE_P4RT - build docker-p4rt for P4RT support | ||
INCLUDE_P4RT = n | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not change init_cfg.json.j2, in order to enable by default in image. This enablement is controlled by golden config generation service outside sonic.