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 <daniel.vanderster@cern.ch>
This commit is contained in:
Dan van der Ster 2021-07-12 15:35:39 +02:00
parent 3e2c8e94fb
commit 092a6e3e83

View File

@ -2398,13 +2398,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
@ -2416,7 +2424,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
@ -2436,13 +2446,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
@ -2452,7 +2470,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