From: Sebastian Wagner Date: Tue, 12 May 2020 12:07:32 +0000 (+0200) Subject: cephadm: Manually remove containers X-Git-Tag: v15.2.5~147^2~55 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c9d6a1d179f29af8da8e7f897c02ffc65111ceee;p=ceph.git cephadm: Manually remove containers This fixes: ``` Error: error creating container storage: the container name "ceph--mon.b" is already in use by "". You have to remove that container to be able to reuse that name.: that name is already in use ``` Relates to https://tracker.ceph.com/issues/44990 Signed-off-by: Sebastian Wagner (cherry picked from commit b3fbc0329c15d0a7d73d9e0ad6f0065d724b12a7) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index e27bc73a6365..3e0603fbfc26 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1885,6 +1885,9 @@ def deploy_daemon_units(fsid, uid, gid, daemon_type, daemon_id, c, install_path = find_program('install') f.write('{install_path} -d -m0770 -o {uid} -g {gid} /var/run/ceph/{fsid}\n'.format(install_path=install_path, fsid=fsid, uid=uid, gid=gid)) + # Sometimes, adding `--rm` to a run_cmd doesn't work. Let's remove the container manually + f.write(' '.join(c.rm_cmd()) + '\n') + # container run command f.write(' '.join(c.run_cmd()) + '\n') os.fchmod(f.fileno(), 0o600) @@ -2209,6 +2212,14 @@ class CephContainer: self.cname, ] + cmd + def rm_cmd(self): + # type: () -> List[str] + return [ + str(container_path), + 'rm', '-f', + self.cname + ] + def run(self, timeout=DEFAULT_TIMEOUT): # type: (Optional[int]) -> str logger.debug(self.run_cmd())