Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions qa/tasks/mgr/mgr_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def get_mgr_map(self):
return json.loads(
self.mon_manager.raw_cluster_cmd("mgr", "dump", "--format=json-pretty"))

def get_registered_clients(self, name, mgr_map = None):
if mgr_map is None:
mgr_map = self.get_mgr_map()
for c in mgr_map['active_clients']:
if c['name'] == name:
return c['addrvec']
return None

def get_active_id(self):
return self.get_mgr_map()["active_name"]

Expand Down
34 changes: 34 additions & 0 deletions qa/tasks/mgr/test_failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,37 @@ def test_standby_timeout(self):
timeout=60
)
self.assertEqual(self.mgr_cluster.get_active_id(), original_active)

class TestLibCephSQLiteFailover(MgrTestCase):
MGRS_REQUIRED = 1

def setUp(self):
super(TestLibCephSQLiteFailover, self).setUp()
self.setup_mgrs()

def get_libcephsqlite(self):
mgr_map = self.mgr_cluster.get_mgr_map()
addresses = self.mgr_cluster.get_registered_clients('libcephsqlite', mgr_map=mgr_map)
self.assertEqual(len(addresses), 1)
return addresses[0]

def test_maybe_reonnect(self):
"""
That the devicehealth module can recover after losing its libcephsqlite lock.
"""

# make sure the database is populated and loaded by the module
self.mgr_cluster.mon_manager.ceph("device scrape-health-metrics")

oldaddr = self.get_libcephsqlite()
self.mgr_cluster.mon_manager.ceph(f"osd blocklist add {oldaddr['addr']}/{oldaddr['nonce']}")

def test():
self.mgr_cluster.mon_manager.ceph("device scrape-health-metrics")
newaddr = self.get_libcephsqlite()
return oldaddr != newaddr

self.wait_until_true(
test,
timeout=30
)
14 changes: 7 additions & 7 deletions src/SimpleRADOSStriper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int SimpleRADOSStriper::remove()

auto ext = get_first_extent();
if (int rc = ioctx.remove(ext.soid); rc < 0) {
d(5) << " remove failed: " << cpp_strerror(rc) << dendl;
d(1) << " remove failed: " << cpp_strerror(rc) << dendl;
return rc;
}

Expand Down Expand Up @@ -171,7 +171,7 @@ int SimpleRADOSStriper::wait_for_aios(bool block)
}
}
if (rc) {
d(5) << " aio failed: " << cpp_strerror(rc) << dendl;
d(1) << " aio failed: " << cpp_strerror(rc) << dendl;
if (aios_failure == 0) {
aios_failure = rc;
}
Expand Down Expand Up @@ -257,7 +257,7 @@ int SimpleRADOSStriper::open()
op.getxattr(XATTR_ALLOCATED, &bl_alloc, &prval_alloc);
op.getxattr(XATTR_VERSION, &bl_version, &prval_version);
if (int rc = ioctx.operate(ext.soid, &op, &pbl); rc < 0) {
d(5) << " getxattr failed: " << cpp_strerror(rc) << dendl;
d(1) << " getxattr failed: " << cpp_strerror(rc) << dendl;
return rc;
}
exclusive_holder = bl_excl.to_str();
Expand Down Expand Up @@ -297,7 +297,7 @@ int SimpleRADOSStriper::shrink_alloc(uint64_t a)
auto ext = get_next_extent(offset, len);
auto aiocp = aiocompletionptr(librados::Rados::aio_create_completion());
if (int rc = ioctx.aio_remove(ext.soid, aiocp.get()); rc < 0) {
d(5) << " aio_remove failed: " << cpp_strerror(rc) << dendl;
d(1) << " aio_remove failed: " << cpp_strerror(rc) << dendl;
return rc;
}
removes.emplace_back(std::move(aiocp));
Expand All @@ -307,7 +307,7 @@ int SimpleRADOSStriper::shrink_alloc(uint64_t a)

for (auto& aiocp : removes) {
if (int rc = aiocp->wait_for_complete(); rc < 0 && rc != -ENOENT) {
d(5) << " aio_remove failed: " << cpp_strerror(rc) << dendl;
d(1) << " aio_remove failed: " << cpp_strerror(rc) << dendl;
return rc;
}
}
Expand All @@ -320,7 +320,7 @@ int SimpleRADOSStriper::shrink_alloc(uint64_t a)
op.setxattr(XATTR_VERSION, uint2bl(version+1));
d(15) << " updating version to " << (version+1) << dendl;
if (int rc = ioctx.aio_operate(ext.soid, aiocp.get(), &op); rc < 0) {
d(5) << " update failed: " << cpp_strerror(rc) << dendl;
d(1) << " update failed: " << cpp_strerror(rc) << dendl;
return rc;
}
/* we need to wait so we don't have dangling extents */
Expand Down Expand Up @@ -726,7 +726,7 @@ int SimpleRADOSStriper::lock(uint64_t timeoutms)
}

if (int rc = open(); rc < 0) {
d(5) << " open failed: " << cpp_strerror(rc) << dendl;
d(1) << " open failed: " << cpp_strerror(rc) << dendl;
return rc;
}

Expand Down
Loading