Skip to content

Commit b6800d6

Browse files
[containercfgd] Add containercfgd and syslog rate limit configuration support
1 parent fff6808 commit b6800d6

24 files changed

+518
-15
lines changed

dockers/docker-base-bullseye/Dockerfile.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ RUN pip3 install supervisor==4.2.1
8686
# Add support for supervisord to handle startup dependencies
8787
RUN pip3 install supervisord-dependent-startup==1.4.0
8888

89-
RUN mkdir -p /etc/supervisor /var/log/supervisor
89+
RUN mkdir -p /var/log/supervisor /etc/supervisor/conf.d
9090

9191
RUN apt-get -y purge \
9292
exim4 \
@@ -109,10 +109,10 @@ RUN apt-get clean -y && \
109109
apt-get autoremove -y && \
110110
rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache
111111

112-
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
113112
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
114113
COPY ["root/.vimrc", "/root/.vimrc"]
115114

116115
RUN ln /usr/bin/vim.tiny /usr/bin/vim
117116

118117
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
118+
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[program:containercfgd]
2+
command=python3 /usr/local/bin/containercfgd
3+
priority=99
4+
autostart=false
5+
autorestart=unexpected
6+
stdout_logfile=syslog
7+
stderr_logfile=syslog
8+
dependent_startup=true
9+
dependent_startup_wait_for=rsyslogd:running

dockers/docker-base-buster/Dockerfile.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ RUN pip3 install supervisor==4.2.1
100100
# Add support for supervisord to handle startup dependencies
101101
RUN pip3 install supervisord-dependent-startup==1.4.0
102102

103-
RUN mkdir -p /etc/supervisor /var/log/supervisor
103+
RUN mkdir -p /var/log/supervisor /etc/supervisor/conf.d
104104

105105
RUN apt-get -y purge \
106106
exim4 \
@@ -123,10 +123,10 @@ RUN apt-get clean -y && \
123123
apt-get autoremove -y && \
124124
rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache/
125125

126-
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
127126
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
128127
COPY ["root/.vimrc", "/root/.vimrc"]
129128

130129
RUN ln /usr/bin/vim.tiny /usr/bin/vim
131130

132131
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
132+
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[program:containercfgd]
2+
command=python3 /usr/local/bin/containercfgd
3+
priority=99
4+
autostart=false
5+
autorestart=unexpected
6+
stdout_logfile=syslog
7+
stderr_logfile=syslog
8+
dependent_startup=true
9+
dependent_startup_wait_for=rsyslogd:running

dockers/docker-base-stretch/Dockerfile.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ RUN pip install supervisor>=3.4.0
9696
# Add support for supervisord to handle startup dependencies
9797
RUN pip install supervisord-dependent-startup==1.4.0
9898

99-
RUN mkdir -p /etc/supervisor /var/log/supervisor
99+
RUN mkdir -p /var/log/supervisor /etc/supervisor/conf.d
100100

