From: Sebastian Wagner Date: Wed, 21 Jul 2021 12:13:52 +0000 (+0200) Subject: cephadm: Introduce unit.stop X-Git-Tag: v17.1.0~1199^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0f66a5198e38c59aba1be11d586d49ad01c9afce;p=ceph.git cephadm: Introduce unit.stop 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 --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 9bb31288415af..90a62f3256395 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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