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 gbsyncd container for broncos #11154

Merged
merged 5 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 21 additions & 4 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function updateSyslogConf()
TARGET_IP=$(docker network inspect bridge --format={{ "'{{(index .IPAM.Config 0).Gateway}}'" }})
CONTAINER_NAME="$DOCKERNAME"
TMP_FILE="/tmp/rsyslog.$CONTAINER_NAME.conf"
{%- if docker_container_name == "database" %}
{%- if docker_container_name == "database" %}
python -c "import jinja2, os; paths=['/usr/share/sonic/templates']; loader = jinja2.FileSystemLoader(paths); env = jinja2.Environment(loader=loader, trim_blocks=True); template_file='/usr/share/sonic/templates/rsyslog-container.conf.j2'; template = env.get_template(os.path.basename(template_file)); data=template.render({\"target_ip\":\"$TARGET_IP\",\"container_name\":\"$CONTAINER_NAME\"}); print(data)" > $TMP_FILE
{%- else %}
sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE
Expand Down Expand Up @@ -105,7 +105,7 @@ function preStartAction()
if [[ $(/bin/systemctl status watchdog-control.service | grep -c running) -gt 0 ]]; then
echo "Stopping watchdog-control.service before starting PDE"
systemctl stop watchdog-control.service
fi
fi
{%- elif docker_container_name == "snmp" %}
$SONIC_DB_CLI STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s)
{%- else %}
Expand All @@ -127,7 +127,7 @@ function waitForAllInstanceDatabaseConfigJsonFilesReady()
cnt=0
SONIC_DB_GLOBAL_JSON="/var/run/redis/sonic-db/database_global.json"
if [ -f "$SONIC_DB_GLOBAL_JSON" ]; then
# Create a separate python script to get a list of location of all instance database_config.json file
# Create a separate python script to get a list of location of all instance database_config.json file
redis_database_cfg_list=`/usr/bin/python -c "import sys; import os; import json; f=open(sys.argv[1]); \
global_db_dir = os.path.dirname(sys.argv[1]); data=json.load(f); \
print(\" \".join([os.path.normpath(global_db_dir+'/'+elem['include']) \
Expand Down Expand Up @@ -297,6 +297,20 @@ start() {
source $PLATFORM_ENV_CONF
fi

{%- if docker_container_name == "gbsyncd" %}
GBSYNCD_CONF=/usr/share/sonic/device/$PLATFORM/gbsyncd.ini
GBSYNCD_PLATFORM=gbsyncd-vs
if [ -f "$GBSYNCD_CONF" ]; then
while IFS="=" read -r key value; do
case "$key" in
platform)
GBSYNCD_PLATFORM="$value"
;;
esac
done < "$GBSYNCD_CONF"
fi
{%- endif %}

{%- if docker_container_name == "database" %}
# Don't mount HWSKU in {{docker_container_name}} container.
HWSKU=""
Expand Down Expand Up @@ -522,7 +536,10 @@ start() {
--env "NAMESPACE_PREFIX"="$NAMESPACE_PREFIX" \
--env "NAMESPACE_COUNT"=$NUM_ASIC \
--name=$DOCKERNAME \
{%- if docker_image_name is defined %}
{%- if docker_container_name == "gbsyncd" %}
-v /var/run/docker-syncd$DEV:/var/run/sswsyncd \
"docker-$GBSYNCD_PLATFORM":latest \
{%- elif docker_image_name is defined %}
{{docker_image_name}}:latest \
{%- else %}
{{docker_image_id}} \
Expand Down
3 changes: 3 additions & 0 deletions platform/broadcom/rules.dep
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ include $(PLATFORM_PATH)/libsaithrift-dev.dep
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.dep
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.dep
include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.dep
ifeq ($(INCLUDE_GBSYNCD_BRONCOS), y)
include $(PLATFORM_PATH)/../components/docker-gbsyncd-broncos.dep
andywongarista marked this conversation as resolved.
Show resolved Hide resolved
endif
3 changes: 3 additions & 0 deletions platform/broadcom/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ include $(PLATFORM_PATH)/libsaithrift-dev.mk
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.mk
include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.mk
include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.mk
ifeq ($(INCLUDE_GBSYNCD_BRONCOS), y)
include $(PLATFORM_PATH)/../components/docker-gbsyncd-broncos.mk
andywongarista marked this conversation as resolved.
Show resolved Hide resolved
endif

BCMCMD = bcmcmd
$(BCMCMD)_URL = "https://sonicstorage.blob.core.windows.net/packages/20190307/bcmcmd?sv=2015-04-05&sr=b&sig=sUdbU7oVbh5exbXXHVL5TDFBTWDDBASHeJ8Cp0B0TIc%3D&se=2038-05-06T22%3A34%3A19Z&sp=r"
Expand Down
12 changes: 12 additions & 0 deletions platform/components/docker-gbsyncd-broncos.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DPATH := $($(DOCKER_GBSYNCD_BRONCOS)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST)
DEP_FILES += platform/components/docker-gbsyncd-broncos.mk
DEP_FILES += platform/components/docker-gbsyncd-broncos.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

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

$(eval $(call add_dbg_docker,$(DOCKER_GBSYNCD_BRONCOS),$(DOCKER_GBSYNCD_BRONCOS_DBG)))
37 changes: 37 additions & 0 deletions platform/components/docker-gbsyncd-broncos.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
LIBSAI_BRONCOS = libsaibroncos_0.0.1_amd64.deb
$(LIBSAI_BRONCOS)_URL =

ifneq ($($(LIBSAI_BRONCOS)_URL),)

DOCKER_GBSYNCD_BRONCOS_STEM = docker-gbsyncd-broncos
DOCKER_GBSYNCD_BRONCOS = $(DOCKER_GBSYNCD_BRONCOS_STEM).gz
DOCKER_GBSYNCD_BRONCOS_DBG = $(DOCKER_GBSYNCD_BRONCOS_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_GBSYNCD_BRONCOS)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

$(DOCKER_GBSYNCD_BRONCOS)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE)

$(DOCKER_GBSYNCD_BRONCOS)_DBG_DEPENDS += $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS)

$(DOCKER_GBSYNCD_BRONCOS)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES)

SONIC_DOCKER_IMAGES += $(DOCKER_GBSYNCD_BRONCOS)
SONIC_BULLSEYE_DOCKERS += $(DOCKER_GBSYNCD_BRONCOS)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_GBSYNCD_BRONCOS)

SONIC_DOCKER_DBG_IMAGES += $(DOCKER_GBSYNCD_BRONCOS_DBG)
SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_GBSYNCD_BRONCOS_DBG)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_GBSYNCD_BRONCOS_DBG)

$(DOCKER_GBSYNCD_BRONCOS)_CONTAINER_NAME = gbsyncd
$(DOCKER_GBSYNCD_BRONCOS)_RUN_OPT += --privileged -t
$(DOCKER_GBSYNCD_BRONCOS)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf
$(DOCKER_GBSYNCD_BRONCOS)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro

SONIC_ONLINE_DEBS += $(LIBSAI_BRONCOS)

$(DOCKER_GBSYNCD_BRONCOS)_VERSION = 1.0.0
$(DOCKER_GBSYNCD_BRONCOS)_PACKAGE_NAME = gbsyncd-broncos
$(DOCKER_GBSYNCD_BRONCOS)_PATH = $(PLATFORM_PATH)/../components/docker-gbsyncd-broncos
$(DOCKER_GBSYNCD_BRONCOS)_DEPENDS += $(SYNCD) $(LIBSAI_BRONCOS)
endif
40 changes: 40 additions & 0 deletions platform/components/docker-gbsyncd-broncos/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM docker-config-engine-bullseye

ARG docker_container_name
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

RUN apt-get update

RUN apt-get install -f -y iproute2 libcap2-bin libprotobuf-dev

COPY \
{% for deb in docker_gbsyncd_broncos_debs.split(' ') -%}
{% if 'libsaibcm' not in deb -%}
debs/{{ deb }}{{' '}}
{%- endif %}
{%- endfor -%}
debs/

RUN dpkg -i \
{% for deb in docker_gbsyncd_broncos_debs.split(' ') -%}
{% if 'libsaibcm' not in deb -%}
debs/{{ deb }}{{' '}}
{%- endif %}
{%- endfor %}

COPY ["docker-init.sh", "/usr/bin/"]
COPY ["start.sh", "/usr/bin/"]

COPY ["critical_processes.j2", "/usr/share/sonic/templates"]
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates"]

COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]

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

ENTRYPOINT ["/usr/bin/docker-init.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
program:syncd
16 changes: 16 additions & 0 deletions platform/components/docker-gbsyncd-broncos/docker-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/sh

GB_CONFIG=/usr/share/sonic/hwsku/gearbox_config.json

if [ ! -f $GB_CONFIG ]; then
exit 0
fi

CFGGEN_ARG="-j $GB_CONFIG"

mkdir -p /etc/supervisor/conf.d/

sonic-cfggen $CFGGEN_ARG -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
sonic-cfggen $CFGGEN_ARG -t /usr/share/sonic/templates/critical_processes.j2 > /etc/supervisor/critical_processes

exec /usr/local/bin/supervisord
14 changes: 14 additions & 0 deletions platform/components/docker-gbsyncd-broncos/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

HWSKU_DIR=/usr/share/sonic/hwsku

mkdir -p /etc/sai.d/

# Create/Copy the psai.profile to /etc/sai.d/psai.profile
if [ -f $HWSKU_DIR/psai.profile.j2 ]; then
sonic-cfggen -d -t $HWSKU_DIR/psai.profile.j2 > /etc/sai.d/psai.profile
else
if [ -f $HWSKU_DIR/psai.profile ]; then
cp $HWSKU_DIR/psai.profile /etc/sai.d/psai.profile
fi
fi
43 changes: 43 additions & 0 deletions platform/components/docker-gbsyncd-broncos/supervisord.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[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

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=unexpected
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

[program:syncd]
environment=BRONCOS_DEVICE_PATH=/usr/lib
command=/usr/bin/syncd -s -p /etc/sai.d/psai.profile -x /usr/share/sonic/hwsku/context_config.json -g 1
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited