[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/2] rbd: Set timeout options for librados



These timeout values make librados/librbd return -ETIMEDOUT when a
operation is blocking due to a failing/unreachable Ceph cluster.

By having the operations time out libvirt will not block.
---
 src/storage/storage_backend_rbd.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index abb110e..22ed7de 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -60,6 +60,9 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
     char secretUuid[VIR_UUID_STRING_BUFLEN];
     size_t i;
     char *mon_buff = NULL;
+    const char *client_mount_timeout = "30";
+    const char *mon_op_timeout = "30";
+    const char *osd_op_timeout = "30";
 
     VIR_DEBUG("Found Cephx username: %s",
               pool->def->source.auth.cephx.username);
@@ -197,6 +200,20 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
         goto cleanup;
     }
 
+    /*
+     * Set timeout options for librados.
+     * In case the Ceph cluster is down libvirt won't block forever.
+     * Operations in librados will return -ETIMEDOUT when the timeout is reached.
+     */
+    VIR_DEBUG("Setting RADOS option client_mount_timeout to %s", client_mount_timeout);
+    rados_conf_set(ptr->cluster, "client_mount_timeout", client_mount_timeout);
+
+    VIR_DEBUG("Setting RADOS option rados_mon_op_timeout to %s", mon_op_timeout);
+    rados_conf_set(ptr->cluster, "rados_mon_op_timeout", mon_op_timeout);
+
+    VIR_DEBUG("Setting RADOS option rados_osd_op_timeout to %s", osd_op_timeout);
+    rados_conf_set(ptr->cluster, "rados_osd_op_timeout", osd_op_timeout);
+
     ptr->starttime = time(0);
     r = rados_connect(ptr->cluster);
     if (r < 0) {
-- 
1.7.9.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]