From d27bc1fe014f99303699c2de27d1b8d6a2baf7c9 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Mon, 5 Jun 2023 20:29:54 +0000 Subject: [PATCH 01/20] Added sonic-device-healh as new submodule --- .gitmodules | 3 +++ src/sonic-device-health | 1 + 2 files changed, 4 insertions(+) create mode 160000 src/sonic-device-health diff --git a/.gitmodules b/.gitmodules index 2715540c1f90..6a64b75fc1d4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -115,3 +115,6 @@ [submodule "src/dhcpmon"] path = src/dhcpmon url = https://github.com/sonic-net/sonic-dhcpmon.git +[submodule "src/sonic-device-health"] + path = src/sonic-device-health + url = https://github.com/renukamanavalan/sonic-device-health.git diff --git a/src/sonic-device-health b/src/sonic-device-health new file mode 160000 index 000000000000..c24e2c24e8a9 --- /dev/null +++ b/src/sonic-device-health @@ -0,0 +1 @@ +Subproject commit c24e2c24e8a927c00517e0a6511e2019bb9e893e From 8fdd5270a420b95175a5bc0a61815f4978e6b644 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Tue, 6 Jun 2023 23:08:13 +0000 Subject: [PATCH 02/20] Added dockers files --- dockers/docker-device-health/Dockerfile.j2 | 38 +++++++++++ .../LoMSupervisord.conf.j2 | 68 +++++++++++++++++++ .../docker-device-health/critical_processes | 2 + dockers/docker-device-health/docker_init.sh | 16 +++++ dockers/docker-device-health/start.sh | 12 ++++ 5 files changed, 136 insertions(+) create mode 100644 dockers/docker-device-health/Dockerfile.j2 create mode 100644 dockers/docker-device-health/LoMSupervisord.conf.j2 create mode 100644 dockers/docker-device-health/critical_processes create mode 100755 dockers/docker-device-health/docker_init.sh create mode 100755 dockers/docker-device-health/start.sh diff --git a/dockers/docker-device-health/Dockerfile.j2 b/dockers/docker-device-health/Dockerfile.j2 new file mode 100644 index 000000000000..6ffb1ce8f8c2 --- /dev/null +++ b/dockers/docker-device-health/Dockerfile.j2 @@ -0,0 +1,38 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} +FROM docker-config-engine-bullseye-{{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 + +# Pass the Config location to procs in container +ENV LOM_CONF_LOCATION=/usr/share/lom/ + +# Update apt's cache of available packages +RUN apt-get update + +{% if docker_device_health_debs.strip() -%} +# Copy built Debian packages +{{ copy_files("debs/", docker_device_health_debs.split(' '), "/debs/") }} + +# Install built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_device_health_debs.split(' ')) }} +{%- endif %} + +# Clean up +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 ["lom.supervisord.conf.j2", "/usr/share/sonic/templates/"] +COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] +COPY ["critical_processes", "/etc/supervisor"] + +ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-device-health/LoMSupervisord.conf.j2 b/dockers/docker-device-health/LoMSupervisord.conf.j2 new file mode 100644 index 000000000000..24e30e954765 --- /dev/null +++ b/dockers/docker-device-health/LoMSupervisord.conf.j2 @@ -0,0 +1,68 @@ +[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 device_health +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=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:LoMEngine] +command=/usr/bin/LoMEngine +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=start:exited + +[group:LoMPluginMgr] +programs={% for key in procs %}{{ key }}{% if not loop.last %},{% endif %}{% endfor %} + +{% for proc in procs %} +[program:LoMPluginMgr-{{ proc }}] +command=/usr/bin/LoMPluginMgr {{ proc }} +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=start:exited +{% endfor %} + + diff --git a/dockers/docker-device-health/critical_processes b/dockers/docker-device-health/critical_processes new file mode 100644 index 000000000000..cce0bb4f4a07 --- /dev/null +++ b/dockers/docker-device-health/critical_processes @@ -0,0 +1,2 @@ +program:LoMEngine +group:LoMPluginMgr diff --git a/dockers/docker-device-health/docker_init.sh b/dockers/docker-device-health/docker_init.sh new file mode 100755 index 000000000000..55f397e2bef8 --- /dev/null +++ b/dockers/docker-device-health/docker_init.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Generate supervisord config file +mkdir -p /etc/supervisor/conf.d/ + +# Generate supervisord configuration template. +TEMPLATE_FILE="/usr/share/sonic/templates/LoMSupervisord.conf.j2" +PROCS_JSON_FILE="/usr/share/lom/procs.conf.json" +SUPERVISORD_FILE="/etc/supervisor/conf.d/LoMSupervisord.conf" + +j2 -f json -o ${SUPERVISORD_FILE} ${TEMPLATE_FILE} ${PROCS_JSON_FILE} + +# 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 diff --git a/dockers/docker-device-health/start.sh b/dockers/docker-device-health/start.sh new file mode 100755 index 000000000000..afe38aeb6fef --- /dev/null +++ b/dockers/docker-device-health/start.sh @@ -0,0 +1,12 @@ +#!/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 device_health -o ${RUNTIME_OWNER} -v ${IMAGE_VERSION} +fi + From bb1d0de160251941a055793e99131d0307eaf99f Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Wed, 7 Jun 2023 00:25:46 +0000 Subject: [PATCH 03/20] more integration --- Makefile.work | 2 ++ build_debian.sh | 8 +++++++ rules/config | 3 +++ rules/device-health.dep | 13 ++++++++++++ rules/device-health.mk | 20 +++++++++++++++++ rules/docker-device-health.dep | 11 ++++++++++ rules/docker-device-health.mk | 39 ++++++++++++++++++++++++++++++++++ src/sonic-device-health | 2 +- 8 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 rules/device-health.dep create mode 100644 rules/device-health.mk create mode 100644 rules/docker-device-health.dep create mode 100644 rules/docker-device-health.mk diff --git a/Makefile.work b/Makefile.work index 7c561e545011..e6deee0cd715 100644 --- a/Makefile.work +++ b/Makefile.work @@ -9,6 +9,7 @@ # through http. # * ENABLE_ZTP: Enables zero touch provisioning. # * SHUTDOWN_BGP_ON_START: Sets admin-down state for all bgp peerings after restart. +# * INCLUDE_DEVICE_HEALTH: Allows including device-health feature # * INCLUDE_KUBERNETES: Allows including Kubernetes # * INCLUDE_KUBERNETES_MASTER: Allows including Kubernetes master # * INCLUDE_MUX: Include MUX feature/services for TOR switch. @@ -508,6 +509,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \ ENABLE_ZTP=$(ENABLE_ZTP) \ INCLUDE_PDE=$(INCLUDE_PDE) \ SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ + INCLUDE_DEVICE_HEALTH=$(INCLUDE_DEVICE_HEALTH) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ KUBERNETES_CNI_VERSION=$(KUBERNETES_CNI_VERSION) \ diff --git a/build_debian.sh b/build_debian.sh index 9462e4a54fba..61ac9a0d8f28 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -289,6 +289,14 @@ else echo '[INFO] Skipping Install kubernetes' fi +if [ "$INCLUDE_DEVICE_HEALTH" == "y" ] +then + sudo mkdir -p $FILESYSTEM_ROOT/usr/share/device_health/ +else + echo '[INFO] Skipping Install of device-health' +fi + + if [ "$INCLUDE_KUBERNETES_MASTER" == "y" ] then ## Install Kubernetes master diff --git a/rules/config b/rules/config index 8f3354eb2d2a..58b2de077921 100644 --- a/rules/config +++ b/rules/config @@ -176,6 +176,9 @@ INCLUDE_TEAMD ?= y # INCLUDE_ROUTER_ADVERTISER - build docker-router-advertiser for router advertisements support INCLUDE_ROUTER_ADVERTISER ?= y +# INCLUDE_DEVICE_HEALTH - if set to y installs Device health +INCLUDE_DEVICE_HEALTH ?= y + # INCLUDE_KUBERNETES - if set to y kubernetes packages are installed to be able to # run as worker node in kubernetes cluster. INCLUDE_KUBERNETES ?= n diff --git a/rules/device-health.dep b/rules/device-health.dep new file mode 100644 index 000000000000..8c5f6144d075 --- /dev/null +++ b/rules/device-health.dep @@ -0,0 +1,13 @@ +#DPKG FRK +SPATH := $($(SONIC_DEVICE_HEALTH)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/device-health.mk rules/device-health.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + + +$(SONIC_DEVICE_HEALTH)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_DEVICE_HEALTH)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_DEVICE_HEALTH)_DEP_FILES := $(DEP_FILES) +$(SONIC_DEVICE_HEALTH)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_DEVICE_HEALTH)_SMDEP_PATHS := $(SPATH) + diff --git a/rules/device-health.mk b/rules/device-health.mk new file mode 100644 index 000000000000..eeaf053f02f6 --- /dev/null +++ b/rules/device-health.mk @@ -0,0 +1,20 @@ +# SONiC device-health package + +SONIC_DEVICE_HEALTH_VERSION = 1.0.0-0 +SONIC_DEVICE_HEALTH_PKG_NAME = device_health + +SONIC_DEVICE_HEALTH = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb +$(SONIC_DEVICE_HEALTH)_SRC_PATH = $(SRC_PATH)/sonic-device-health +$(SONIC_DEVICE_HEALTH)_DEPENDS = $(LIBSWSSCOMMON_DEV) $(LIBSWSSCOMMON) +$(SONIC_DEVICE_HEALTH)_RDEPENDS = $(LIBSWSSCOMMON) $(LIBSWSSCOMMON_DEV) + +SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) + +SONIC_DPKG_DEBS += $(SONIC_DEVICE_HEALTH) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += sonic-device-health + diff --git a/rules/docker-device-health.dep b/rules/docker-device-health.dep new file mode 100644 index 000000000000..0880f3410e1c --- /dev/null +++ b/rules/docker-device-health.dep @@ -0,0 +1,11 @@ + +DPATH := $($(DOCKER_DEVICE_HEALTH)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-device-health.mk rules/docker-device-health.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_DEVICE_HEALTH)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_DEVICE_HEALTH)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_DEVICE_HEALTH)_DEP_FILES := $(DEP_FILES) + +$(eval $(call add_dbg_docker,$(DOCKER_DEVICE_HEALTH),$(DOCKER_DEVICE_HEALTH_DBG))) diff --git a/rules/docker-device-health.mk b/rules/docker-device-health.mk new file mode 100644 index 000000000000..4ebbfd0ac73d --- /dev/null +++ b/rules/docker-device-health.mk @@ -0,0 +1,39 @@ +# docker image for device-health agent + +DOCKER_DEVICE_HEALTH_STEM = docker-sonic-device-health +DOCKER_DEVICE_HEALTH = $(DOCKER_DEVICE_HEALTH_STEM).gz +DOCKER_DEVICE_HEALTH_DBG = $(DOCKER_DEVICE_HEALTH_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_DEVICE_HEALTH)_PATH = $(DOCKERS_PATH)/$(DOCKER_DEVICE_HEALTH_STEM) + +$(DOCKER_DEVICE_HEALTH)_DEPENDS += $(SONIC_MGMT_COMMON) +$(DOCKER_DEVICE_HEALTH)_DEPENDS += $(SONIC_DEVICE_HEALTH) +$(DOCKER_DEVICE_HEALTH)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS) + +$(DOCKER_DEVICE_HEALTH)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) + +$(DOCKER_DEVICE_HEALTH)_VERSION = 1.0.0 +$(DOCKER_DEVICE_HEALTH)_PACKAGE_NAME = device-health + +$(DOCKER_DEVICE_HEALTH)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) + +SONIC_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) +ifeq ($(INCLUDE_SYSTEM_DEVICE_HEALTH), y) +SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) +endif + +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) +ifeq ($(INCLUDE_SYSTEM_DEVICE_HEALTH), y) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) +endif + +$(DOCKER_DEVICE_HEALTH)_CONTAINER_NAME = device-health +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += --privileged -t +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /usr/share/sonic/scripts:/usr/share/sonic/scripts:ro +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /usr/share/device_health:/usr/share/device_health:rw +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw + +SONIC_BULLSEYE_DOCKERS += $(DOCKER_DEVICE_HEALTH) +SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_DEVICE_HEALTH_DBG) +$(DOCKER_DEVICE_HEALTH)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) diff --git a/src/sonic-device-health b/src/sonic-device-health index c24e2c24e8a9..faa1f4265d5e 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit c24e2c24e8a927c00517e0a6511e2019bb9e893e +Subproject commit faa1f4265d5e998d0ecbb7248d26816b5c93a401 From e0cb84ba2bafc1861b8c2ea0877b715ce4d73033 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Wed, 7 Jun 2023 03:42:20 +0000 Subject: [PATCH 04/20] more integrate --- files/build_templates/device_health.service.j2 | 17 +++++++++++++++++ files/build_templates/init_cfg.json.j2 | 1 + files/build_templates/rsyslog_plugin.conf.j2 | 3 +++ slave.mk | 6 ++++++ 4 files changed, 27 insertions(+) create mode 100644 files/build_templates/device_health.service.j2 diff --git a/files/build_templates/device_health.service.j2 b/files/build_templates/device_health.service.j2 new file mode 100644 index 000000000000..4ff6ca34b392 --- /dev/null +++ b/files/build_templates/device_health.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=Device-health container +Requires=eventd.service +After=eventd.service +BindsTo=sonic.target +After=sonic.target +StartLimitIntervalSec=1200 +StartLimitBurst=3 + +[Service] +ExecStartPre=/usr/bin/{{docker_container_name}}.sh start +ExecStart=/usr/bin/{{docker_container_name}}.sh wait +ExecStop=/usr/bin/{{docker_container_name}}.sh stop +RestartSec=30 + +[Install] +WantedBy=sonic.target diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index d7a898dd4497..e3333701e98c 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -54,6 +54,7 @@ {%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "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_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %} +{%- if include_device_health == "y" %}{% do features.append(("device-health", "enabled", true, "enabled")) %}{% endif %} "FEATURE": { {# delayed field if set, will start the feature systemd .timer unit instead of .service unit #} {%- for feature, state, delayed, autorestart in features %} diff --git a/files/build_templates/rsyslog_plugin.conf.j2 b/files/build_templates/rsyslog_plugin.conf.j2 index fdf661fc2d65..aae77fb478a5 100644 --- a/files/build_templates/rsyslog_plugin.conf.j2 +++ b/files/build_templates/rsyslog_plugin.conf.j2 @@ -17,3 +17,6 @@ if re_match($programname, "{{ proc.name }}") then { template="prog_msg") } {% endfor %} + + +$IncludeConfig /usr/share/device_health/*.conf diff --git a/slave.mk b/slave.mk index a592bc5b43a8..913d5e71ecbd 100644 --- a/slave.mk +++ b/slave.mk @@ -157,6 +157,10 @@ ifeq ($(SONIC_INCLUDE_SYSTEM_TELEMETRY),y) INCLUDE_SYSTEM_TELEMETRY = y endif +ifeq ($(INCLUDE_DEVICE_HEALTH),y) +INCLUDE_DEVICE_HEALTH = y +endif + ifeq ($(SONIC_INCLUDE_RESTAPI),y) INCLUDE_RESTAPI = y endif @@ -413,6 +417,7 @@ $(info "VS_PREPARE_MEM" : "$(VS_PREPARE_MEM)") $(info "INCLUDE_MGMT_FRAMEWORK" : "$(INCLUDE_MGMT_FRAMEWORK)") $(info "INCLUDE_ICCPD" : "$(INCLUDE_ICCPD)") $(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)") +$(info "INCLUDE_DEVICE_HEALTH" : "$(INCLUDE_DEVICE_HEALTH)") $(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)") $(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)") $(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)") @@ -1287,6 +1292,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export sonic_su_mode="$(SECURE_UPGRADE_MODE)" export sonic_su_prod_signing_tool="/sonic/scripts/$(shell basename -- $(SECURE_UPGRADE_PROD_SIGNING_TOOL))" export include_system_telemetry="$(INCLUDE_SYSTEM_TELEMETRY)" + export include_device_health="$(INCLUDE_DEVICE_HEALTH)" export include_restapi="$(INCLUDE_RESTAPI)" export include_nat="$(INCLUDE_NAT)" export include_p4rt="$(INCLUDE_P4RT)" From 445add902db1eba364e0e76f7f66965ae3ced8f0 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 9 Jun 2023 22:48:32 +0000 Subject: [PATCH 05/20] adapting to v1.15.5 of golang --- .../Dockerfile.j2 | 0 .../LoMSupervisord.conf.j2 | 0 .../critical_processes | 0 .../docker_init.sh | 0 .../start.sh | 0 rules/device-health.dep | 4 +--- rules/docker-device-health.mk | 2 +- src/sonic-device-health | 2 +- 8 files changed, 3 insertions(+), 5 deletions(-) rename dockers/{docker-device-health => docker-sonic-device-health}/Dockerfile.j2 (100%) rename dockers/{docker-device-health => docker-sonic-device-health}/LoMSupervisord.conf.j2 (100%) rename dockers/{docker-device-health => docker-sonic-device-health}/critical_processes (100%) rename dockers/{docker-device-health => docker-sonic-device-health}/docker_init.sh (100%) rename dockers/{docker-device-health => docker-sonic-device-health}/start.sh (100%) diff --git a/dockers/docker-device-health/Dockerfile.j2 b/dockers/docker-sonic-device-health/Dockerfile.j2 similarity index 100% rename from dockers/docker-device-health/Dockerfile.j2 rename to dockers/docker-sonic-device-health/Dockerfile.j2 diff --git a/dockers/docker-device-health/LoMSupervisord.conf.j2 b/dockers/docker-sonic-device-health/LoMSupervisord.conf.j2 similarity index 100% rename from dockers/docker-device-health/LoMSupervisord.conf.j2 rename to dockers/docker-sonic-device-health/LoMSupervisord.conf.j2 diff --git a/dockers/docker-device-health/critical_processes b/dockers/docker-sonic-device-health/critical_processes similarity index 100% rename from dockers/docker-device-health/critical_processes rename to dockers/docker-sonic-device-health/critical_processes diff --git a/dockers/docker-device-health/docker_init.sh b/dockers/docker-sonic-device-health/docker_init.sh similarity index 100% rename from dockers/docker-device-health/docker_init.sh rename to dockers/docker-sonic-device-health/docker_init.sh diff --git a/dockers/docker-device-health/start.sh b/dockers/docker-sonic-device-health/start.sh similarity index 100% rename from dockers/docker-device-health/start.sh rename to dockers/docker-sonic-device-health/start.sh diff --git a/rules/device-health.dep b/rules/device-health.dep index 8c5f6144d075..dc3bf0036d85 100644 --- a/rules/device-health.dep +++ b/rules/device-health.dep @@ -2,12 +2,10 @@ SPATH := $($(SONIC_DEVICE_HEALTH)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/device-health.mk rules/device-health.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) +DEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) $(SONIC_DEVICE_HEALTH)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_DEVICE_HEALTH)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_DEVICE_HEALTH)_DEP_FILES := $(DEP_FILES) -$(SONIC_DEVICE_HEALTH)_SMDEP_FILES := $(SMDEP_FILES) -$(SONIC_DEVICE_HEALTH)_SMDEP_PATHS := $(SPATH) diff --git a/rules/docker-device-health.mk b/rules/docker-device-health.mk index 4ebbfd0ac73d..67cc6931c0fc 100644 --- a/rules/docker-device-health.mk +++ b/rules/docker-device-health.mk @@ -1,6 +1,6 @@ # docker image for device-health agent -DOCKER_DEVICE_HEALTH_STEM = docker-sonic-device-health +DOCKER_DEVICE_HEALTH_STEM = docker-device-health DOCKER_DEVICE_HEALTH = $(DOCKER_DEVICE_HEALTH_STEM).gz DOCKER_DEVICE_HEALTH_DBG = $(DOCKER_DEVICE_HEALTH_STEM)-$(DBG_IMAGE_MARK).gz diff --git a/src/sonic-device-health b/src/sonic-device-health index faa1f4265d5e..751a749f5218 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit faa1f4265d5e998d0ecbb7248d26816b5c93a401 +Subproject commit 751a749f5218b4e349698c336a248b610fc967da From 63a904d21d6ce4aa543dea3dd3306f7b572a0e25 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Sun, 11 Jun 2023 17:50:53 +0000 Subject: [PATCH 06/20] some --- rules/device-health.mk | 1 - rules/docker-device-health.mk | 20 ++++++++++++-------- slave.mk | 1 + src/sonic-device-health | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/rules/device-health.mk b/rules/device-health.mk index eeaf053f02f6..94d49470b3df 100644 --- a/rules/device-health.mk +++ b/rules/device-health.mk @@ -6,7 +6,6 @@ SONIC_DEVICE_HEALTH_PKG_NAME = device_health SONIC_DEVICE_HEALTH = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb $(SONIC_DEVICE_HEALTH)_SRC_PATH = $(SRC_PATH)/sonic-device-health $(SONIC_DEVICE_HEALTH)_DEPENDS = $(LIBSWSSCOMMON_DEV) $(LIBSWSSCOMMON) -$(SONIC_DEVICE_HEALTH)_RDEPENDS = $(LIBSWSSCOMMON) $(LIBSWSSCOMMON_DEV) SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) diff --git a/rules/docker-device-health.mk b/rules/docker-device-health.mk index 67cc6931c0fc..6ba676a870f2 100644 --- a/rules/docker-device-health.mk +++ b/rules/docker-device-health.mk @@ -4,26 +4,30 @@ DOCKER_DEVICE_HEALTH_STEM = docker-device-health DOCKER_DEVICE_HEALTH = $(DOCKER_DEVICE_HEALTH_STEM).gz DOCKER_DEVICE_HEALTH_DBG = $(DOCKER_DEVICE_HEALTH_STEM)-$(DBG_IMAGE_MARK).gz -$(DOCKER_DEVICE_HEALTH)_PATH = $(DOCKERS_PATH)/$(DOCKER_DEVICE_HEALTH_STEM) - -$(DOCKER_DEVICE_HEALTH)_DEPENDS += $(SONIC_MGMT_COMMON) $(DOCKER_DEVICE_HEALTH)_DEPENDS += $(SONIC_DEVICE_HEALTH) + $(DOCKER_DEVICE_HEALTH)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS) +$(DOCKER_DEVICE_HEALTH)_DBG_DEPENDS += $(SONIC_DEVICE_HEALTH_DBG) $(LIBSWSSCOMMON_DBG) + +$(DOCKER_DEVICE_HEALTH)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) $(DOCKER_DEVICE_HEALTH)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) +$(DOCKER_DEVICE_HEALTH)_PATH = $(DOCKERS_PATH)/$(DOCKER_DEVICE_HEALTH_STEM) + +$(DOCKER_DEVICE_HEALTH)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3) +$(DOCKER_DEVICE_HEALTH)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON) + $(DOCKER_DEVICE_HEALTH)_VERSION = 1.0.0 $(DOCKER_DEVICE_HEALTH)_PACKAGE_NAME = device-health -$(DOCKER_DEVICE_HEALTH)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) - SONIC_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) -ifeq ($(INCLUDE_SYSTEM_DEVICE_HEALTH), y) +ifeq ($(INCLUDE_DEVICE_HEALTH), y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) endif SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) -ifeq ($(INCLUDE_SYSTEM_DEVICE_HEALTH), y) +ifeq ($(INCLUDE_DEVICE_HEALTH), y) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) endif @@ -36,4 +40,4 @@ $(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw SONIC_BULLSEYE_DOCKERS += $(DOCKER_DEVICE_HEALTH) SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_DEVICE_HEALTH_DBG) -$(DOCKER_DEVICE_HEALTH)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) +$(DOCKER_DEVICE_HEALTH)_FILES = $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) diff --git a/slave.mk b/slave.mk index 913d5e71ecbd..2d73c2c25948 100644 --- a/slave.mk +++ b/slave.mk @@ -1357,6 +1357,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ $(eval $(docker:-dbg.gz=.gz)_RUN_OPT += $($(docker:-dbg.gz=.gz)_$($*_IMAGE_TYPE)_RUN_OPT)) export docker_image_run_opt="$($(docker:-dbg.gz=.gz)_RUN_OPT)" + $(info "XXX docker yyy" : "$(docker)") if [ -f files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then j2 files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service diff --git a/src/sonic-device-health b/src/sonic-device-health index 751a749f5218..2048d82a8607 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit 751a749f5218b4e349698c336a248b610fc967da +Subproject commit 2048d82a8607d0d26d572c3fa2d7069c85938127 From e8ce1f6342da17b4f26b2b6954012328123662cd Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Wed, 14 Jun 2023 23:29:16 +0000 Subject: [PATCH 07/20] Built target/debs/bullseye/sonic-device-health_1.0.0-0_amd64.deb --- rules/device-health.mk | 8 ++++---- sonic-slave-bullseye/Dockerfile.j2 | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rules/device-health.mk b/rules/device-health.mk index 94d49470b3df..e3bf9158083b 100644 --- a/rules/device-health.mk +++ b/rules/device-health.mk @@ -1,17 +1,17 @@ # SONiC device-health package SONIC_DEVICE_HEALTH_VERSION = 1.0.0-0 -SONIC_DEVICE_HEALTH_PKG_NAME = device_health +SONIC_DEVICE_HEALTH_PKG_NAME = device-health SONIC_DEVICE_HEALTH = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb $(SONIC_DEVICE_HEALTH)_SRC_PATH = $(SRC_PATH)/sonic-device-health $(SONIC_DEVICE_HEALTH)_DEPENDS = $(LIBSWSSCOMMON_DEV) $(LIBSWSSCOMMON) -SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) - SONIC_DPKG_DEBS += $(SONIC_DEVICE_HEALTH) +# SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb +# $(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) + # The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} # are archived into debug one image to facilitate debugging. # diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index 89b1240bb1b4..bff8930a94f9 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -114,6 +114,7 @@ RUN apt-get update && apt-get install -y \ libzmq5 \ libzmq3-dev \ uuid-dev \ + uuid-runtime \ jq \ cron \ # For quagga build @@ -472,6 +473,11 @@ RUN wget -O golang-go.deb 'https://sonicstorage.blob.core.windows.net/public/fip && rm golang-go.deb golang-src.deb {%- endif %} +RUN wget -O golang-go.tar.gz https://go.dev/dl/go1.20.3.linux-amd64.tar.gz +RUN mkdir -p /usr/local/go1.20.3 +RUN tar -C /usr/local/go1.20.3 -xzf golang-go.tar.gz +RUN rm -f golang-go.tar.gz + RUN pip3 install --upgrade pip RUN apt-get purge -y python3-pip python3-yaml From ac877f5aa3a7777444b28c4910d5b8b3a928a744 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 16 Jun 2023 22:02:12 +0000 Subject: [PATCH 08/20] more ... --- .../Dockerfile.j2 | 0 .../critical_processes | 0 .../docker_init.sh | 0 .../lom.supervisord.conf.j2} | 0 .../start.sh | 0 rules/device-health.mk | 3 --- scripts/dbg_files.sh | 2 +- 7 files changed, 1 insertion(+), 4 deletions(-) rename dockers/{docker-sonic-device-health => docker-device-health}/Dockerfile.j2 (100%) rename dockers/{docker-sonic-device-health => docker-device-health}/critical_processes (100%) rename dockers/{docker-sonic-device-health => docker-device-health}/docker_init.sh (100%) rename dockers/{docker-sonic-device-health/LoMSupervisord.conf.j2 => docker-device-health/lom.supervisord.conf.j2} (100%) rename dockers/{docker-sonic-device-health => docker-device-health}/start.sh (100%) diff --git a/dockers/docker-sonic-device-health/Dockerfile.j2 b/dockers/docker-device-health/Dockerfile.j2 similarity index 100% rename from dockers/docker-sonic-device-health/Dockerfile.j2 rename to dockers/docker-device-health/Dockerfile.j2 diff --git a/dockers/docker-sonic-device-health/critical_processes b/dockers/docker-device-health/critical_processes similarity index 100% rename from dockers/docker-sonic-device-health/critical_processes rename to dockers/docker-device-health/critical_processes diff --git a/dockers/docker-sonic-device-health/docker_init.sh b/dockers/docker-device-health/docker_init.sh similarity index 100% rename from dockers/docker-sonic-device-health/docker_init.sh rename to dockers/docker-device-health/docker_init.sh diff --git a/dockers/docker-sonic-device-health/LoMSupervisord.conf.j2 b/dockers/docker-device-health/lom.supervisord.conf.j2 similarity index 100% rename from dockers/docker-sonic-device-health/LoMSupervisord.conf.j2 rename to dockers/docker-device-health/lom.supervisord.conf.j2 diff --git a/dockers/docker-sonic-device-health/start.sh b/dockers/docker-device-health/start.sh similarity index 100% rename from dockers/docker-sonic-device-health/start.sh rename to dockers/docker-device-health/start.sh diff --git a/rules/device-health.mk b/rules/device-health.mk index e3bf9158083b..b918478ed65e 100644 --- a/rules/device-health.mk +++ b/rules/device-health.mk @@ -9,9 +9,6 @@ $(SONIC_DEVICE_HEALTH)_DEPENDS = $(LIBSWSSCOMMON_DEV) $(LIBSWSSCOMMON) SONIC_DPKG_DEBS += $(SONIC_DEVICE_HEALTH) -# SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb -# $(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) - # The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} # are archived into debug one image to facilitate debugging. # diff --git a/scripts/dbg_files.sh b/scripts/dbg_files.sh index 6624fca83f34..bf6426866f27 100755 --- a/scripts/dbg_files.sh +++ b/scripts/dbg_files.sh @@ -6,7 +6,7 @@ if [ "$DEBUG_IMG" == "y" ] then for i in $DEBUG_SRC_ARCHIVE_DIRS do - find src/$i/ -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -type f + find src/$i/ -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.go" -o -name "*.json" -type f done | tar -czf $DEBUG_SRC_ARCHIVE_FILE -T - fi From 62ee92d6b1bb332098f12d50e82684c7e36923fb Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 16 Jun 2023 22:05:19 +0000 Subject: [PATCH 09/20] submod update --- src/sonic-device-health | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-device-health b/src/sonic-device-health index 2048d82a8607..12b630c94797 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit 2048d82a8607d0d26d572c3fa2d7069c85938127 +Subproject commit 12b630c94797cfda8fe100507862ab6cfcc828f6 From 41dd5fceb838be81a2e019b683c06aef9bfc9add Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Sun, 18 Jun 2023 00:33:40 +0000 Subject: [PATCH 10/20] misc --- dockers/docker-device-health/docker_init.sh | 2 +- files/build_templates/init_cfg.json.j2 | 2 +- files/build_templates/sonic_debian_extension.j2 | 4 ++++ slave.mk | 1 - 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dockers/docker-device-health/docker_init.sh b/dockers/docker-device-health/docker_init.sh index 55f397e2bef8..afe585050308 100755 --- a/dockers/docker-device-health/docker_init.sh +++ b/dockers/docker-device-health/docker_init.sh @@ -4,7 +4,7 @@ mkdir -p /etc/supervisor/conf.d/ # Generate supervisord configuration template. -TEMPLATE_FILE="/usr/share/sonic/templates/LoMSupervisord.conf.j2" +TEMPLATE_FILE="/usr/share/sonic/templates/lom.supervisord.conf.j2" PROCS_JSON_FILE="/usr/share/lom/procs.conf.json" SUPERVISORD_FILE="/etc/supervisor/conf.d/LoMSupervisord.conf" diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index e3333701e98c..230db9f69050 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -76,7 +76,7 @@ "check_up_status" : "false", {%- endif %} {%- if include_kubernetes == "y" %} -{%- if feature in ["lldp", "pmon", "radv", "eventd", "snmp", "telemetry"] %} +{%- if feature in ["lldp", "pmon", "radv", "eventd", "snmp", "telemetry", "device-health"] %} "set_owner": "kube", {% else %} "set_owner": "local", {% endif %} {% endif %} "high_mem_alert": "disabled" diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 0dc60b2b605f..89600dd45651 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -952,3 +952,7 @@ sudo rm -rf $FILESYSTEM_ROOT/tmp/mask_disabled_services.py sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install python3-dbus + +{% if include_device_health == 'y' %} +sudo mkdir -p /usr/share/device_health +{%- endif %} diff --git a/slave.mk b/slave.mk index 2d73c2c25948..913d5e71ecbd 100644 --- a/slave.mk +++ b/slave.mk @@ -1357,7 +1357,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ $(eval $(docker:-dbg.gz=.gz)_RUN_OPT += $($(docker:-dbg.gz=.gz)_$($*_IMAGE_TYPE)_RUN_OPT)) export docker_image_run_opt="$($(docker:-dbg.gz=.gz)_RUN_OPT)" - $(info "XXX docker yyy" : "$(docker)") if [ -f files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 ]; then j2 files/build_templates/$($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service.j2 > $($(docker:-dbg.gz=.gz)_CONTAINER_NAME).service From 38c78f70e24ddd5b03d8725ae4008648fa88ac0b Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Tue, 20 Jun 2023 00:17:40 +0000 Subject: [PATCH 11/20] Integration is good --- dockers/docker-device-health/critical_processes | 1 - dockers/docker-device-health/lom.supervisord.conf.j2 | 5 +---- .../{device_health.service.j2 => device-health.service.j2} | 0 src/sonic-device-health | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-) rename files/build_templates/{device_health.service.j2 => device-health.service.j2} (100%) diff --git a/dockers/docker-device-health/critical_processes b/dockers/docker-device-health/critical_processes index cce0bb4f4a07..dd8bbe85eef2 100644 --- a/dockers/docker-device-health/critical_processes +++ b/dockers/docker-device-health/critical_processes @@ -1,2 +1 @@ program:LoMEngine -group:LoMPluginMgr diff --git a/dockers/docker-device-health/lom.supervisord.conf.j2 b/dockers/docker-device-health/lom.supervisord.conf.j2 index 24e30e954765..89a24918f73f 100644 --- a/dockers/docker-device-health/lom.supervisord.conf.j2 +++ b/dockers/docker-device-health/lom.supervisord.conf.j2 @@ -50,9 +50,6 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=start:exited -[group:LoMPluginMgr] -programs={% for key in procs %}{{ key }}{% if not loop.last %},{% endif %}{% endfor %} - {% for proc in procs %} [program:LoMPluginMgr-{{ proc }}] command=/usr/bin/LoMPluginMgr {{ proc }} @@ -62,7 +59,7 @@ autorestart=false stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true -dependent_startup_wait_for=start:exited +dependent_startup_wait_for=LoMEngine:running {% endfor %} diff --git a/files/build_templates/device_health.service.j2 b/files/build_templates/device-health.service.j2 similarity index 100% rename from files/build_templates/device_health.service.j2 rename to files/build_templates/device-health.service.j2 diff --git a/src/sonic-device-health b/src/sonic-device-health index 12b630c94797..4394f186df6a 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit 12b630c94797cfda8fe100507862ab6cfcc828f6 +Subproject commit 4394f186df6a2755f27ec9c634b00294d502b99e From 9334725d9831a55f02b672a4fb3d8fe1fa505029 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Thu, 22 Jun 2023 20:51:19 +0000 Subject: [PATCH 12/20] minor updates --- dockers/docker-device-health/Dockerfile.j2 | 6 ++++++ dockers/docker-device-health/lom.supervisord.conf.j2 | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dockers/docker-device-health/Dockerfile.j2 b/dockers/docker-device-health/Dockerfile.j2 index 6ffb1ce8f8c2..0d0410ef0213 100644 --- a/dockers/docker-device-health/Dockerfile.j2 +++ b/dockers/docker-device-health/Dockerfile.j2 @@ -13,6 +13,12 @@ ENV IMAGE_VERSION=$image_version # Pass the Config location to procs in container ENV LOM_CONF_LOCATION=/usr/share/lom/ +# Set the binaries to run in Prod mode +ENV LOM_RUN_MODE=PROD + +# Enable core dump +ENV GOTRACEBACK=crash + # Update apt's cache of available packages RUN apt-get update diff --git a/dockers/docker-device-health/lom.supervisord.conf.j2 b/dockers/docker-device-health/lom.supervisord.conf.j2 index 89a24918f73f..897dca942f89 100644 --- a/dockers/docker-device-health/lom.supervisord.conf.j2 +++ b/dockers/docker-device-health/lom.supervisord.conf.j2 @@ -52,7 +52,7 @@ dependent_startup_wait_for=start:exited {% for proc in procs %} [program:LoMPluginMgr-{{ proc }}] -command=/usr/bin/LoMPluginMgr {{ proc }} +command=/usr/bin/LoMPluginMgr -proc_id={{ proc }} priority=3 autostart=false autorestart=false From ae3d2c84b5826fb4c623f2cfb41751c0202a2192 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 23 Jun 2023 03:25:14 +0000 Subject: [PATCH 13/20] Updated submod to remanava fork's LoM-Prod branch --- src/sonic-device-health | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-device-health b/src/sonic-device-health index 4394f186df6a..73b5fcaea38f 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit 4394f186df6a2755f27ec9c634b00294d502b99e +Subproject commit 73b5fcaea38fbfbbed8f8e5cacf47d4597008ab4 From c18bbe2ac5e6f19caf7d0cfbf95847244e1fbf39 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Mon, 26 Jun 2023 19:25:25 +0000 Subject: [PATCH 14/20] install uuid runtime --- dockers/docker-device-health/Dockerfile.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dockers/docker-device-health/Dockerfile.j2 b/dockers/docker-device-health/Dockerfile.j2 index 0d0410ef0213..d6372fc3691b 100644 --- a/dockers/docker-device-health/Dockerfile.j2 +++ b/dockers/docker-device-health/Dockerfile.j2 @@ -22,6 +22,8 @@ ENV GOTRACEBACK=crash # Update apt's cache of available packages RUN apt-get update +RUN apt-get -y install uuid-runtime + {% if docker_device_health_debs.strip() -%} # Copy built Debian packages {{ copy_files("debs/", docker_device_health_debs.split(' '), "/debs/") }} From 5b1941f5a295966a3bca63616b03c6024306697f Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 30 Jun 2023 16:13:42 +0000 Subject: [PATCH 15/20] submod update --- src/sonic-device-health | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-device-health b/src/sonic-device-health index 73b5fcaea38f..222fd8ebd670 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit 73b5fcaea38fbfbbed8f8e5cacf47d4597008ab4 +Subproject commit 222fd8ebd6707e8cf0d9296fbcbc43590c8f0176 From 6f9c632250d3375724b5c71c47e0be2a67f1650d Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 30 Jun 2023 20:23:37 +0000 Subject: [PATCH 16/20] Added debug docker --- rules/device-health.mk | 3 +++ rules/docker-device-health.mk | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rules/device-health.mk b/rules/device-health.mk index b918478ed65e..d7ba78f61dff 100644 --- a/rules/device-health.mk +++ b/rules/device-health.mk @@ -9,6 +9,9 @@ $(SONIC_DEVICE_HEALTH)_DEPENDS = $(LIBSWSSCOMMON_DEV) $(LIBSWSSCOMMON) SONIC_DPKG_DEBS += $(SONIC_DEVICE_HEALTH) +SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) + # The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} # are archived into debug one image to facilitate debugging. # diff --git a/rules/docker-device-health.mk b/rules/docker-device-health.mk index 6ba676a870f2..ba22784731eb 100644 --- a/rules/docker-device-health.mk +++ b/rules/docker-device-health.mk @@ -28,7 +28,7 @@ endif SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) ifeq ($(INCLUDE_DEVICE_HEALTH), y) -SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) + SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) endif $(DOCKER_DEVICE_HEALTH)_CONTAINER_NAME = device-health @@ -40,4 +40,3 @@ $(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw SONIC_BULLSEYE_DOCKERS += $(DOCKER_DEVICE_HEALTH) SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_DEVICE_HEALTH_DBG) -$(DOCKER_DEVICE_HEALTH)_FILES = $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) From fcf6b6b4eee48b99008d5c0915d3a6a32c5b7e4b Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Fri, 30 Jun 2023 20:27:08 +0000 Subject: [PATCH 17/20] Added space --- rules/docker-device-health.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/docker-device-health.mk b/rules/docker-device-health.mk index ba22784731eb..f45a79e029a4 100644 --- a/rules/docker-device-health.mk +++ b/rules/docker-device-health.mk @@ -23,7 +23,7 @@ $(DOCKER_DEVICE_HEALTH)_PACKAGE_NAME = device-health SONIC_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) ifeq ($(INCLUDE_DEVICE_HEALTH), y) -SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) + SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) endif SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) From c19867d5d91647bff6f7baa925d1207583cfe86c Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Fri, 30 Jun 2023 13:28:21 -0700 Subject: [PATCH 18/20] Integrate Device Health into SONiC (#40) Integrate device-health as SONiC service as submod. --- .gitmodules | 3 + Makefile.work | 2 + build_debian.sh | 8 +++ dockers/docker-device-health/Dockerfile.j2 | 46 +++++++++++++ .../docker-device-health/critical_processes | 1 + dockers/docker-device-health/docker_init.sh | 16 +++++ .../lom.supervisord.conf.j2 | 65 +++++++++++++++++++ dockers/docker-device-health/start.sh | 12 ++++ .../build_templates/device-health.service.j2 | 17 +++++ files/build_templates/init_cfg.json.j2 | 3 +- files/build_templates/rsyslog_plugin.conf.j2 | 3 + .../build_templates/sonic_debian_extension.j2 | 4 ++ rules/config | 3 + rules/device-health.dep | 11 ++++ rules/device-health.mk | 19 ++++++ rules/docker-device-health.dep | 11 ++++ rules/docker-device-health.mk | 42 ++++++++++++ scripts/dbg_files.sh | 2 +- slave.mk | 6 ++ sonic-slave-bullseye/Dockerfile.j2 | 6 ++ src/sonic-device-health | 1 + 21 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 dockers/docker-device-health/Dockerfile.j2 create mode 100644 dockers/docker-device-health/critical_processes create mode 100755 dockers/docker-device-health/docker_init.sh create mode 100644 dockers/docker-device-health/lom.supervisord.conf.j2 create mode 100755 dockers/docker-device-health/start.sh create mode 100644 files/build_templates/device-health.service.j2 create mode 100644 rules/device-health.dep create mode 100644 rules/device-health.mk create mode 100644 rules/docker-device-health.dep create mode 100644 rules/docker-device-health.mk create mode 160000 src/sonic-device-health diff --git a/.gitmodules b/.gitmodules index 2715540c1f90..6a64b75fc1d4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -115,3 +115,6 @@ [submodule "src/dhcpmon"] path = src/dhcpmon url = https://github.com/sonic-net/sonic-dhcpmon.git +[submodule "src/sonic-device-health"] + path = src/sonic-device-health + url = https://github.com/renukamanavalan/sonic-device-health.git diff --git a/Makefile.work b/Makefile.work index 7c561e545011..e6deee0cd715 100644 --- a/Makefile.work +++ b/Makefile.work @@ -9,6 +9,7 @@ # through http. # * ENABLE_ZTP: Enables zero touch provisioning. # * SHUTDOWN_BGP_ON_START: Sets admin-down state for all bgp peerings after restart. +# * INCLUDE_DEVICE_HEALTH: Allows including device-health feature # * INCLUDE_KUBERNETES: Allows including Kubernetes # * INCLUDE_KUBERNETES_MASTER: Allows including Kubernetes master # * INCLUDE_MUX: Include MUX feature/services for TOR switch. @@ -508,6 +509,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \ ENABLE_ZTP=$(ENABLE_ZTP) \ INCLUDE_PDE=$(INCLUDE_PDE) \ SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ + INCLUDE_DEVICE_HEALTH=$(INCLUDE_DEVICE_HEALTH) \ INCLUDE_KUBERNETES=$(INCLUDE_KUBERNETES) \ KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ KUBERNETES_CNI_VERSION=$(KUBERNETES_CNI_VERSION) \ diff --git a/build_debian.sh b/build_debian.sh index 9462e4a54fba..61ac9a0d8f28 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -289,6 +289,14 @@ else echo '[INFO] Skipping Install kubernetes' fi +if [ "$INCLUDE_DEVICE_HEALTH" == "y" ] +then + sudo mkdir -p $FILESYSTEM_ROOT/usr/share/device_health/ +else + echo '[INFO] Skipping Install of device-health' +fi + + if [ "$INCLUDE_KUBERNETES_MASTER" == "y" ] then ## Install Kubernetes master diff --git a/dockers/docker-device-health/Dockerfile.j2 b/dockers/docker-device-health/Dockerfile.j2 new file mode 100644 index 000000000000..d6372fc3691b --- /dev/null +++ b/dockers/docker-device-health/Dockerfile.j2 @@ -0,0 +1,46 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} +FROM docker-config-engine-bullseye-{{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 + +# Pass the Config location to procs in container +ENV LOM_CONF_LOCATION=/usr/share/lom/ + +# Set the binaries to run in Prod mode +ENV LOM_RUN_MODE=PROD + +# Enable core dump +ENV GOTRACEBACK=crash + +# Update apt's cache of available packages +RUN apt-get update + +RUN apt-get -y install uuid-runtime + +{% if docker_device_health_debs.strip() -%} +# Copy built Debian packages +{{ copy_files("debs/", docker_device_health_debs.split(' '), "/debs/") }} + +# Install built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_device_health_debs.split(' ')) }} +{%- endif %} + +# Clean up +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 ["lom.supervisord.conf.j2", "/usr/share/sonic/templates/"] +COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] +COPY ["critical_processes", "/etc/supervisor"] + +ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-device-health/critical_processes b/dockers/docker-device-health/critical_processes new file mode 100644 index 000000000000..dd8bbe85eef2 --- /dev/null +++ b/dockers/docker-device-health/critical_processes @@ -0,0 +1 @@ +program:LoMEngine diff --git a/dockers/docker-device-health/docker_init.sh b/dockers/docker-device-health/docker_init.sh new file mode 100755 index 000000000000..afe585050308 --- /dev/null +++ b/dockers/docker-device-health/docker_init.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Generate supervisord config file +mkdir -p /etc/supervisor/conf.d/ + +# Generate supervisord configuration template. +TEMPLATE_FILE="/usr/share/sonic/templates/lom.supervisord.conf.j2" +PROCS_JSON_FILE="/usr/share/lom/procs.conf.json" +SUPERVISORD_FILE="/etc/supervisor/conf.d/LoMSupervisord.conf" + +j2 -f json -o ${SUPERVISORD_FILE} ${TEMPLATE_FILE} ${PROCS_JSON_FILE} + +# 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 diff --git a/dockers/docker-device-health/lom.supervisord.conf.j2 b/dockers/docker-device-health/lom.supervisord.conf.j2 new file mode 100644 index 000000000000..897dca942f89 --- /dev/null +++ b/dockers/docker-device-health/lom.supervisord.conf.j2 @@ -0,0 +1,65 @@ +[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 device_health +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=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:LoMEngine] +command=/usr/bin/LoMEngine +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=start:exited + +{% for proc in procs %} +[program:LoMPluginMgr-{{ proc }}] +command=/usr/bin/LoMPluginMgr -proc_id={{ proc }} +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=LoMEngine:running +{% endfor %} + + diff --git a/dockers/docker-device-health/start.sh b/dockers/docker-device-health/start.sh new file mode 100755 index 000000000000..afe38aeb6fef --- /dev/null +++ b/dockers/docker-device-health/start.sh @@ -0,0 +1,12 @@ +#!/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 device_health -o ${RUNTIME_OWNER} -v ${IMAGE_VERSION} +fi + diff --git a/files/build_templates/device-health.service.j2 b/files/build_templates/device-health.service.j2 new file mode 100644 index 000000000000..4ff6ca34b392 --- /dev/null +++ b/files/build_templates/device-health.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=Device-health container +Requires=eventd.service +After=eventd.service +BindsTo=sonic.target +After=sonic.target +StartLimitIntervalSec=1200 +StartLimitBurst=3 + +[Service] +ExecStartPre=/usr/bin/{{docker_container_name}}.sh start +ExecStart=/usr/bin/{{docker_container_name}}.sh wait +ExecStop=/usr/bin/{{docker_container_name}}.sh stop +RestartSec=30 + +[Install] +WantedBy=sonic.target diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 827eca04d695..f7331037130e 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -55,6 +55,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_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %} +{%- if include_device_health == "y" %}{% do features.append(("device-health", "enabled", true, "enabled")) %}{% endif %} "FEATURE": { {# delayed field if set, will start the feature systemd .timer unit instead of .service unit #} {%- for feature, state, delayed, autorestart in features %} @@ -76,7 +77,7 @@ "check_up_status" : "false", {%- endif %} {%- if include_kubernetes == "y" %} -{%- if feature in ["lldp", "pmon", "radv", "eventd", "snmp", "telemetry"] %} +{%- if feature in ["lldp", "pmon", "radv", "eventd", "snmp", "telemetry", "device-health"] %} "set_owner": "kube", {% else %} "set_owner": "local", {% endif %} {% endif %} "high_mem_alert": "disabled" diff --git a/files/build_templates/rsyslog_plugin.conf.j2 b/files/build_templates/rsyslog_plugin.conf.j2 index fdf661fc2d65..aae77fb478a5 100644 --- a/files/build_templates/rsyslog_plugin.conf.j2 +++ b/files/build_templates/rsyslog_plugin.conf.j2 @@ -17,3 +17,6 @@ if re_match($programname, "{{ proc.name }}") then { template="prog_msg") } {% endfor %} + + +$IncludeConfig /usr/share/device_health/*.conf diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 04a404688ff3..d216c3f74903 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -956,3 +956,7 @@ sudo rm -rf $FILESYSTEM_ROOT/tmp/mask_disabled_services.py sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install python3-dbus + +{% if include_device_health == 'y' %} +sudo mkdir -p /usr/share/device_health +{%- endif %} diff --git a/rules/config b/rules/config index 8f3354eb2d2a..58b2de077921 100644 --- a/rules/config +++ b/rules/config @@ -176,6 +176,9 @@ INCLUDE_TEAMD ?= y # INCLUDE_ROUTER_ADVERTISER - build docker-router-advertiser for router advertisements support INCLUDE_ROUTER_ADVERTISER ?= y +# INCLUDE_DEVICE_HEALTH - if set to y installs Device health +INCLUDE_DEVICE_HEALTH ?= y + # INCLUDE_KUBERNETES - if set to y kubernetes packages are installed to be able to # run as worker node in kubernetes cluster. INCLUDE_KUBERNETES ?= n diff --git a/rules/device-health.dep b/rules/device-health.dep new file mode 100644 index 000000000000..dc3bf0036d85 --- /dev/null +++ b/rules/device-health.dep @@ -0,0 +1,11 @@ +#DPKG FRK +SPATH := $($(SONIC_DEVICE_HEALTH)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/device-health.mk rules/device-health.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + + +$(SONIC_DEVICE_HEALTH)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_DEVICE_HEALTH)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_DEVICE_HEALTH)_DEP_FILES := $(DEP_FILES) + diff --git a/rules/device-health.mk b/rules/device-health.mk new file mode 100644 index 000000000000..d7ba78f61dff --- /dev/null +++ b/rules/device-health.mk @@ -0,0 +1,19 @@ +# SONiC device-health package + +SONIC_DEVICE_HEALTH_VERSION = 1.0.0-0 +SONIC_DEVICE_HEALTH_PKG_NAME = device-health + +SONIC_DEVICE_HEALTH = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb +$(SONIC_DEVICE_HEALTH)_SRC_PATH = $(SRC_PATH)/sonic-device-health +$(SONIC_DEVICE_HEALTH)_DEPENDS = $(LIBSWSSCOMMON_DEV) $(LIBSWSSCOMMON) + +SONIC_DPKG_DEBS += $(SONIC_DEVICE_HEALTH) + +SONIC_DEVICE_HEALTH_DBG = sonic-$(SONIC_DEVICE_HEALTH_PKG_NAME)-dbgsym_$(SONIC_DEVICE_HEALTH_VERSION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(SONIC_DEVICE_HEALTH),$(SONIC_DEVICE_HEALTH_DBG))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += sonic-device-health + diff --git a/rules/docker-device-health.dep b/rules/docker-device-health.dep new file mode 100644 index 000000000000..0880f3410e1c --- /dev/null +++ b/rules/docker-device-health.dep @@ -0,0 +1,11 @@ + +DPATH := $($(DOCKER_DEVICE_HEALTH)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-device-health.mk rules/docker-device-health.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_DEVICE_HEALTH)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_DEVICE_HEALTH)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_DEVICE_HEALTH)_DEP_FILES := $(DEP_FILES) + +$(eval $(call add_dbg_docker,$(DOCKER_DEVICE_HEALTH),$(DOCKER_DEVICE_HEALTH_DBG))) diff --git a/rules/docker-device-health.mk b/rules/docker-device-health.mk new file mode 100644 index 000000000000..f45a79e029a4 --- /dev/null +++ b/rules/docker-device-health.mk @@ -0,0 +1,42 @@ +# docker image for device-health agent + +DOCKER_DEVICE_HEALTH_STEM = docker-device-health +DOCKER_DEVICE_HEALTH = $(DOCKER_DEVICE_HEALTH_STEM).gz +DOCKER_DEVICE_HEALTH_DBG = $(DOCKER_DEVICE_HEALTH_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_DEVICE_HEALTH)_DEPENDS += $(SONIC_DEVICE_HEALTH) + +$(DOCKER_DEVICE_HEALTH)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS) +$(DOCKER_DEVICE_HEALTH)_DBG_DEPENDS += $(SONIC_DEVICE_HEALTH_DBG) $(LIBSWSSCOMMON_DBG) + +$(DOCKER_DEVICE_HEALTH)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) + +$(DOCKER_DEVICE_HEALTH)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) + +$(DOCKER_DEVICE_HEALTH)_PATH = $(DOCKERS_PATH)/$(DOCKER_DEVICE_HEALTH_STEM) + +$(DOCKER_DEVICE_HEALTH)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3) +$(DOCKER_DEVICE_HEALTH)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON) + +$(DOCKER_DEVICE_HEALTH)_VERSION = 1.0.0 +$(DOCKER_DEVICE_HEALTH)_PACKAGE_NAME = device-health + +SONIC_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) +ifeq ($(INCLUDE_DEVICE_HEALTH), y) + SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_DEVICE_HEALTH) +endif + +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) +ifeq ($(INCLUDE_DEVICE_HEALTH), y) + SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_DEVICE_HEALTH_DBG) +endif + +$(DOCKER_DEVICE_HEALTH)_CONTAINER_NAME = device-health +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += --privileged -t +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /usr/share/sonic/scripts:/usr/share/sonic/scripts:ro +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /usr/share/device_health:/usr/share/device_health:rw +$(DOCKER_DEVICE_HEALTH)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw + +SONIC_BULLSEYE_DOCKERS += $(DOCKER_DEVICE_HEALTH) +SONIC_BULLSEYE_DBG_DOCKERS += $(DOCKER_DEVICE_HEALTH_DBG) diff --git a/scripts/dbg_files.sh b/scripts/dbg_files.sh index 6624fca83f34..bf6426866f27 100755 --- a/scripts/dbg_files.sh +++ b/scripts/dbg_files.sh @@ -6,7 +6,7 @@ if [ "$DEBUG_IMG" == "y" ] then for i in $DEBUG_SRC_ARCHIVE_DIRS do - find src/$i/ -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -type f + find src/$i/ -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.go" -o -name "*.json" -type f done | tar -czf $DEBUG_SRC_ARCHIVE_FILE -T - fi diff --git a/slave.mk b/slave.mk index a592bc5b43a8..913d5e71ecbd 100644 --- a/slave.mk +++ b/slave.mk @@ -157,6 +157,10 @@ ifeq ($(SONIC_INCLUDE_SYSTEM_TELEMETRY),y) INCLUDE_SYSTEM_TELEMETRY = y endif +ifeq ($(INCLUDE_DEVICE_HEALTH),y) +INCLUDE_DEVICE_HEALTH = y +endif + ifeq ($(SONIC_INCLUDE_RESTAPI),y) INCLUDE_RESTAPI = y endif @@ -413,6 +417,7 @@ $(info "VS_PREPARE_MEM" : "$(VS_PREPARE_MEM)") $(info "INCLUDE_MGMT_FRAMEWORK" : "$(INCLUDE_MGMT_FRAMEWORK)") $(info "INCLUDE_ICCPD" : "$(INCLUDE_ICCPD)") $(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)") +$(info "INCLUDE_DEVICE_HEALTH" : "$(INCLUDE_DEVICE_HEALTH)") $(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)") $(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)") $(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)") @@ -1287,6 +1292,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export sonic_su_mode="$(SECURE_UPGRADE_MODE)" export sonic_su_prod_signing_tool="/sonic/scripts/$(shell basename -- $(SECURE_UPGRADE_PROD_SIGNING_TOOL))" export include_system_telemetry="$(INCLUDE_SYSTEM_TELEMETRY)" + export include_device_health="$(INCLUDE_DEVICE_HEALTH)" export include_restapi="$(INCLUDE_RESTAPI)" export include_nat="$(INCLUDE_NAT)" export include_p4rt="$(INCLUDE_P4RT)" diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index 89b1240bb1b4..bff8930a94f9 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -114,6 +114,7 @@ RUN apt-get update && apt-get install -y \ libzmq5 \ libzmq3-dev \ uuid-dev \ + uuid-runtime \ jq \ cron \ # For quagga build @@ -472,6 +473,11 @@ RUN wget -O golang-go.deb 'https://sonicstorage.blob.core.windows.net/public/fip && rm golang-go.deb golang-src.deb {%- endif %} +RUN wget -O golang-go.tar.gz https://go.dev/dl/go1.20.3.linux-amd64.tar.gz +RUN mkdir -p /usr/local/go1.20.3 +RUN tar -C /usr/local/go1.20.3 -xzf golang-go.tar.gz +RUN rm -f golang-go.tar.gz + RUN pip3 install --upgrade pip RUN apt-get purge -y python3-pip python3-yaml diff --git a/src/sonic-device-health b/src/sonic-device-health new file mode 160000 index 000000000000..222fd8ebd670 --- /dev/null +++ b/src/sonic-device-health @@ -0,0 +1 @@ +Subproject commit 222fd8ebd6707e8cf0d9296fbcbc43590c8f0176 From 109830b9b0131094c0d09f3d2ebed12e33842684 Mon Sep 17 00:00:00 2001 From: gouthambanala Date: Tue, 18 Jul 2023 19:39:47 +0000 Subject: [PATCH 19/20] devicehealth name corrected in supervisord --- dockers/docker-device-health/lom.supervisord.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-device-health/lom.supervisord.conf.j2 b/dockers/docker-device-health/lom.supervisord.conf.j2 index 897dca942f89..2a760e00bef9 100644 --- a/dockers/docker-device-health/lom.supervisord.conf.j2 +++ b/dockers/docker-device-health/lom.supervisord.conf.j2 @@ -13,7 +13,7 @@ events=PROCESS_STATE buffer_size=1024 [eventlistener:supervisor-proc-exit-listener] -command=/usr/bin/supervisor-proc-exit-listener --container-name device_health +command=/usr/bin/supervisor-proc-exit-listener --container-name device-health events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected From a206f4361e8bc39adae8c16fc51ae8b3d480903d Mon Sep 17 00:00:00 2001 From: Renuka Manavalan Date: Sun, 20 Aug 2023 20:08:46 +0000 Subject: [PATCH 20/20] submod update --- src/sonic-device-health | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-device-health b/src/sonic-device-health index 222fd8ebd670..cf9423251b96 160000 --- a/src/sonic-device-health +++ b/src/sonic-device-health @@ -1 +1 @@ -Subproject commit 222fd8ebd6707e8cf0d9296fbcbc43590c8f0176 +Subproject commit cf9423251b96520494ae21e6935909af166ca856