Skip to content

Commit

Permalink
Rename DATA_STORE_CONN_RETRY -> DATA_UPDATER_CONN_RETRY
Browse files Browse the repository at this point in the history
With backwards compatibility
  • Loading branch information
roekatz committed Mar 13, 2024
1 parent 400195c commit 2d86d5f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion documentation/docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion packages/opal-client/opal_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
)
Expand All @@ -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,
Expand Down Expand Up @@ -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_")
4 changes: 2 additions & 2 deletions packages/opal-client/opal_client/data/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
4 changes: 1 addition & 3 deletions packages/opal-server/opal_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2d86d5f

Please sign in to comment.