]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
cephadm: fix rm-cluster when /etc/ceph/ceph.conf is a directory 67621/head
authorKefu Chai <k.chai@proxmox.com>
Wed, 4 Mar 2026 13:10:28 +0000 (21:10 +0800)
committerKefu Chai <k.chai@proxmox.com>
Wed, 4 Mar 2026 13:12:41 +0000 (21:12 +0800)
commitc78636c7e7591a606c9ba75543c62381e5f49d69
treeec694b6c1334d2769ddf88170676f20ed1c45f5e
parent332260fa162e01ac81db5d577895c95870d8cb7c
cephadm: fix rm-cluster when /etc/ceph/ceph.conf is a directory

Fix IsADirectoryError in _rm_cluster() when /etc/ceph/ceph.conf exists
as a directory instead of a file.

The Error:
----------
During cluster cleanup, _rm_cluster() fails with:

  Traceback (most recent call last):
    File "/home/ubuntu/cephtest/cephadm", line 8634, in <module>
      main()
    File "/home/ubuntu/cephtest/cephadm", line 8622, in main
      r = ctx.func(ctx)
    File "/home/ubuntu/cephtest/cephadm", line 6538, in command_rm_cluster
      with open(files[0]) as f:
  IsADirectoryError: [Errno 21] Is a directory: '/etc/ceph/ceph.conf'

Root Cause:
-----------
Container services (iSCSI, NFS, NVMe-oF) create bind mounts like:
  mounts[os.path.join(data_dir, 'config')] = '/etc/ceph/ceph.conf:z'

Docker/Podman has a quirk: when bind mounting to a destination that
doesn't exist, the container runtime creates the destination as a
DIRECTORY, not a file.

The Fix:
--------
Use early returns and guard clauses to handle different states of
/etc/ceph/ceph.conf:

1. If ceph.conf doesn't exist: return early (nothing to clean up)
2. If ceph.conf is an empty directory: remove it and return (leftover
   bind mount point from container)
3. If ceph.conf exists but is not a file: return early (unexpected state)
4. If ceph.conf is a file: validate fsid and remove all config files

Also log a warning when the fsid in ceph.conf does not match the cluster
being removed, so the user knows why config files are not being deleted.

Includes unit tests covering all code paths.

Fixes: https://tracker.ceph.com/issues/75275
Signed-off-by: Kefu Chai <kchai@redhat.com>
Co-authored-by: ADI2705 <2021bit038@sggs.ac.in>
src/cephadm/cephadm.py
src/cephadm/tests/test_cephadm.py