From 7106a12251c1a18d362ff1cc7c59c8774389cda8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 26 Aug 2025 09:45:43 +0900 Subject: [PATCH] Rename confusing query timeout options These do not actually define timeout but interval. Rename the options to reflect what they actually define. The existing deprecated options in the [gnocchi_client] are also removed, because these have been kept for 6 years. In addition, fix inconsistent name (query vs call). Change-Id: Ib29115746a25b45bdff1c3da8df9d7167c2db662 Signed-off-by: Takashi Kajinami --- ...al-not-query-timeout-ecb6f2c6b1a647e9.yaml | 21 +++++++++++++++++++ watcher/conf/collector.py | 15 ++++++++----- watcher/conf/datasources.py | 7 +++---- watcher/decision_engine/datasources/base.py | 6 +++--- .../decision_engine/model/collector/base.py | 10 ++++----- .../decision_engine/datasources/test_base.py | 4 ++-- 6 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 releasenotes/notes/query-interval-not-query-timeout-ecb6f2c6b1a647e9.yaml diff --git a/releasenotes/notes/query-interval-not-query-timeout-ecb6f2c6b1a647e9.yaml b/releasenotes/notes/query-interval-not-query-timeout-ecb6f2c6b1a647e9.yaml new file mode 100644 index 000000000..ef9cb5628 --- /dev/null +++ b/releasenotes/notes/query-interval-not-query-timeout-ecb6f2c6b1a647e9.yaml @@ -0,0 +1,21 @@ +--- +deprecations: + - | + The ``[collector] api_query_timeout`` option was deprecated in favor of + the ``[collector] api_query_interval`` option. + + - | + The ``[collector] api_call_retries`` option was deprecated in favor of + the ``[collector] api_query_max_retries`` option. + + - | + The ``[watcher_datasources] query_timeout`` option was deprecated in favor + of the ``[watcher_datasources] query_interval`` option. + + - | + The following deprecated options were removed. + + - ``[gnocchi_client] query_timeout`` (Use + ``[watcher_datsources] query_interval``) + - ``[gnocchi_client] query_max_retries`` (Use + ``[watcher_datasources] query_max_retires``) diff --git a/watcher/conf/collector.py b/watcher/conf/collector.py index 126657f02..2577f3a97 100644 --- a/watcher/conf/collector.py +++ b/watcher/conf/collector.py @@ -35,13 +35,18 @@ Supported in-tree collectors include: Custom data model collector plugins can be defined with the ``watcher_cluster_data_model_collectors`` extension point. """), - cfg.IntOpt('api_call_retries', + cfg.IntOpt('api_query_max_retries', + min=1, default=10, - help="Number of retries before giving up on external service " - "calls."), - cfg.IntOpt('api_query_timeout', + help="Number of retries before giving up on query to " + "external service.", + deprecated_name="api_call_retries"), + cfg.IntOpt('api_query_interval', + min=0, default=1, - help="Time before retry after failed call to external service.") + help="Time before retry after failed query to " + "external service.", + deprecated_name="api_query_timeout") ] diff --git a/watcher/conf/datasources.py b/watcher/conf/datasources.py index 67e457040..c69903ac9 100644 --- a/watcher/conf/datasources.py +++ b/watcher/conf/datasources.py @@ -46,14 +46,13 @@ DATASOURCES_OPTS = [ min=1, default=10, mutable=True, - help='How many times Watcher is trying to query again', - deprecated_group="gnocchi_client"), - cfg.IntOpt('query_timeout', + help='How many times Watcher is trying to query again'), + cfg.IntOpt('query_interval', min=0, default=1, mutable=True, help='How many seconds Watcher should wait to do query again', - deprecated_group="gnocchi_client") + deprecated_name="query_timeout") ] diff --git a/watcher/decision_engine/datasources/base.py b/watcher/decision_engine/datasources/base.py index c196bece1..9dfa664e8 100644 --- a/watcher/decision_engine/datasources/base.py +++ b/watcher/decision_engine/datasources/base.py @@ -78,7 +78,7 @@ class DataSourceBase(object): """ num_retries = CONF.watcher_datasources.query_max_retries - timeout = CONF.watcher_datasources.query_timeout + interval = CONF.watcher_datasources.query_interval ignored_exc = ignored_exc or tuple() for i in range(num_retries): @@ -92,8 +92,8 @@ class DataSourceBase(object): LOG.exception(e) self.query_retry_reset(e) LOG.warning("Retry %d of %d while retrieving metrics retry " - "in %d seconds", i+1, num_retries, timeout) - time.sleep(timeout) + "in %d seconds", i+1, num_retries, interval) + time.sleep(interval) @abc.abstractmethod def query_retry_reset(self, exception_instance): diff --git a/watcher/decision_engine/model/collector/base.py b/watcher/decision_engine/model/collector/base.py index 5c20a8de0..412855f90 100644 --- a/watcher/decision_engine/model/collector/base.py +++ b/watcher/decision_engine/model/collector/base.py @@ -201,15 +201,15 @@ class BaseModelBuilder(object): Attempts to access data from the external service and handles exceptions. The retrieval should be retried in accordance - to the value of api_call_retries + to the value of api_query_max_retries :param f: The method that performs the actual querying for metrics :param args: Array of arguments supplied to the method :param kwargs: The amount of arguments supplied to the method :return: The value as retrieved from the external service """ - num_retries = CONF.collector.api_call_retries - timeout = CONF.collector.api_query_timeout + num_retries = CONF.collector.api_query_max_retries + interval = CONF.collector.api_query_interval for i in range(num_retries): try: @@ -219,8 +219,8 @@ class BaseModelBuilder(object): self.call_retry_reset(e) LOG.warning("Retry %d of %d, error while calling service " "retry in %s seconds", - i+1, num_retries, timeout) - time.sleep(timeout) + i+1, num_retries, interval) + time.sleep(interval) raise @abc.abstractmethod diff --git a/watcher/tests/decision_engine/datasources/test_base.py b/watcher/tests/decision_engine/datasources/test_base.py index 8254fd6e4..6449134dd 100644 --- a/watcher/tests/decision_engine/datasources/test_base.py +++ b/watcher/tests/decision_engine/datasources/test_base.py @@ -37,7 +37,7 @@ class TestBaseDatasourceHelper(base.BaseTestCase): CONF.set_override("query_max_retries", 2, group='watcher_datasources') # Reduce sleep time to 0 - CONF.set_override("query_timeout", 0, + CONF.set_override("query_interval", 0, group='watcher_datasources') helper = datasource.DataSourceBase() @@ -55,7 +55,7 @@ class TestBaseDatasourceHelper(base.BaseTestCase): CONF.set_override("query_max_retries", 2, group='watcher_datasources') # Reduce sleep time to 0 - CONF.set_override("query_timeout", 0, + CONF.set_override("query_interval", 0, group='watcher_datasources') helper = datasource.DataSourceBase()