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

Event mgmt #7813

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions dockers/docker-database/critical_processes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
program:redis
program:redis1
11 changes: 11 additions & 0 deletions dockers/docker-database/database_config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"port": 6380,
"unix_socket_path": "/var/run/redis-chassis/redis_chassis.sock",
"persistence_for_warm_boot" : "yes"
},
"redis1":{
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason for having a dedicated redis instance for event mgmt is because they are supposed to persist across reboots. If that is the intention, can we name this instance as redisp instead of redis1. Other applications can also use it.

Copy link
Author

Choose a reason for hiding this comment

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

During the HLD review, we were asked to keep event/alarm tables in separate instance so that they wont grow too big that impacts other tables.

"hostname" : "{{HOST_IP}}",
"port" : 6381,
"unix_socket_path" : "/var/run/redis{{NAMESPACE_ID}}/redis1.sock",
"persistence_for_warm_boot" : "yes"
}
},
"DATABASES" : {
Expand Down Expand Up @@ -88,6 +94,11 @@
"id" : 13,
"separator": "|",
"instance" : "redis_chassis"
},
"EVENT_DB" : {
"id" : 14,
"separator": "|",
"instance" : "redis1"
}
},
"VERSION" : "1.0"
Expand Down
27 changes: 27 additions & 0 deletions dockers/docker-eventd/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM docker-config-engine-buster

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

COPY \
{% for deb in docker_eventd_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/

RUN dpkg -i \
{% for deb in docker_eventd_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %}

COPY ["docker-init.sh", "files/supervisor-proc-exit-listener", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["critical_processes", "/etc/supervisor"]

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

ENTRYPOINT ["/usr/bin/docker-init.sh"]
1 change: 1 addition & 0 deletions dockers/docker-eventd/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
program:eventd
8 changes: 8 additions & 0 deletions dockers/docker-eventd/docker-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

sonic-db-cli EVENT_DB config set notify-keyspace-events AKE

cp /var/evprofile/default.json /etc/evprofile/default.json
Copy link
Contributor

Choose a reason for hiding this comment

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

cp /var/lib/evprofile/default.json /etc/evprofile/default.json

Copy link
Author

Choose a reason for hiding this comment

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

Previous comment.


exec /usr/local/bin/supervisord

40 changes: 40 additions & 0 deletions dockers/docker-eventd/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[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 eventd
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
startsecs=1
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:eventd]
command=/usr/bin/eventd
priority=2
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

2 changes: 1 addition & 1 deletion dockers/docker-sonic-mgmt-framework/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%s
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y g++ python3-dev libxml2 libcurl3-gnutls libcjson-dev
apt-get install -y g++ python3-dev libxml2 libcurl3-gnutls libcjson1

RUN pip3 install connexion==2.7.0 \
setuptools==21.0.0 \
Expand Down
9 changes: 7 additions & 2 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ function preStartAction()
# Load redis content from /host/warmboot/dump.rdb
docker cp $WARM_DIR/dump.rdb database$DEV:/var/lib/redis/dump.rdb
else
COLD_DIR=/host/coldboot
# Create an emtpy file and overwrite any RDB if already there
echo -n > /tmp/dump.rdb
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/
if [[ -s $COLD_DIR/dump.rdb ]]; then
docker cp $COLD_DIR/dump.rdb database$DEV:/var/lib/redis/dump.rdb
else
echo -n > /tmp/dump.rdb
docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/
fi
fi
fi
{%- elif docker_container_name == "snmp" %}
Expand Down
16 changes: 16 additions & 0 deletions files/build_templates/eventd.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Eventd container
Requires=database.service
After=database.service
Before=ntp-config.service
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for the before ntp-config service dependency?

Copy link
Author

Choose a reason for hiding this comment

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

At that time, I thought there might be a scenario ntpd may want to raise an event/alarm.

StartLimitIntervalSec=1200
StartLimitBurst=20

[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
Restart=always

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
("snmp", "enabled", true, "enabled"),
("swss", "enabled", false, "enabled"),
("syncd", "enabled", false, "enabled"),
("eventd", "enabled", false, "enabled"),
("teamd", "enabled", false, "enabled")] %}
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
Expand Down
11 changes: 11 additions & 0 deletions rules/docker-eventd.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DPATH := $($(DOCKER_EVENTD)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-eventd.mk rules/docker-eventd.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

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

$(eval $(call add_dbg_docker,$(DOCKER_EVENTD),$(DOCKER_EVENTD_DBG)))

31 changes: 31 additions & 0 deletions rules/docker-eventd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Docker image for EVENTD

DOCKER_EVENTD_STEM = docker-eventd
DOCKER_EVENTD = $(DOCKER_EVENTD_STEM).gz
DOCKER_EVENTD_DBG = $(DOCKER_EVENTD_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_EVENTD)_PATH = $(DOCKERS_PATH)/$(DOCKER_EVENTD_STEM)

$(DOCKER_EVENTD)_DEPENDS += $(EVENTD) $(LIBSWSSCOMMON) $(LIBEVENTNOTIFY)
$(DOCKER_EVENTD)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS)
$(DOCKER_EVENTD)_DBG_DEPENDS += $(EVENTD) $(LIBSWSSCOMMON) $(LIBEVENTNOTIFY)
$(DOCKER_EVENTD)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES)

