summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2020-09-22 23:17:14 +0200
committerDavid Disseldorp <ddiss@samba.org>2020-09-23 23:29:41 +0000
commitff36cb740251e64661f3877397b7c97efc4f2b4d (patch)
treec9bca732ce679cad7a05524dababf2146f431f25 /ctdb
parent56f022c3f8b7e7bc6052fc5159972598c892b1fa (diff)
downloadsamba-ff36cb740251e64661f3877397b7c97efc4f2b4d.tar.gz
ctdb/ceph: register recovery lock holder with ceph-mgr
The Ceph Manager's service map is useful for tracking the status of Ceph related services. By registering the CTDB recovery lock holder, Ceph storage administrators can more easily identify where and when a CTDB cluster is up and running. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c b/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c
index 7ef76c26e02..bdbb8df7104 100644
--- a/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c
+++ b/ctdb/utils/ceph/ctdb_mutex_ceph_rados_helper.c
@@ -1,7 +1,7 @@
/*
CTDB mutex helper using Ceph librados locks
- Copyright (C) David Disseldorp 2016-2018
+ Copyright (C) David Disseldorp 2016-2020
Based on ctdb_mutex_fcntl_helper.c, which is:
Copyright (C) Martin Schwenke 2015
@@ -267,6 +267,31 @@ static int ctdb_mutex_rados_state_destroy(struct ctdb_mutex_rados_state *cmr_sta
return 0;
}
+/* register this host+service with ceph-mgr for visibility */
+static int ctdb_mutex_rados_mgr_reg(rados_t ceph_cluster)
+{
+ int ret;
+ uint64_t instance_guid;
+ char id_buf[128];
+
+ instance_guid = rados_get_instance_id(ceph_cluster);
+ ret = snprintf(id_buf, sizeof(id_buf), "%s:0x%016llx",
+ "ctdb_mutex_ceph_rados_helper",
+ (unsigned long long)instance_guid);
+ if (ret < 0 || ret >= sizeof(id_buf)) {
+ fprintf(stderr, "Ceph instance name too long\n");
+ return -ENAMETOOLONG;
+ }
+
+ ret = rados_service_register(ceph_cluster, "ctdb", id_buf, "");
+ if (ret < 0) {
+ fprintf(stderr, "failed to register service with ceph-mgr\n");
+ return ret;
+ }
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
int ret;
@@ -380,6 +405,12 @@ int main(int argc, char *argv[])
goto err_ctx_cleanup;
}
+ ret = ctdb_mutex_rados_mgr_reg(cmr_state->ceph_cluster);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to register with ceph-mgr\n");
+ /* ignore: ceph-mgr service registration is informational */
+ }
+
ret = ctdb_mutex_rados_lock(cmr_state->ioctx, cmr_state->object,
cmr_state->lock_duration_s,
0);