From d942043cc56d213dde2c2571cbcc81d37efe2d6b Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 10 Jun 2026 13:22:14 +0200 Subject: [PATCH] ceph-volume: fix raw activate when device path is stale 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 (cherry picked from commit 1ee1fc14fe16aee940293ec228107e8c5a68c2d8) --- src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py | 2 +- src/ceph-volume/ceph_volume/tests/objectstore/test_raw.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py b/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py index e9b0ac9d630..3b0386a68ef 100644 --- a/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py +++ b/src/ceph-volume/ceph_volume/objectstore/baseobjectstore.py @@ -110,7 +110,7 @@ class BaseObjectStore: 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: diff --git a/src/ceph-volume/ceph_volume/tests/objectstore/test_raw.py b/src/ceph-volume/ceph_volume/tests/objectstore/test_raw.py index ba244d05e18..a9de1862a33 100644 --- a/src/ceph-volume/ceph_volume/tests/objectstore/test_raw.py +++ b/src/ceph-volume/ceph_volume/tests/objectstore/test_raw.py @@ -145,7 +145,7 @@ class TestRaw: @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') -- 2.47.3