From: Nathan Cutler Date: Tue, 19 Apr 2016 12:48:41 +0000 (+0200) Subject: rpm: implement scriptlets for the post-split daemon packages X-Git-Tag: ses3-milestone5~38^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c72f0bc3d4fb9a3f5abfefcf8d2775721d95b33a;p=ceph.git rpm: implement scriptlets for the post-split daemon packages This patch gives each of the ceph-{mds,mon,osd,radosgw} packages its own %post, %preun, and %postun scriptlets dealing with the package's unit files. The scriptlets of ceph-base are adapted to handle the ceph.target unit file only. The scriptlets of ceph-mon handle ceph-create-keys services in addition to ceph-mon. The scriptlets of ceph-osd handle ceph-disk services in addition to ceph-osd. Fixes: http://tracker.ceph.com/issues/14941 Signed-off-by: Nathan Cutler Signed-off-by: Boris Ranto (cherry picked from commit 644aba9270714e5e231ac7d7e3437477837531eb) --- diff --git a/ceph.spec.in b/ceph.spec.in index 409959672ee9..34379310beef 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -901,70 +901,34 @@ rm -rf $RPM_BUILD_ROOT %attr(770,ceph,ceph) %dir %{_localstatedir}/run/ceph %endif -%pre base -%if 0%{?_with_systemd} - %if 0%{?suse_version} - # service_add_pre and friends don't work with parameterized systemd service - # instances, only with single services or targets, so we always pass - # ceph.target to these macros - %service_add_pre ceph.target - %endif -%endif - %post base /sbin/ldconfig -%if 0%{?_with_systemd} - %if 0%{?suse_version} - %fillup_only - %service_add_post ceph.target - %endif -%else - /sbin/chkconfig --add ceph +%if 0%{?suse_version} +%fillup_only +if [ $1 -ge 1 ] ; then + /usr/bin/systemctl preset ceph.target >/dev/null 2>&1 || : +fi +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_post ceph.target %endif %preun base -%if 0%{?_with_systemd} - %if 0%{?suse_version} - %service_del_preun ceph.target - %endif - # Disable and stop on removal. - if [ $1 = 0 ] ; then - SERVICE_LIST=$(systemctl | grep -E '^ceph-mon@|^ceph-create-keys@|^ceph-osd@|^ceph-mds@|^ceph-disk-' | cut -d' ' -f1) - if [ -n "$SERVICE_LIST" ]; then - for SERVICE in $SERVICE_LIST; do - /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || : - /usr/bin/systemctl stop $SERVICE > /dev/null 2>&1 || : - done - fi - fi -%else - %if 0%{?rhel} || 0%{?fedora} - if [ $1 = 0 ] ; then - /sbin/service ceph stop >/dev/null 2>&1 - /sbin/chkconfig --del ceph - fi - %endif +%if 0%{?suse_version} +%service_del_preun ceph.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_preun ceph.target %endif %postun base /sbin/ldconfig -%if 0%{?_with_systemd} - if [ $1 = 1 ] ; then - # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to - # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph - if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then - source $SYSCONF_CEPH - fi - if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then - SERVICE_LIST=$(systemctl | grep -E '^ceph-mon@|^ceph-create-keys@|^ceph-osd@|^ceph-mds@|^ceph-disk-' | cut -d' ' -f1) - if [ -n "$SERVICE_LIST" ]; then - for SERVICE in $SERVICE_LIST; do - /usr/bin/systemctl try-restart $SERVICE > /dev/null 2>&1 || : - done - fi - fi - fi +%if 0%{?suse_version} +DISABLE_RESTART_ON_UPDATE="yes" +%service_del_postun ceph.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_postun ceph.target %endif ################################################################################# @@ -1070,6 +1034,45 @@ fi %endif %attr(750,ceph,ceph) %dir %{_localstatedir}/lib/ceph/mds +%post mds +%if 0%{?suse_version} +if [ $1 -ge 1 ] ; then + /usr/bin/systemctl preset ceph-mds@\*.service ceph-mds.target >/dev/null 2>&1 || : +fi +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_post ceph-mds@\*.service ceph-mds.target +%endif + +%preun mds +%if 0%{?suse_version} +%service_del_preun ceph-mds@\*.service ceph-mds.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_preun ceph-mds@\*.service ceph-mds.target +%endif + +%postun mds +test -n "$FIRST_ARG" || FIRST_ARG=$1 +%if 0%{?suse_version} +DISABLE_RESTART_ON_UPDATE="yes" +%service_del_postun ceph-mds@\*.service ceph-mds.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_postun ceph-mds@\*.service ceph-mds.target +%endif +if [ $FIRST_ARG -ge 1 ] ; then + # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to + # "yes". In any case: if units are not running, do not touch them. + SYSCONF_CEPH=/etc/sysconfig/ceph + if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then + source $SYSCONF_CEPH + fi + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl try-restart ceph-mds@\*.service > /dev/null 2>&1 || : + fi +fi + ################################################################################# %files mon %{_bindir}/ceph-mon @@ -1085,6 +1088,45 @@ fi %endif %attr(750,ceph,ceph) %dir %{_localstatedir}/lib/ceph/mon +%post mon +%if 0%{?suse_version} +if [ $1 -ge 1 ] ; then + /usr/bin/systemctl preset ceph-create-keys@\*.service ceph-mon@\*.service ceph-mon.target >/dev/null 2>&1 || : +fi +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_post ceph-create-keys@\*.service ceph-mon@\*.service ceph-mon.target +%endif + +%preun mon +%if 0%{?suse_version} +%service_del_preun ceph-create-keys@\*.service ceph-mon@\*.service ceph-mon.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_preun ceph-create-keys@\*.service ceph-mon@\*.service ceph-mon.target +%endif + +%postun mon +test -n "$FIRST_ARG" || FIRST_ARG=$1 +%if 0%{?suse_version} +DISABLE_RESTART_ON_UPDATE="yes" +%service_del_postun ceph-create-keys@\*.service ceph-mon@\*.service ceph-mon.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_postun ceph-create-keys@\*.service ceph-mon@\*.service ceph-mon.target +%endif +if [ $FIRST_ARG -ge 1 ] ; then + # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to + # "yes". In any case: if units are not running, do not touch them. + SYSCONF_CEPH=/etc/sysconfig/ceph + if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then + source $SYSCONF_CEPH + fi + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl try-restart ceph-create-keys@\*.service ceph-mon@\*.service > /dev/null 2>&1 || : + fi +fi + ################################################################################# %files fuse %defattr(-,root,root,-) @@ -1138,48 +1180,43 @@ fi %endif %post radosgw -/sbin/ldconfig %if 0%{?suse_version} - # explicit systemctl daemon-reload (that's the only relevant bit of - # service_add_post; the rest is all sysvinit --> systemd migration which - # isn't applicable in this context (see above comment). - /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + /usr/bin/systemctl preset ceph-radosgw@\*.service ceph-radosgw.target >/dev/null 2>&1 || : +fi +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_post ceph-radosgw@\*.service ceph-radosgw.target %endif %preun radosgw -%if 0%{?_with_systemd} - # Disable and stop on removal. - if [ $1 = 0 ] ; then - SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@' | cut -d' ' -f1) - if [ -n "$SERVICE_LIST" ]; then - for SERVICE in $SERVICE_LIST; do - /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || : - /usr/bin/systemctl stop $SERVICE > /dev/null 2>&1 || : - done - fi - fi +%if 0%{?suse_version} +%service_del_preun ceph-radosgw@\*.service ceph-radosgw.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_preun ceph-radosgw@\*.service ceph-radosgw.target %endif %postun radosgw -/sbin/ldconfig -%if 0%{?_with_systemd} - if [ $1 = 1 ] ; then - # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to - # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph - if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then - source $SYSCONF_CEPH - fi - if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then - SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@' | cut -d' ' -f1) - if [ -n "$SERVICE_LIST" ]; then - for SERVICE in $SERVICE_LIST; do - /usr/bin/systemctl try-restart $SERVICE > /dev/null 2>&1 || : - done - fi - fi - fi +test -n "$FIRST_ARG" || FIRST_ARG=$1 +%if 0%{?suse_version} +DISABLE_RESTART_ON_UPDATE="yes" +%service_del_postun ceph-radosgw@\*.service ceph-radosgw.target %endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_postun ceph-radosgw@\*.service ceph-radosgw.target +%endif +if [ $FIRST_ARG -ge 1 ] ; then + # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to + # "yes". In any case: if units are not running, do not touch them. + SYSCONF_CEPH=/etc/sysconfig/ceph + if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then + source $SYSCONF_CEPH + fi + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl try-restart ceph-radosgw@\*.service > /dev/null 2>&1 || : + fi +fi ################################################################################# %files osd @@ -1207,6 +1244,45 @@ fi %endif %attr(750,ceph,ceph) %dir %{_localstatedir}/lib/ceph/osd +%post osd +%if 0%{?suse_version} +if [ $1 -ge 1 ] ; then + /usr/bin/systemctl preset ceph-disk@\*.service ceph-osd@\*.service ceph-osd.target >/dev/null 2>&1 || : +fi +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_post ceph-disk@\*.service ceph-osd@\*.service ceph-osd.target +%endif + +%preun osd +%if 0%{?suse_version} +%service_del_preun ceph-disk@\*.service ceph-osd@\*.service ceph-osd.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_preun ceph-disk@\*.service ceph-osd@\*.service ceph-osd.target +%endif + +%postun osd +test -n "$FIRST_ARG" || FIRST_ARG=$1 +%if 0%{?suse_version} +DISABLE_RESTART_ON_UPDATE="yes" +%service_del_postun ceph-disk@\*.service ceph-osd@\*.service ceph-osd.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_postun ceph-disk@\*.service ceph-osd@\*.service ceph-osd.target +%endif +if [ $FIRST_ARG -ge 1 ] ; then + # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to + # "yes". In any case: if units are not running, do not touch them. + SYSCONF_CEPH=/etc/sysconfig/ceph + if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then + source $SYSCONF_CEPH + fi + if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then + /usr/bin/systemctl try-restart ceph-disk@\*.service ceph-osd@\*.service > /dev/null 2>&1 || : + fi +fi + ################################################################################# %if %{with ocf} @@ -1452,7 +1528,7 @@ else exit 0 fi -if test "$OLD_POLVER" == "$NEW_POLVER"; then +if test "$OLD_POLVER" = "$NEW_POLVER"; then # Do not relabel if policy version did not change exit 0 fi