-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use gnmi container instead of telemetry container
- Loading branch information
Showing
27 changed files
with
315 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
############################################################################### | ||
## Monit configuration for telemetry container | ||
############################################################################### | ||
check program container_memory_gnmi with path "/usr/bin/memory_checker gnmi 419430400" | ||
if status == 3 for 10 times within 20 cycles then exec "/usr/bin/restart_service gnmi" repeat every 2 cycles |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
program:gnmi-native |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
cp /usr/share/sonic/templates/telemetry_vars.j2.${CONTAINER_NAME} /usr/share/sonic/templates/telemetry_vars.j2 | ||
cp /etc/supervisor/conf.d/supervisord.conf.${CONTAINER_NAME} /etc/supervisor/conf.d/supervisord.conf | ||
cp /etc/supervisor/critical_processes.${CONTAINER_NAME} /etc/supervisor/critical_processes | ||
|
||
exec /usr/local/bin/supervisord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env bash | ||
|
||
EXIT_TELEMETRY_VARS_FILE_NOT_FOUND=1 | ||
INCORRECT_TELEMETRY_VALUE=2 | ||
TELEMETRY_VARS_FILE=/usr/share/sonic/templates/telemetry_vars.j2 | ||
|
||
if [ ! -f "$TELEMETRY_VARS_FILE" ]; then | ||
echo "Telemetry vars template file not found" | ||
exit $EXIT_TELEMETRY_VARS_FILE_NOT_FOUND | ||
fi | ||
|
||
# Try to read telemetry and certs config from ConfigDB. | ||
# Use default value if no valid config exists | ||
TELEMETRY_VARS=$(sonic-cfggen -d -t $TELEMETRY_VARS_FILE) | ||
TELEMETRY_VARS=${TELEMETRY_VARS//[\']/\"} | ||
X509=$(echo $TELEMETRY_VARS | jq -r '.x509') | ||
GNMI=$(echo $TELEMETRY_VARS | jq -r '.gnmi') | ||
CERTS=$(echo $TELEMETRY_VARS | jq -r '.certs') | ||
|
||
TELEMETRY_ARGS=" -logtostderr" | ||
export CVL_SCHEMA_PATH=/usr/sbin/schema | ||
|
||
if [ -n "$CERTS" ]; then | ||
SERVER_CRT=$(echo $CERTS | jq -r '.server_crt') | ||
SERVER_KEY=$(echo $CERTS | jq -r '.server_key') | ||
if [ -z $SERVER_CRT ] || [ -z $SERVER_KEY ]; then | ||
TELEMETRY_ARGS+=" --insecure" | ||
else | ||
TELEMETRY_ARGS+=" --server_crt $SERVER_CRT --server_key $SERVER_KEY " | ||
fi | ||
|
||
CA_CRT=$(echo $CERTS | jq -r '.ca_crt') | ||
if [ ! -z $CA_CRT ]; then | ||
TELEMETRY_ARGS+=" --ca_crt $CA_CRT" | ||
fi | ||
elif [ -n "$X509" ]; then | ||
SERVER_CRT=$(echo $X509 | jq -r '.server_crt') | ||
SERVER_KEY=$(echo $X509 | jq -r '.server_key') | ||
if [ -z $SERVER_CRT ] || [ -z $SERVER_KEY ]; then | ||
TELEMETRY_ARGS+=" --insecure" | ||
else | ||
TELEMETRY_ARGS+=" --server_crt $SERVER_CRT --server_key $SERVER_KEY " | ||
fi | ||
|
||
CA_CRT=$(echo $X509 | jq -r '.ca_crt') | ||
if [ ! -z $CA_CRT ]; then | ||
TELEMETRY_ARGS+=" --ca_crt $CA_CRT" | ||
fi | ||
else | ||
TELEMETRY_ARGS+=" --noTLS" | ||
fi | ||
|
||
# If no configuration entry exists for TELEMETRY, create one default port | ||
if [ -z "$GNMI" ]; then | ||
PORT=8080 | ||
else | ||
PORT=$(echo $GNMI | jq -r '.port') | ||
fi | ||
TELEMETRY_ARGS+=" --port $PORT" | ||
|
||
CLIENT_AUTH=$(echo $GNMI | jq -r '.client_auth') | ||
if [ -z $CLIENT_AUTH ] || [ $CLIENT_AUTH == "false" ]; then | ||
TELEMETRY_ARGS+=" --allow_no_client_auth" | ||
fi | ||
|
||
LOG_LEVEL=$(echo $GNMI | jq -r '.log_level') | ||
if [[ $LOG_LEVEL =~ ^[0-9]+$ ]]; then | ||
TELEMETRY_ARGS+=" -v=$LOG_LEVEL" | ||
else | ||
TELEMETRY_ARGS+=" -v=2" | ||
fi | ||
|
||
# Enable ZMQ for SmartSwitch | ||
LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget localhost "subtype"` | ||
if [[ x"${LOCALHOST_SUBTYPE}" == x"SmartSwitch" ]]; then | ||
TELEMETRY_ARGS+=" -zmq_address=tcp://127.0.0.1:8100" | ||
fi | ||
|
||
# Server will handle threshold connections consecutively | ||
THRESHOLD_CONNECTIONS=$(echo $GNMI | jq -r '.threshold') | ||
if [[ $THRESHOLD_CONNECTIONS =~ ^[0-9]+$ ]]; then | ||
TELEMETRY_ARGS+=" --threshold $THRESHOLD_CONNECTIONS" | ||
else | ||
if [ -z $GNMI ] || [[ $THRESHOLD_CONNECTIONS == "null" ]]; then | ||
TELEMETRY_ARGS+=" --threshold 100" | ||
else | ||
echo "Incorrect threshold value, expecting positive integers" >&2 | ||
exit $INCORRECT_TELEMETRY_VALUE | ||
fi | ||
fi | ||
|
||
# Close idle connections after certain duration (in seconds) | ||
IDLE_CONN_DURATION=$(echo $GNMI | jq -r '.idle_conn_duration') | ||
if [[ $IDLE_CONN_DURATION =~ ^[0-9]+$ ]]; then | ||
TELEMETRY_ARGS+=" --idle_conn_duration $IDLE_CONN_DURATION" | ||
else | ||
if [ -z $GNMI ] || [[ $IDLE_CONN_DURATION == "null" ]]; then | ||
TELEMETRY_ARGS+=" --idle_conn_duration 5" | ||
else | ||
echo "Incorrect idle_conn_duration value, expecting positive integers" >&2 | ||
exit $INCORRECT_TELEMETRY_VALUE | ||
fi | ||
fi | ||
|
||
exec /usr/sbin/telemetry ${TELEMETRY_ARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[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 gnmi | ||
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING | ||
autostart=true | ||
autorestart=false | ||
buffer_size=1024 | ||
|
||
[program:rsyslogd] | ||
command=/usr/sbin/rsyslogd -n -iNONE | ||
priority=1 | ||
autostart=false | ||
autorestart=true | ||
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:gnmi-native] | ||
command=/usr/bin/gnmi-native.sh | ||
priority=3 | ||
autostart=false | ||
autorestart=false | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
dependent_startup=true | ||
dependent_startup_wait_for=start:exited | ||
|
||
[program:dialout] | ||
command=/usr/bin/dialout.sh | ||
priority=4 | ||
autostart=false | ||
autorestart=false | ||
stdout_logfile=syslog | ||
stderr_logfile=syslog | ||
dependent_startup=true | ||
dependent_startup_wait_for=gnmi-native:running |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"certs": {% if "certs" in GNMI.keys() %}{{ GNMI["certs"] }}{% else %}""{% endif %}, | ||
"gnmi" : {% if "gnmi" in GNMI.keys() %}{{ GNMI["gnmi"] }}{% else %}""{% endif %}, | ||
"x509" : {% if "x509" in DEVICE_METADATA.keys() %}{{ DEVICE_METADATA["x509"] }}{% else %}""{% endif %} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=GNMI container | ||
Requires=database.service | ||
After=database.service swss.service syncd.service | ||
Before=ntp-config.service | ||
BindsTo=sonic.target | ||
After=sonic.target | ||
StartLimitIntervalSec=1200 | ||
StartLimitBurst=3 | ||
|
||
[Service] | ||
User={{ sonicadmin_user }} | ||
ExecStartPre=/usr/local/bin/gnmi.sh start | ||
ExecStart=/usr/local/bin/gnmi.sh wait | ||
ExecStop=/usr/local/bin/gnmi.sh stop | ||
RestartSec=30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
DPATH := $($(DOCKER_GNMI)_PATH) | ||
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-gnmi.mk rules/docker-gnmi.dep | ||
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
DEP_FILES += $(shell git ls-files $(DPATH)) | ||
|
||
$(DOCKER_GNMI)_CACHE_MODE := GIT_CONTENT_SHA | ||
$(DOCKER_GNMI)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
$(DOCKER_GNMI)_DEP_FILES := $(DEP_FILES) | ||
|
||
$(eval $(call add_dbg_docker,$(DOCKER_GNMI),$(DOCKER_GNMI_DBG))) |
Oops, something went wrong.