From 8d4308b4c31148fab550a1d328fc3f0e60985e7a Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Wed, 19 Feb 2025 16:19:36 -0600 Subject: [PATCH 1/2] chore: tweak settings imports --- dev/deploy-to-container/settings_local.py | 2 +- dev/diff/settings_local.py | 2 +- dev/tests/settings_local.py | 2 +- docker/configs/settings_local.py | 2 +- ietf/settings_test.py | 2 +- k8s/settings_local.py | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dev/deploy-to-container/settings_local.py b/dev/deploy-to-container/settings_local.py index aaee07f0eab..e878206bd50 100644 --- a/dev/deploy-to-container/settings_local.py +++ b/dev/deploy-to-container/settings_local.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from ietf.settings import * # pyflakes:ignore -from ietf.settings import STORAGES, MORE_STORAGE_NAMES +from ietf.settings import STORAGES, MORE_STORAGE_NAMES, BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS import botocore.config ALLOWED_HOSTS = ['*'] diff --git a/dev/diff/settings_local.py b/dev/diff/settings_local.py index c52ee6d8abb..9e0806a8a6f 100644 --- a/dev/diff/settings_local.py +++ b/dev/diff/settings_local.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from ietf.settings import * # pyflakes:ignore -from ietf.settings import STORAGES, MORE_STORAGE_NAMES +from ietf.settings import STORAGES, MORE_STORAGE_NAMES, BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS import botocore.config ALLOWED_HOSTS = ['*'] diff --git a/dev/tests/settings_local.py b/dev/tests/settings_local.py index db1676d4847..f2166053a7a 100644 --- a/dev/tests/settings_local.py +++ b/dev/tests/settings_local.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from ietf.settings import * # pyflakes:ignore -from ietf.settings import STORAGES, MORE_STORAGE_NAMES +from ietf.settings import STORAGES, MORE_STORAGE_NAMES, BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS import botocore.config ALLOWED_HOSTS = ['*'] diff --git a/docker/configs/settings_local.py b/docker/configs/settings_local.py index 19e1a566201..46833451c1e 100644 --- a/docker/configs/settings_local.py +++ b/docker/configs/settings_local.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from ietf.settings import * # pyflakes:ignore -from ietf.settings import STORAGES, MORE_STORAGE_NAMES +from ietf.settings import STORAGES, MORE_STORAGE_NAMES, BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS import botocore.config ALLOWED_HOSTS = ['*'] diff --git a/ietf/settings_test.py b/ietf/settings_test.py index 9cdb4350971..fe77152d426 100755 --- a/ietf/settings_test.py +++ b/ietf/settings_test.py @@ -14,7 +14,7 @@ import shutil import tempfile from ietf.settings import * # pyflakes:ignore -from ietf.settings import STORAGES, TEST_CODE_COVERAGE_CHECKER, MORE_STORAGE_NAMES +from ietf.settings import STORAGES, TEST_CODE_COVERAGE_CHECKER, MORE_STORAGE_NAMES, BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS import botocore.config import debug # pyflakes:ignore debug.debug = True diff --git a/k8s/settings_local.py b/k8s/settings_local.py index 8f89894d1c9..0ef2593b7ed 100644 --- a/k8s/settings_local.py +++ b/k8s/settings_local.py @@ -7,6 +7,7 @@ from ietf import __release_hash__ from ietf.settings import * # pyflakes:ignore +from ietf.settings import BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS def _multiline_to_list(s): From a661280a7e9256b62f95859c994de21893af9541 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 19 Feb 2025 19:27:50 -0400 Subject: [PATCH 2/2] chore: simplify k8s/settings_local.py imports --- k8s/settings_local.py | 45 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/k8s/settings_local.py b/k8s/settings_local.py index 0ef2593b7ed..912607f4669 100644 --- a/k8s/settings_local.py +++ b/k8s/settings_local.py @@ -7,7 +7,8 @@ from ietf import __release_hash__ from ietf.settings import * # pyflakes:ignore -from ietf.settings import BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS +from ietf.settings import STORAGES, MORE_STORAGE_NAMES, BLOBSTORAGE_CONNECT_TIMEOUT, BLOBSTORAGE_READ_TIMEOUT, BLOBSTORAGE_MAX_ATTEMPTS +import botocore.config def _multiline_to_list(s): @@ -325,29 +326,21 @@ def _multiline_to_list(s): _blob_store_read_timeout = ( os.environ.get("DATATRACKER_BLOB_STORE_READ_TIMEOUT", BLOBSTORAGE_READ_TIMEOUT) ) -try: - from ietf.settings import MORE_STORAGE_NAMES -except ImportError: - pass # Don't fail if MORE_STORAGE_NAMES is not there, just don't configure it -else: - from ietf.settings import STORAGES # do fail if these aren't found! - import botocore.config - - for storage_name in MORE_STORAGE_NAMES: - STORAGES[storage_name] = { - "BACKEND": "ietf.doc.storage_backends.CustomS3Storage", - "OPTIONS": dict( - endpoint_url=_blob_store_endpoint_url, - access_key=_blob_store_access_key, - secret_key=_blob_store_secret_key, - security_token=None, - client_config=botocore.config.Config( - signature_version="s3v4", - connect_timeout=_blob_store_connect_timeout, - read_timeout=_blob_store_read_timeout, - retries={"total_max_attempts": _blob_store_max_attempts}, - ), - bucket_name=f"{_blob_store_bucket_prefix}{storage_name}".strip(), - ietf_log_blob_timing=_blob_store_enable_profiling, +for storage_name in MORE_STORAGE_NAMES: + STORAGES[storage_name] = { + "BACKEND": "ietf.doc.storage_backends.CustomS3Storage", + "OPTIONS": dict( + endpoint_url=_blob_store_endpoint_url, + access_key=_blob_store_access_key, + secret_key=_blob_store_secret_key, + security_token=None, + client_config=botocore.config.Config( + signature_version="s3v4", + connect_timeout=_blob_store_connect_timeout, + read_timeout=_blob_store_read_timeout, + retries={"total_max_attempts": _blob_store_max_attempts}, ), - } + bucket_name=f"{_blob_store_bucket_prefix}{storage_name}".strip(), + ietf_log_blob_timing=_blob_store_enable_profiling, + ), + }