This changes unlink_bs_symlinks to use os.path.lexists instead
of os.path.exists. It can happen that devices get renumbered,
in that case, the OSD symlink still exists but its target device
is gone which means os.path.exists returns False, so the symlink
is never cleaned up and ceph-volume activate can fail later.
Fixes: https://tracker.ceph.com/issues/77295
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
def unlink_bs_symlinks(self) -> None:
for link_name in ['block', 'block.db', 'block.wal']:
link_path = os.path.join(self.osd_path, link_name)
- if os.path.exists(link_path):
+ if os.path.lexists(link_path):
os.unlink(os.path.join(self.osd_path, link_name))
def prepare_osd_req(self, tmpfs: bool = True) -> None:
@patch('ceph_volume.objectstore.raw.prepare_utils.link_wal')
@patch('ceph_volume.objectstore.raw.prepare_utils.link_db')
@patch('ceph_volume.objectstore.raw.prepare_utils.link_block')
- @patch('os.path.exists')
+ @patch('os.path.lexists')
@patch('os.unlink')
@patch('ceph_volume.objectstore.raw.prepare_utils.create_osd_path')
@patch('ceph_volume.objectstore.raw.process.run')