From 00cea080afc67db372c4f8267735da7b0d7a2725 Mon Sep 17 00:00:00 2001 From: mprabhu-nokia <66807480+mprabhu-nokia@users.noreply.github.com> Date: Tue, 15 Dec 2020 19:28:58 -0500 Subject: [PATCH] Chassisd to monitor cards in a modular chassis (#5523) HLD: Azure/SONiC#646 Introducing chassisd process to monitor status of the control, line and fabric cards in a modular chassis. - Why I did it Modular Chassis has control-cards, line-cards and fabric-cards along with other peripherals. Chassisd will be a central entity that has visibility of the entire chassis. - How I did it Chassisd process will monitor cards in the main thread. Another configuation_handling_task is created to listen to CONFIG_DB for admin_status up/down events. The monitored status is persisted in REDIS-DB. --- .../docker-pmon.supervisord.conf.j2 | 13 +++++++++++++ dockers/docker-platform-monitor/docker_init.sh | 8 +++++++- rules/docker-platform-monitor.mk | 5 ++++- rules/sonic-chassisd.dep | 10 ++++++++++ rules/sonic-chassisd.mk | 8 ++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 rules/sonic-chassisd.dep create mode 100644 rules/sonic-chassisd.mk diff --git a/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 index 6ca914674e..929fa751b2 100644 --- a/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 +++ b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 @@ -38,6 +38,19 @@ startsecs=0 dependent_startup=true dependent_startup_wait_for=rsyslogd:running +{% if not skip_chassisd and IS_MODULAR_CHASSIS == 1 %} +[program:chassisd] +command=/usr/local/bin/chassisd +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +startsecs=0 +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running +{% endif %} + {% if not skip_sensors and HAVE_SENSORS_CONF == 1 %} [program:lm-sensors] command=/usr/bin/lm-sensors.sh diff --git a/dockers/docker-platform-monitor/docker_init.sh b/dockers/docker-platform-monitor/docker_init.sh index c06295c0c1..d073dd223c 100755 --- a/dockers/docker-platform-monitor/docker_init.sh +++ b/dockers/docker-platform-monitor/docker_init.sh @@ -5,9 +5,11 @@ mkdir -p /etc/supervisor/conf.d/ SENSORS_CONF_FILE="/usr/share/sonic/platform/sensors.conf" FANCONTROL_CONF_FILE="/usr/share/sonic/platform/fancontrol" +MODULAR_CHASSISDB_CONF_FILE="/usr/share/sonic/platform/chassisdb.conf" HAVE_SENSORS_CONF=0 HAVE_FANCONTROL_CONF=0 +IS_MODULAR_CHASSIS=0 if [ -e $SENSORS_CONF_FILE ]; then HAVE_SENSORS_CONF=1 @@ -17,7 +19,11 @@ if [ -e $FANCONTROL_CONF_FILE ]; then HAVE_FANCONTROL_CONF=1 fi -confvar="{\"HAVE_SENSORS_CONF\":$HAVE_SENSORS_CONF, \"HAVE_FANCONTROL_CONF\":$HAVE_FANCONTROL_CONF}" +if [ -e $MODULAR_CHASSISDB_CONF_FILE ]; then + IS_MODULAR_CHASSIS=1 +fi + +confvar="{\"HAVE_SENSORS_CONF\":$HAVE_SENSORS_CONF, \"HAVE_FANCONTROL_CONF\":$HAVE_FANCONTROL_CONF, \"IS_MODULAR_CHASSIS\":$IS_MODULAR_CHASSIS}" if [ -e /usr/share/sonic/platform/pmon_daemon_control.json ]; then diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 2abc68ff4c..e9e414cadd 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -6,7 +6,8 @@ DOCKER_PLATFORM_MONITOR_DBG = $(DOCKER_PLATFORM_MONITOR_STEM)-$(DBG_IMAGE_MARK). $(DOCKER_PLATFORM_MONITOR)_PATH = $(DOCKERS_PATH)/$(DOCKER_PLATFORM_MONITOR_STEM) -$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL) $(SENSORD) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) $(SMARTMONTOOLS) +$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL) $(SENSORD) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(SMARTMONTOOLS) + $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2) @@ -21,6 +22,8 @@ $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PSUD) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_SYSEEPROMD) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_THERMALCTLD) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_XCVRD) +$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_CHASSISD_PY3) + ifeq ($(PDDF_SUPPORT),y) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY2) endif diff --git a/rules/sonic-chassisd.dep b/rules/sonic-chassisd.dep new file mode 100644 index 0000000000..bf27492937 --- /dev/null +++ b/rules/sonic-chassisd.dep @@ -0,0 +1,10 @@ +SPATH := $($(SONIC_CHASSISD_PY3)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-chassisd.mk rules/sonic-chassisd.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + +$(SONIC_CHASSISD_PY3)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_CHASSISD_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_CHASSISD_PY3)_DEP_FILES := $(DEP_FILES) +$(SONIC_CHASSISD_PY3)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_CHASSISD_PY3)_SMDEP_PATHS := $(SPATH) diff --git a/rules/sonic-chassisd.mk b/rules/sonic-chassisd.mk new file mode 100644 index 0000000000..46a49d3597 --- /dev/null +++ b/rules/sonic-chassisd.mk @@ -0,0 +1,8 @@ +# sonic-chassisd (SONiC Chassis mgmt daemon) wheel package + +SONIC_CHASSISD_PY3 = sonic_chassisd-1.0-py3-none-any.whl +$(SONIC_CHASSISD_PY3)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-chassisd +$(SONIC_CHASSISD_PY3)_DEPENDS = $(SONIC_PY_COMMON_PY3) +$(SONIC_CHASSISD_PY3)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) +$(SONIC_CHASSISD_PY3)_PYTHON_VERSION = 3 +SONIC_PYTHON_WHEELS += $(SONIC_CHASSISD_PY3)