]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Introduce unit.stop 42242/head
authorSebastian Wagner <sewagner@redhat.com>
Wed, 21 Jul 2021 12:13:52 +0000 (14:13 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Wed, 4 Aug 2021 12:56:46 +0000 (14:56 +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>
src/cephadm/cephadm

index 9bb31288415af16fbfec93ecd60c369d84e1ad24..90a62f32563950779656bbeaedf421415bb42fad 100755 (executable)
@@ -2880,6 +2880,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')
@@ -3158,7 +3167,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
@@ -3414,11 +3423,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