From 517e3fdc79060803b277d513e5d65023f91585a0 Mon Sep 17 00:00:00 2001 From: Dan van der Ster Date: Mon, 12 Jul 2021 15:35:39 +0200 Subject: [PATCH] ceph.spec: selinux scripts respect CEPH_AUTO_RESTART_ON_UPGRADE In /etc/sysconfig/ceph we allow operators to define if ceph daemons should be restarted on upgrade: CEPH_AUTO_RESTART_ON_UPGRADE. But the post selinux scripts will stop ceph.target regardless if this is set to `no`, leading to operators adding various hacks to prevent these unexpected or inconvenient daemon restarts. By now, if users are using rpms directly, they are likely orchestrating their own daemon restarts so should not rely on the rpm itself to do this. Fixes: https://tracker.ceph.com/issues/21672 Signed-off-by: Dan van der Ster (cherry picked from commit 092a6e3e83e9ef8e37cb6f1033c345dcb5224cfc) --- ceph.spec.in | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/ceph.spec.in b/ceph.spec.in index ccafc4562941c..0dea4d6fccba9 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -2244,13 +2244,21 @@ if diff ${FILE_CONTEXT} ${FILE_CONTEXT}.pre > /dev/null 2>&1; then exit 0 fi +# Stop ceph.target while relabeling if CEPH_AUTO_RESTART_ON_UPGRADE=yes +SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph +if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then + source $SYSCONF_CEPH +fi + # Check whether the daemons are running /usr/bin/systemctl status ceph.target > /dev/null 2>&1 STATUS=$? # Stop the daemons if they were running if test $STATUS -eq 0; then - /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 + fi fi # Relabel the files fix for first package install @@ -2262,7 +2270,9 @@ rm -f ${FILE_CONTEXT}.pre # Start the daemons iff they were running before if test $STATUS -eq 0; then - /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : + fi fi exit 0 @@ -2282,13 +2292,21 @@ if [ $1 -eq 0 ]; then exit 0 fi + # Stop ceph.target while relabeling if CEPH_AUTO_RESTART_ON_UPGRADE=yes + SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph + if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then + source $SYSCONF_CEPH + fi + # Check whether the daemons are running /usr/bin/systemctl status ceph.target > /dev/null 2>&1 STATUS=$? # Stop the daemons if they were running if test $STATUS -eq 0; then - /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 + fi fi /usr/sbin/fixfiles -C ${FILE_CONTEXT}.pre restore 2> /dev/null @@ -2298,7 +2316,9 @@ if [ $1 -eq 0 ]; then # Start the daemons if they were running before if test $STATUS -eq 0; then - /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : + fi fi fi exit 0 -- 2.47.3