From fdc2cc4adece0ca29762f2b26fb37875d2a13f85 Mon Sep 17 00:00:00 2001 From: Eric MacDonald Date: Mon, 14 May 2018 16:12:16 -0400 Subject: [PATCH] Collectd+InfluxDb-RMON Replacement(ALL METRICS) P1 This update introduces a non-reboot patch example script for a service whose patch modified its service file thereby requiring a system daemon-reload as a precursor to the service process restart. This new RPM was introduced in support of no-reboot patching of the 'influxdb' and 'collectd' processes ; so those are the default processes used in this script. Note that there is nothing that prevents a designer from using this as a more general example script for any service that requires the same patching operations after replacing the default process names with their own. Change-Id: I9f261509f16490f986722b47b0f92db4ef735609 Signed-off-by: Jack Ding --- centos_pkg_dirs | 1 + .../centos/EXAMPLE_SERVICE.spec | 27 ++++++++++ .../EXAMPLE_SERVICE/centos/build_srpm.data | 2 + .../scripts/service-process-restart | 54 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 patch-scripts/EXAMPLE_SERVICE/centos/EXAMPLE_SERVICE.spec create mode 100644 patch-scripts/EXAMPLE_SERVICE/centos/build_srpm.data create mode 100644 patch-scripts/EXAMPLE_SERVICE/scripts/service-process-restart diff --git a/centos_pkg_dirs b/centos_pkg_dirs index 61949d15..b1f2b615 100644 --- a/centos_pkg_dirs +++ b/centos_pkg_dirs @@ -13,3 +13,4 @@ patch-scripts/EXAMPLE_HEAT patch-scripts/EXAMPLE_VIM patch-scripts/EXAMPLE_NOVA patch-scripts/EXAMPLE_SYSINV +patch-scripts/EXAMPLE_SERVICE diff --git a/patch-scripts/EXAMPLE_SERVICE/centos/EXAMPLE_SERVICE.spec b/patch-scripts/EXAMPLE_SERVICE/centos/EXAMPLE_SERVICE.spec new file mode 100644 index 00000000..3b63b0cc --- /dev/null +++ b/patch-scripts/EXAMPLE_SERVICE/centos/EXAMPLE_SERVICE.spec @@ -0,0 +1,27 @@ +Name: EXAMPLE_SERVICE +Summary: TIS In-Service Patch Scripts Example that supports systemd reload +Version: 1.0 +Release: %{tis_patch_ver}%{?_tis_dist} +License: windriver +Group: base +Packager: Wind River +Source0: service-process-restart + +%install + install -Dp -m 700 %{S:0} %{buildroot}%{_patch_scripts}/%{name} + +%description +%{summary} + +%files +%defattr(-,root,root,-) +%{_patch_scripts}/* + +%post +cp -f %{_patch_scripts}/%{name} %{_runtime_patch_scripts}/ +exit 0 + +%preun +cp -f %{_patch_scripts}/%{name} %{_runtime_patch_scripts}/ +exit 0 + diff --git a/patch-scripts/EXAMPLE_SERVICE/centos/build_srpm.data b/patch-scripts/EXAMPLE_SERVICE/centos/build_srpm.data new file mode 100644 index 00000000..ff906984 --- /dev/null +++ b/patch-scripts/EXAMPLE_SERVICE/centos/build_srpm.data @@ -0,0 +1,2 @@ +COPY_LIST="scripts/*" +TIS_PATCH_VER=0 diff --git a/patch-scripts/EXAMPLE_SERVICE/scripts/service-process-restart b/patch-scripts/EXAMPLE_SERVICE/scripts/service-process-restart new file mode 100644 index 00000000..bd9ead65 --- /dev/null +++ b/patch-scripts/EXAMPLE_SERVICE/scripts/service-process-restart @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Copyright (c) 2018 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# +# This script provides an example in-service patching restart script +# that supports service file changes by issuing a systemctl daemon reload +# after the patch is applied + +# +# The patching subsystem provides a patch-functions bash source file +# with useful function and variable definitions. +# +. /etc/patching/patch-functions + +# +# Declare an overall script return code +# +declare -i GLOBAL_RC=$PATCH_STATUS_OK + +# issue a systemd daemon-reload once the rpms have been installed and before +# the processes have been restarted. +systemctl daemon-reload + +# processes that run on all nodes +processes_to_restart="collectd" +/usr/local/sbin/patch-restart-processes ${processes_to_restart} +if [ $? != 0 ] ; then + loginfo "patching restart failed" + loginfo "... process-restart ${processes_to_restart}" + exit ${PATCH_STATUS_FAILED} +fi + +# processes that only run on controller hosts +if is_controller +then + processes_to_restart="influxdb" + /usr/local/sbin/patch-restart-processes ${processes_to_restart} + if [ $? != 0 ] ; then + loginfo "patching restart failed" + loginfo "... process-restart ${processes_to_restart}" + exit ${PATCH_STATUS_FAILED} + fi +fi + + +# +# Exit the script with the overall return code +# +exit $GLOBAL_RC +