101101
RUN apt-get -y purge \
102102
exim4 \
@@ -119,10 +119,10 @@ RUN apt-get clean -y && \
119119
apt-get autoremove -y && \
120120
rm -rf /var/lib/apt/lists/* /tmp/*
121121

122-
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
123122
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
124123
COPY ["root/.vimrc", "/root/.vimrc"]
125124

126125
RUN ln /usr/bin/vim.tiny /usr/bin/vim
127126

128127
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
128+
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[program:containercfgd]
2+
command=python /usr/local/bin/containercfgd
3+
priority=99
4+
autostart=false
5+
autorestart=unexpected
6+
stdout_logfile=syslog
7+
stderr_logfile=syslog
8+
dependent_startup=true
9+
dependent_startup_wait_for=rsyslogd:running

dockers/docker-base/Dockerfile.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ RUN apt-get -y install \
4949
rsyslog \
5050
less
5151

52-
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
5352
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
5453
COPY ["root/.vimrc", "/root/.vimrc"]
5554

@@ -64,10 +63,11 @@ RUN pip install wheel
6463
# Install supervisor
6564
RUN pip install supervisor>=3.4.0
6665
67-
RUN mkdir -p /etc/supervisor
66+
RUN mkdir -p /etc/supervisor/conf.d
6867
RUN mkdir -p /var/log/supervisor
6968
7069
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
70+
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
7171
7272
RUN apt-get -y purge \
7373
exim4 \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[program:containercfgd]
2+
command=python /usr/local/bin/containercfgd
3+
priority=99
4+
autostart=false
5+
autorestart=unexpected
6+
stdout_logfile=syslog
7+
stderr_logfile=syslog
8+
dependent_startup=true
9+
dependent_startup_wait_for=rsyslogd:running

dockers/docker-database/supervisord.conf.j2

+18-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ logfile_maxbytes=1MB
33
logfile_backups=2
44
nodaemon=true
55

6+
[eventlistener:dependent-startup]
7+
command=python3 -m supervisord_dependent_startup
8+
autostart=true
9+
autorestart=unexpected
10+
startretries=0
11+
exitcodes=0,3
12+
events=PROCESS_STATE
13+
buffer_size=1024
14+
615
[eventlistener:supervisor-proc-exit-listener]
716
command=/usr/bin/supervisor-proc-exit-listener --container-name database
817
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
@@ -13,32 +22,37 @@ buffer_size=1024
1322
[program:rsyslogd]
1423
command=/usr/sbin/rsyslogd -n -iNONE
1524
priority=1
16-
autostart=true
25+
autostart=false
1726
autorestart=false
1827
stdout_logfile=syslog
1928
stderr_logfile=syslog
29+
dependent_startup=true
2030

2131
{% if INSTANCES %}
2232
{% for redis_inst, redis_items in INSTANCES.items() %}
23-
[program: {{ redis_inst }}]
33+
[program:{{ redis_inst }}]
2434
{% if redis_items['hostname'] != '127.0.0.1' and redis_inst != 'redis_chassis' %}
2535
{%- set LOOPBACK_IP = '127.0.0.1' -%}
2636
{%- else -%}
2737
{%- set LOOPBACK_IP = '' -%}
2838
{%- endif -%}
2939
command=/bin/bash -c "{ [[ -s /var/lib/{{ redis_inst }}/dump.rdb ]] || rm -f /var/lib/{{ redis_inst }}/dump.rdb; } && mkdir -p /var/lib/{{ redis_inst }} && exec /usr/bin/redis-server /etc/redis/redis.conf --bind {{ LOOPBACK_IP }} {{ redis_items['hostname'] }} --port {{ redis_items['port'] }} --unixsocket {{ redis_items['unix_socket_path'] }} --pidfile /var/run/redis/{{ redis_inst }}.pid --dir /var/lib/{{ redis_inst }}"
3040
priority=2
31-
autostart=true
41+
autostart=false
3242
autorestart=false
3343
stdout_logfile=syslog
3444
stderr_logfile=syslog
45+
dependent_startup=true
46+
dependent_startup_wait_for=rsyslogd:running
3547
{% endfor %}
3648
{% endif %}
3749

3850
[program:flushdb]
3951
command=/bin/bash -c "sleep 300 && /usr/local/bin/flush_unused_database"
4052
priority=3
41-
autostart=true
53+
autostart=false
4254
autorestart=false
4355
stdout_logfile=syslog
4456
stderr_logfile=syslog
57+
dependent_startup=true
58+
dependent_startup_wait_for=rsyslogd:running

rules/docker-config-engine-bullseye.mk

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ $(DOCKER_CONFIG_ENGINE_BULLSEYE)_DEPENDS += $(LIBSWSSCOMMON) \
1111
$(SONIC_DB_CLI) \
1212
$(SONIC_EVENTD)
1313
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) \
14-
$(SONIC_YANG_MGMT_PY3) \
15-
$(SONIC_YANG_MODELS_PY3)
14+
$(SONIC_YANG_MGMT_PY3) \
15+
$(SONIC_YANG_MODELS_PY3) \
16+
$(SONIC_CONTAINERCFGD)
1617
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3)
1718
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_LOAD_DOCKERS += $(DOCKER_BASE_BULLSEYE)
1819
$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $(SWSS_VARS_TEMPLATE)

rules/docker-config-engine-buster.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ $(DOCKER_CONFIG_ENGINE_BUSTER)_DEPENDS += $(LIBSWSSCOMMON) \
1111
$(SONIC_DB_CLI)
1212
$(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) \
1313
$(SONIC_YANG_MGMT_PY3) \
14-
$(SONIC_YANG_MODELS_PY3)
14+
$(SONIC_YANG_MODELS_PY3) \
15+
$(SONIC_CONTAINERCFGD)
1516
$(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3)
1617
$(DOCKER_CONFIG_ENGINE_BUSTER)_LOAD_DOCKERS += $(DOCKER_BASE_BUSTER)
1718
$(DOCKER_CONFIG_ENGINE_BUSTER)_FILES += $(SWSS_VARS_TEMPLATE)

rules/sonic-containercfgd.dep

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SPATH := $($(SONIC_CONTAINERCFGD)_SRC_PATH)
2+
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-containercfgd.mk rules/sonic-containercfgd.dep
3+
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
4+
DEP_FILES += $(shell git ls-files $(SPATH))
5+
6+
$(SONIC_CONTAINERCFGD)_CACHE_MODE := GIT_CONTENT_SHA
7+
$(SONIC_CONTAINERCFGD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
8+
$(SONIC_CONTAINERCFGD)_DEP_FILES := $(DEP_FILES)
9+
$(SONIC_CONTAINERCFGD)_SMDEP_FILES := $(SMDEP_FILES)
10+
$(SONIC_CONTAINERCFGD)_SMDEP_PATHS := $(SPATH)

rules/sonic-containercfgd.mk

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# sonic-bgpcfgd package
2+
3+
SONIC_CONTAINERCFGD = sonic_containercfgd-1.0-py3-none-any.whl
4+
$(SONIC_CONTAINERCFGD)_SRC_PATH = $(SRC_PATH)/sonic-containercfgd
5+
$(SONIC_CONTAINERCFGD)_DEPENDS += $(SONIC_PY_COMMON_PY3)
6+
$(SONIC_CONTAINERCFGD)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON)
7+
$(SONIC_CONTAINERCFGD)_PYTHON_VERSION = 3
8+
SONIC_PYTHON_WHEELS += $(SONIC_CONTAINERCFGD)

src/sonic-containercfgd/.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Compiled Python files
2+
*.pyc
3+
4+
# Generated by packaging
5+
*.egg-info/
6+
.eggs/
7+
build/
8+
dist/
9+
10+
# Unit test coverage
11+
.coverage
12+
coverage.xml
13+
htmlcov/

src/sonic-containercfgd/containercfgd/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)