]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Introduce unit.stop
authorSebastian Wagner <sewagner@redhat.com>
Wed, 21 Jul 2021 12:13:52 +0000 (14:13 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 10 Aug 2021 14:36:33 +0000 (16:36 +0200)
Reason is we now have to stop two containers named differently. This is possible
with `bash -c ... echo %i | tr . -`. But we're not gainig anything readability
compared to putting it into a unit.stop script.

As not all daemons have this stop script, we still have to call podman for old daemons.

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
(cherry picked from commit 0f66a5198e38c59aba1be11d586d49ad01c9afce)

src/cephadm/cephadm

index 12a99b5268f38ec346048da1a6d87dfde0137a76..ce0081d22306f7f0dfdc4266774ecbfaa9db6f65 100755 (executable)
@@ -2857,6 +2857,15 @@ def deploy_daemon_units(
         os.rename(data_dir + '/unit.poststop.new',
                   data_dir + '/unit.poststop')
 
+    # post-stop command(s)
+    with open(data_dir + '/unit.stop.new', 'w') as f:
+        f.write('! ' + ' '.join(c.stop_cmd()) + '\n')
+        f.write('! ' + ' '.join(c.stop_cmd(old_cname=True)) + '\n')
+
+        os.fchmod(f.fileno(), 0o600)
+        os.rename(data_dir + '/unit.stop.new',
+                  data_dir + '/unit.stop')
+
     if c:
         with open(data_dir + '/unit.image.new', 'w') as f:
             f.write(c.image + '\n')
@@ -3135,7 +3144,7 @@ LimitNOFILE=1048576
 LimitNPROC=1048576
 EnvironmentFile=-/etc/environment
 ExecStart=/bin/bash {data_dir}/{fsid}/%i/unit.run
-ExecStop=-{container_path} stop ceph-{fsid}-%i
+ExecStop=-/bin/bash -c '{container_path} stop ceph-{fsid}-%i ; bash {data_dir}/{fsid}/%i/unit.stop'
 ExecStopPost=-/bin/bash {data_dir}/{fsid}/%i/unit.poststop
 KillMode=none
 Restart=on-failure
@@ -3391,11 +3400,10 @@ class CephContainer:
             ret.append(self.cname)
         return ret
 
-    def stop_cmd(self):
-        # type: () -> List[str]
+    def stop_cmd(self, old_cname: bool = False) -> List[str]:
         ret = [
             str(self.ctx.container_engine.path),
-            'stop', self.cname,
+            'stop', self.old_cname if old_cname else self.cname,
         ]
         return ret