diff --git a/main.py b/main.py index 512b83a27..fc27106da 100644 --- a/main.py +++ b/main.py @@ -72,10 +72,16 @@ def setup_worker(): storage_client = get_storage_client() minio_config = get_config("services", "minio") bucket_name = get_config("services", "minio", "bucket", default="archive") + auto_create_bucket = get_config( + "services", "minio", "auto_create_bucket", default=False + ) region = minio_config.get("region", "us-east-1") try: - storage_client.create_root_storage(bucket_name, region) - log.info("Initializing bucket %s", bucket_name) + # note that this is a departure from the old default behavior. + # This is intended as the bucket will exist in most cases where IAC or manual setup is used + if auto_create_bucket: + storage_client.create_root_storage(bucket_name, region) + log.info("Initializing bucket %s", bucket_name) except BucketAlreadyExistsError: pass diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 079baa204..4c6348fde 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -27,11 +27,12 @@ def test_run_empty_config( assert not mock_storage.root_storage_created res = setup_worker() assert res is None - assert mock_storage.root_storage_created + assert not mock_storage.root_storage_created assert mock_storage.config == {} mock_license_logging.assert_called_once() + @mock.patch("main.startup_license_logging") @mock.patch("main.start_prometheus") def test_sys_path_append_on_enterprise(