SONIC_DOCKER_IMAGES += $(DOCKER_EVENTD)
#SONIC_STRETCH_DOCKERS += $(DOCKER_EVENTD)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_EVENTD)

SONIC_DOCKER_DBG_IMAGES += $(DOCKER_EVENTD_DBG)
#SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_EVENTD_DBG)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_EVENTD_DBG)

$(DOCKER_EVENTD)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BUSTER)

$(DOCKER_EVENTD)_CONTAINER_NAME = eventd
$(DOCKER_EVENTD)_RUN_OPT += --net=host --privileged -t
$(DOCKER_EVENTD)_RUN_OPT += -v /etc/sonic/:/etc/sonic/:ro
$(DOCKER_EVENTD)_RUN_OPT += -v /etc/evprofile:/etc/evprofile:rw
$(DOCKER_EVENTD)_RUN_OPT += -v /host/warmboot:/var/warmboot

$(DOCKER_EVENTD)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

1 change: 1 addition & 0 deletions rules/docker-sonic-mgmt-framework.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endif
$(DOCKER_MGMT_FRAMEWORK)_CONTAINER_NAME = mgmt-framework
$(DOCKER_MGMT_FRAMEWORK)_RUN_OPT += --privileged -t
$(DOCKER_MGMT_FRAMEWORK)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_MGMT_FRAMEWORK)_RUN_OPT += -v /etc/evprofile:/etc/evprofile:ro
$(DOCKER_MGMT_FRAMEWORK)_RUN_OPT += -v /etc:/host_etc:ro
$(DOCKER_MGMT_FRAMEWORK)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw
$(DOCKER_MGMT_FRAMEWORK)_RUN_OPT += --mount type=bind,source="/var/platform/",target="/mnt/platform/"
Expand Down
11 changes: 11 additions & 0 deletions rules/eventd.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SPATH := $($(EVENTD)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/eventd.mk rules/eventd.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files))

$(EVENTD)_CACHE_MODE := GIT_CONTENT_SHA
$(EVENTD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(EVENTD)_DEP_FILES := $(DEP_FILES)
$(EVENTD)_SMDEP_FILES := $(SMDEP_FILES)
$(EVENTD)_SMDEP_PATHS := $(SPATH)

18 changes: 18 additions & 0 deletions rules/eventd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EVENTD package
#
EVENTD_VERSION = 1.0.0
export EVENTD_VERSION

EVENTD = eventd_$(EVENTD_VERSION)_amd64.deb
$(EVENTD)_SRC_PATH = $(SRC_PATH)/sonic-eventd
$(EVENTD)_DEPENDS += $(LIBSWSSCOMMON_DEV) $(LIBEVENTNOTIFY_DEV)
$(EVENTD)_RDEPENDS += $(LIBSWSSCOMMON) $(LIBEVENTNOTIFY)
SONIC_DPKG_DEBS += $(EVENTD)

EVENTD_DBG = eventd-dbg_1.0.0_amd64.deb
$(EVENTD_DBG)_DEPENDS += $(EVENTD)
$(EVENTD_DBG)_RDEPENDS += $(EVENTD)
$(eval $(call add_derived_package,$(EVENTD),$(EVENTD_DBG)))

export EVENTD

11 changes: 11 additions & 0 deletions rules/libeventnotify.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SPATH := $($(LIBEVENTNOTIFY)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/libeventnotify.mk rules/libeventnotify.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files))

