From c197bbdccadf799be2d86da28f1d2302ccf5e1e8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 27 Nov 2023 11:33:12 +0900 Subject: [PATCH] RBD: Use rados_connect_timeout to override timeout This imports the existing rados_connect_timeout option handling in cinder so that users can use a different timeouts for Glance specifically, instead of relying on the global ceph.conf options. This parameter was initially deprecated in Zed release by [1] and has had no effect since then, but this change restores the parameter with the logic to override the timeout value in RADOS client. [1] b1d0feeba4e16046c7840bd4966f31a0e7527e67 Related-Bug: #1983499 Change-Id: Ib370f527c06dc85bcfd9df6ca1efb2a4e8cb5e7d --- glance_store/_drivers/rbd.py | 25 +++++++++++-------- ...ados_connect_timeout-39e5074bc1a3b65b.yaml | 19 ++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/fix-rados_connect_timeout-39e5074bc1a3b65b.yaml diff --git a/glance_store/_drivers/rbd.py b/glance_store/_drivers/rbd.py index ba2defa3..5e18af8f 100644 --- a/glance_store/_drivers/rbd.py +++ b/glance_store/_drivers/rbd.py @@ -134,14 +134,7 @@ Related options: * rbd_store_user """), - cfg.IntOpt('rados_connect_timeout', default=0, - deprecated_for_removal=True, - deprecated_since='Zed', - deprecated_reason=""" -This option has not had any effect in years. Users willing to set a timeout for -connecting to the Ceph cluster should use 'client_mount_timeout' in Ceph's -configuration file. -""", + cfg.IntOpt('rados_connect_timeout', default=-1, help=""" Timeout value for connecting to Ceph cluster. @@ -149,8 +142,8 @@ This configuration option takes in the timeout value in seconds used when connecting to the Ceph cluster i.e. it sets the time to wait for glance-api before closing the connection. This prevents glance-api hangups during the connection to RBD. If the value for this option -is set to less than or equal to 0, no timeout is set and the default -librados value is used. +is set to less than 0, no timeout is set and the default librados value +is used. Possible Values: * Any integer value @@ -302,6 +295,18 @@ class Store(driver.Store): def get_connection(self, conffile, rados_id): client = rados.Rados(conffile=conffile, rados_id=rados_id) + if self.backend_group: + timeout = getattr(self.conf, + self.backend_group).rados_connect_timeout + else: + timeout = self.conf.glance_store.rados_connect_timeout + + if timeout >= 0: + t = str(timeout) + client.conf_set('rados_osd_op_timeout', t) + client.conf_set('rados_mon_op_timeout', t) + client.conf_set('client_mount_timeout', t) + try: client.connect() except (rados.Error, rados.ObjectNotFound) as e: diff --git a/releasenotes/notes/fix-rados_connect_timeout-39e5074bc1a3b65b.yaml b/releasenotes/notes/fix-rados_connect_timeout-39e5074bc1a3b65b.yaml new file mode 100644 index 00000000..27aef5be --- /dev/null +++ b/releasenotes/notes/fix-rados_connect_timeout-39e5074bc1a3b65b.yaml @@ -0,0 +1,19 @@ +--- +features: + - | + RBD driver: the ``rados_connect_timeout`` config option has been + un-deprecated and its behavior has been improved. A value of ``0`` + is now respected as disabling timeout in requests, while a value less + than zero indicates that glance_store will not set a timeout but + instead will use whatever timeouts are set in the Ceph configuration + file. + +upgrade: + - | + RBD driver: the default value of the ``rados_connect_timeout`` option + has been changed from 0 to -1, so that the RBD driver will by default + use the timeout values defined in ``ceph.conf``. Be aware that + setting this option to 0 disables timeouts (that is, the RBD driver + will make requests with a timeout of zero, and all requests wait forever), + thereby overriding any timeouts that are set in the Ceph configuration + file.