From 2d86d5f96b1e60c6b59a6d1c72f2b5dd2f2d839d Mon Sep 17 00:00:00 2001 From: Ro'e Katz Date: Mon, 4 Mar 2024 19:24:04 +0200 Subject: [PATCH] Rename DATA_STORE_CONN_RETRY -> DATA_UPDATER_CONN_RETRY With backwards compatibility --- .../docs/getting-started/configuration.mdx | 4 +++- packages/opal-client/opal_client/config.py | 13 ++++++++++++- packages/opal-client/opal_client/data/fetcher.py | 4 ++-- packages/opal-server/opal_server/config.py | 4 +--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/documentation/docs/getting-started/configuration.mdx b/documentation/docs/getting-started/configuration.mdx index dc4e3dd94..8dfd82193 100644 --- a/documentation/docs/getting-started/configuration.mdx +++ b/documentation/docs/getting-started/configuration.mdx @@ -156,7 +156,9 @@ Please use this table as a reference. | SHOULD_REPORT_ON_DATA_UPDATES | Should the client report on updates to callbacks defined in DEFAULT_UPDATE_CALLBACKS or within the given updates. | | | DEFAULT_UPDATE_CALLBACK_CONFIG | | | | DEFAULT_UPDATE_CALLBACKS | Where/How the client should report on the completion of data updates. | | -| DATA_STORE_CONN_RETRY | Retry options when connecting to the base data source (e.g. an external API server which returns data snapshot). | | +| DATA_UPDATER_CONN_RETRY | Retry options when connecting to the base data source (e.g. an external API server which returns data snapshot). | | +| DATA_STORE_CONN_RETRY | DEPTRECATED - The old confusing name for DATA_UPDATER_CONN_RETRY, kept for backwards compatibilit (for now) | | + ## OPA Transaction Log / Healthcheck Configuration Variables diff --git a/packages/opal-client/opal_client/config.py b/packages/opal-client/opal_client/config.py index a8b7e2244..a38c280c0 100644 --- a/packages/opal-client/opal_client/config.py +++ b/packages/opal-client/opal_client/config.py @@ -52,7 +52,7 @@ class OpalClientConfig(Confi): POLICY_STORE_CONN_RETRY: ConnRetryOptions = confi.model( "POLICY_STORE_CONN_RETRY", ConnRetryOptions, - # defaults are being set according to PolicyStoreConnRetryOptions pydantic definitions (see class) + # defaults are being set according to ConnRetryOptions pydantic definitions (see class) {}, description="retry options when connecting to the policy store (i.e. the agent that handles the policy, e.g. OPA)", ) @@ -71,6 +71,13 @@ class OpalClientConfig(Confi): DATA_STORE_CONN_RETRY: ConnRetryOptions = confi.model( "DATA_STORE_CONN_RETRY", ConnRetryOptions, + None, + description="DEPTRECATED - The old confusing name for DATA_UPDATER_CONN_RETRY, kept for backwards compatibilit (for now)", + ) + + DATA_UPDATER_CONN_RETRY: ConnRetryOptions = confi.model( + "DATA_UPDATER_CONN_RETRY", + ConnRetryOptions, { "wait_strategy": "random_exponential", "max_wait": 10, @@ -322,5 +329,9 @@ def on_load(self): opal_common_config.LOG_MODULE_EXCLUDE_LIST ) + if self.DATA_STORE_CONN_RETRY is not None: + # You should use `DATA_UPDATER_CONN_RETRY`, but that's for backwards compatibility + self.DATA_UPDATER_CONN_RETRY = self.DATA_STORE_CONN_RETRY + opal_client_config = OpalClientConfig(prefix="OPAL_") diff --git a/packages/opal-client/opal_client/data/fetcher.py b/packages/opal-client/opal_client/data/fetcher.py index 419ceed7e..81dfffa46 100644 --- a/packages/opal-client/opal_client/data/fetcher.py +++ b/packages/opal-client/opal_client/data/fetcher.py @@ -14,9 +14,9 @@ class DataFetcher: """fetches policy data from backend.""" - # Use as default config the configuration provider by opal_client_config.DATA_STORE_CONN_RETRY + # Use as default config the configuration provider by opal_client_config.DATA_UPDATER_CONN_RETRY # Add reraise as true (an option not available for control from the higher-level config) - DEFAULT_RETRY_CONFIG = opal_client_config.DATA_STORE_CONN_RETRY.toTenacityConfig() + DEFAULT_RETRY_CONFIG = opal_client_config.DATA_UPDATER_CONN_RETRY.toTenacityConfig() DEFAULT_RETRY_CONFIG["reraise"] = True def __init__( diff --git a/packages/opal-server/opal_server/config.py b/packages/opal-server/opal_server/config.py index 1244d4dbf..c610e25f3 100644 --- a/packages/opal-server/opal_server/config.py +++ b/packages/opal-server/opal_server/config.py @@ -296,9 +296,7 @@ class OpalServerConfig(Confi): description="Policy polling refresh interval", ) - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - + def on_load(self): if self.SERVER_PORT is not None and self.SERVER_PORT.isdigit(): # Backward compatibility - if SERVER_PORT is set with a valid value, use it as SERVER_BIND_PORT self.SERVER_BIND_PORT = int(self.SERVER_PORT)