$(LIBEVENTNOTIFY)_CACHE_MODE := GIT_CONTENT_SHA
$(LIBEVENTNOTIFY)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(LIBEVENTNOTIFY)_DEP_FILES := $(DEP_FILES)
$(LIBEVENTNOTIFY)_SMDEP_FILES := $(SMDEP_FILES)
$(LIBEVENTNOTIFY)_SMDEP_PATHS := $(SPATH)

13 changes: 13 additions & 0 deletions rules/libeventnotify.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SONiC event notfiy library

LIBEVENTNOTIFY_VERSION = 1.0.0
LIBEVENTNOTIFY = libeventnotify_$(LIBEVENTNOTIFY_VERSION)_amd64.deb
$(LIBEVENTNOTIFY)_DEPENDS += $(LIBSWSSCOMMON_DEV)
$(LIBEVENTNOTIFY)_RDEPENDS += $(LIBSWSSCOMMON)

$(LIBEVENTNOTIFY)_SRC_PATH = $(SRC_PATH)/sonic-eventd/lib
SONIC_DPKG_DEBS += $(LIBEVENTNOTIFY)

LIBEVENTNOTIFY_DEV = libeventnotify-dev_$(LIBEVENTNOTIFY_VERSION)_amd64.deb
$(eval $(call add_derived_package,$(LIBEVENTNOTIFY),$(LIBEVENTNOTIFY_DEV)))

4 changes: 4 additions & 0 deletions src/sonic-eventd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ACLOCAL_AMFLAGS = -I m4
#INCLUDES = -I $(top_srcdir)
SUBDIRS = src

6 changes: 6 additions & 0 deletions src/sonic-eventd/autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

libtoolize --force --copy &&
autoreconf --force --install -I m4
rm -Rf autom4te.cache

50 changes: 50 additions & 0 deletions src/sonic-eventd/configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
AC_INIT([sonic-eventd],[1.0.0])
AC_CONFIG_SRCDIR([])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([foreign])
AC_LANG_C
AC_LANG([C++])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_HEADER_STDC

AC_ARG_ENABLE(debug,
[ --enable-debug Compile with debugging flags],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)

AC_ARG_ENABLE(gtest,
[ --enable-gtest Compile with googletest flags],
[case "${enableval}" in
yes) gtest=true ;;
no) gtest=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gtest) ;;
esac],[gtest=false])
AM_CONDITIONAL(GTEST, test x$gtest = xtrue)

CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/swss -I/usr/include"

CFLAGS_COMMON+=" -Werror"

AC_SUBST(CFLAGS_COMMON)

dnl ---------------
dnl dlopen & dlinfo
dnl ---------------
AC_SEARCH_LIBS([dlopen], [dl dld], [], [
AC_MSG_ERROR([unable to find the dlopen()])
])

AC_CONFIG_FILES([
src/Makefile
Makefile
])

AC_OUTPUT

6 changes: 6 additions & 0 deletions src/sonic-eventd/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sonic (1.0.0) stable; urgency=medium

* Initial release.

-- Eventd <support@dell.com> Thu, 9 Apr 2021 12:00:00 -0800

1 change: 1 addition & 0 deletions src/sonic-eventd/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
19 changes: 19 additions & 0 deletions src/sonic-eventd/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Source: sonic
Maintainer: Dell
Section: net
Priority: optional
Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev
Standards-Version: 1.0.0

Package: eventd
Architecture: any
Depends: ${shlibs:Depends}
Description: This package contains Eventd for SONiC project.

Package: eventd-dbg
Architecture: any
Section: debug
Priority: extra
Depends: stp (=${binary:Version})
Description: debugging symbols for eventd

1 change: 1 addition & 0 deletions src/sonic-eventd/debian/eventd.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/lib
2 changes: 2 additions & 0 deletions src/sonic-eventd/debian/eventd.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/etc/eventd.json
/var/evprofile/default.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to /var/lib/evprofile/default.json

Copy link
Author

Choose a reason for hiding this comment

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

May I know the reason?
The default.json is placed under sonic-eventd/var/evprofile/default.json so, the .install is using that path.
Should we rather put default.json in sonic-eventd/var/lib/evprofile/ ?

But why?

Loading