From 1227752983fcb27d940dec2c335edb3b7375b696 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Fri, 11 Dec 2020 01:47:48 -0500 Subject: [PATCH] systemd: cephfs-mirror systemd unit files Signed-off-by: Venky Shankar --- ceph.spec.in | 37 +++++++++++++++++++++++++++++++ systemd/50-ceph.preset | 1 + systemd/CMakeLists.txt | 2 ++ systemd/cephfs-mirror.target | 7 ++++++ systemd/cephfs-mirror@.service.in | 33 +++++++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 systemd/cephfs-mirror.target create mode 100644 systemd/cephfs-mirror@.service.in diff --git a/ceph.spec.in b/ceph.spec.in index 08088888347..c11b1b76c27 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1811,6 +1811,43 @@ fi %files -n cephfs-mirror %{_bindir}/cephfs-mirror %{_mandir}/man8/cephfs-mirror.8* +%{_unitdir}/cephfs-mirror@.service +%{_unitdir}/cephfs-mirror.target + +%post -n cephfs-mirror +%if 0%{?suse_version} +if [ $1 -eq 1 ] ; then + /usr/bin/systemctl preset cephfs-mirror@\*.service cephfs-mirror.target >/dev/null 2>&1 || : +fi +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_post cephfs-mirror@\*.service cephfs-mirror.target +%endif +if [ $1 -eq 1 ] ; then +/usr/bin/systemctl start cephfs-mirror.target >/dev/null 2>&1 || : +fi + +%preun -n cephfs-mirror +%if 0%{?suse_version} +%service_del_preun cephfs-mirror@\*.service cephfs-mirror.target +%endif +%if 0%{?fedora} || 0%{?rhel} +%systemd_preun cephfs-mirror@\*.service cephfs-mirror.target +%endif + +%postun -n cephfs-mirror +%systemd_postun cephfs-mirror@\*.service cephfs-mirror.target +if [ $1 -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=%{_sysconfdir}/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 cephfs-mirror@\*.service > /dev/null 2>&1 || : + fi +fi %files -n rbd-fuse %{_bindir}/rbd-fuse diff --git a/systemd/50-ceph.preset b/systemd/50-ceph.preset index ca8f4d2c6f6..a7fc5f129ba 100644 --- a/systemd/50-ceph.preset +++ b/systemd/50-ceph.preset @@ -6,3 +6,4 @@ enable ceph-osd.target enable ceph-rbd-mirror.target enable ceph-radosgw.target enable ceph-crash.service +enable cephfs-mirror.target diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt index 43adf7be142..499b5d19024 100644 --- a/systemd/CMakeLists.txt +++ b/systemd/CMakeLists.txt @@ -13,6 +13,7 @@ foreach(service ceph-radosgw@ ceph-rbd-mirror@ ceph-immutable-object-cache@ + cephfs-mirror@ rbdmap) configure_file( ${service}.service.in @@ -34,4 +35,5 @@ install(FILES ceph-rbd-mirror.target ceph-immutable-object-cache.target ceph-volume@.service + cephfs-mirror.target DESTINATION ${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}) diff --git a/systemd/cephfs-mirror.target b/systemd/cephfs-mirror.target new file mode 100644 index 00000000000..e2296dc5c32 --- /dev/null +++ b/systemd/cephfs-mirror.target @@ -0,0 +1,7 @@ +[Unit] +Description=Ceph target to start/stop all cephfs-mirror@.service instances +PartOf=ceph.target +Before=ceph.target + +[Install] +WantedBy=multi-user.target ceph.target \ No newline at end of file diff --git a/systemd/cephfs-mirror@.service.in b/systemd/cephfs-mirror@.service.in new file mode 100644 index 00000000000..a97d6ad8b57 --- /dev/null +++ b/systemd/cephfs-mirror@.service.in @@ -0,0 +1,33 @@ +[Unit] +Description=CephFS Mirror Daemon +After=network-online.target local-fs.target +Wants=network-online.target local-fs.target +PartOf=cephfs-mirror.target + +[Service] +Environment=CLUSTER=ceph +EnvironmentFile=-@SYSTEMD_ENV_FILE@ +ExecStart=/usr/bin/cephfs-mirror --id %i --cluster ${CLUSTER} -f --setuser ceph --setgroup ceph +LimitNOFILE=1048576 +LimitNPROC=1048576 +LockPersonality=true +MemoryDenyWriteExecute=true +NoNewPrivileges=true +PrivateDevices=yes +PrivateTmp=true +ProtectClock=true +ProtectControlGroups=true +ProtectHome=true +ProtectHostname=true +ProtectKernelLogs=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectSystem=full +Restart=on-failure +RestrictSUIDSGID=true +StartLimitBurst=3 +StartLimitInterval=30min +TasksMax=infinity + +[Install] +WantedBy=cephfs-mirror.target \ No newline at end of file -- 2.39.5