From f9fc0768b543956e9adf44302d9316dafeb19370 Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Mon, 21 Oct 2019 08:21:30 +0000 Subject: [PATCH 1/4] [services] make snmp.timer work again and delay telemetry.service Signed-off-by: Stepan Blyschak --- files/build_templates/snmp.service.j2 | 2 -- files/build_templates/sonic_debian_extension.j2 | 6 ++++-- files/build_templates/telemetry.service.j2 | 2 -- files/build_templates/telemetry.timer | 9 +++++++++ 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 files/build_templates/telemetry.timer diff --git a/files/build_templates/snmp.service.j2 b/files/build_templates/snmp.service.j2 index 43f46bd2b9c0..dd82d1ec472e 100644 --- a/files/build_templates/snmp.service.j2 +++ b/files/build_templates/snmp.service.j2 @@ -10,5 +10,3 @@ ExecStartPre=/usr/bin/{{docker_container_name}}.sh start ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop -[Install] -WantedBy=multi-user.target swss.service diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index d08aa7b6f1cc..9e8d4eb16a3e 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -317,7 +317,7 @@ EOF ## Bind docker path if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then sudo mkdir -p $FILESYSTEM_ROOT/dockerfs - sudo mount --bind dockerfs $FILESYSTEM_ROOT/dockerfs + sudo mount --bind dockerfs $FILESYSTEM_ROOT/dockerfs fi {% if installer_images.strip() -%} @@ -334,7 +334,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT docker $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS ta {% endif %} {% endfor %} if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then - sudo umount $FILESYSTEM_ROOT/dockerfs + sudo umount $FILESYSTEM_ROOT/dockerfs sudo rm -fr $FILESYSTEM_ROOT/dockerfs sudo kill -9 `sudo $SONIC_NATIVE_DOCKERD_FOR_DOCKERFS_PID` || true else @@ -362,6 +362,8 @@ sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh # It implements delayed start of services sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer +sudo cp $BUILD_TEMPLATES/telemetry.timer $FILESYSTEM_ROOT/etc/systemd/system/ +sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable telemetry.timer sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y diff --git a/files/build_templates/telemetry.service.j2 b/files/build_templates/telemetry.service.j2 index 8781ce7afb47..a1ff8cc0ca2c 100644 --- a/files/build_templates/telemetry.service.j2 +++ b/files/build_templates/telemetry.service.j2 @@ -10,5 +10,3 @@ ExecStartPre=/usr/bin/{{docker_container_name}}.sh start ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop -[Install] -WantedBy=multi-user.target diff --git a/files/build_templates/telemetry.timer b/files/build_templates/telemetry.timer new file mode 100644 index 000000000000..e08f1c09eac6 --- /dev/null +++ b/files/build_templates/telemetry.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Delays telemetry container until SONiC has started + +[Timer] +OnBootSec=3min 30 sec +Unit=telemetry.service + +[Install] +WantedBy=timers.target From 8f8f1c9b4179b211014fc638eb73f4624574938c Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Tue, 12 Nov 2019 08:59:47 +0000 Subject: [PATCH 2/4] [services][snmp] snmp service should stop/start/restart with swss.service but start with delay on boot Signed-off-by: Stepan Blyschak --- files/build_templates/snmp.service.j2 | 4 ++-- files/build_templates/snmp.timer | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/files/build_templates/snmp.service.j2 b/files/build_templates/snmp.service.j2 index 9d419b8e0dfd..b1efcfdb85a8 100644 --- a/files/build_templates/snmp.service.j2 +++ b/files/build_templates/snmp.service.j2 @@ -4,6 +4,7 @@ Requires=updategraph.service Requisite=swss.service After=updategraph.service swss.service syncd.service Before=ntp-config.service +Conflicts=snmp.timer StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -12,5 +13,4 @@ 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 -RestartSec=30 - +RestartSec=30 \ No newline at end of file diff --git a/files/build_templates/snmp.timer b/files/build_templates/snmp.timer index 464cf01459ba..6d1838554d0e 100644 --- a/files/build_templates/snmp.timer +++ b/files/build_templates/snmp.timer @@ -1,9 +1,11 @@ [Unit] Description=Delays snmp container until SONiC has started +Conflicts=snmp.service [Timer] +OnUnitActiveSec=0 sec OnBootSec=3min 30 sec Unit=snmp.service [Install] -WantedBy=timers.target +WantedBy=timers.target swss.service From 76504c76064e4adc7aa8ba4579a1cc9a3c8c900e Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Tue, 12 Nov 2019 18:14:24 +0000 Subject: [PATCH 3/4] [sonic_debian_extentions] add telemetry timer only when telemetry is enabled Signed-off-by: Stepan Blyschak --- files/build_templates/sonic_debian_extension.j2 | 2 ++ slave.mk | 1 + 2 files changed, 3 insertions(+) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 0e79d1d9271a..bae7ace02449 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -369,8 +369,10 @@ sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh # It implements delayed start of services sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable snmp.timer +{% if enable_system_telemetry == 'y' %} sudo cp $BUILD_TEMPLATES/telemetry.timer $FILESYSTEM_ROOT/etc/systemd/system/ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable telemetry.timer +{% endif %} sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y diff --git a/slave.mk b/slave.mk index f81895f74dd2..0d0243c188c1 100644 --- a/slave.mk +++ b/slave.mk @@ -639,6 +639,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export sonic_asic_platform="$(patsubst %-$(CONFIGURED_ARCH),%,$(CONFIGURED_PLATFORM))" export enable_organization_extensions="$(ENABLE_ORGANIZATION_EXTENSIONS)" export enable_dhcp_graph_service="$(ENABLE_DHCP_GRAPH_SERVICE)" + export enable_system_telemetry="$(ENABLE_SYSTEM_TELEMETRY)" export shutdown_bgp_on_start="$(SHUTDOWN_BGP_ON_START)" export enable_pfcwd_on_start="$(ENABLE_PFCWD_ON_START)" export installer_debs="$(addprefix $(STRETCH_DEBS_PATH)/,$($*_INSTALLS))" From 0906255168d4db9ad4119e77e873935340c8685b Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Wed, 13 Nov 2019 13:59:09 +0000 Subject: [PATCH 4/4] [snmp] add newline at the end of file in service file Signed-off-by: Stepan Blyschak --- files/build_templates/snmp.service.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/build_templates/snmp.service.j2 b/files/build_templates/snmp.service.j2 index b1efcfdb85a8..4997ab737e37 100644 --- a/files/build_templates/snmp.service.j2 +++ b/files/build_templates/snmp.service.j2 @@ -13,4 +13,5 @@ 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 -RestartSec=30 \ No newline at end of file +RestartSec=30 +