Skip to content

Commit 391935b

Browse files
author
Lucas Gameiro
authored
[DPE-5713] Catch wrong parameters exception on bucket create function call (#701)
* add extra try-catch * fix missing tls-ca-chain case
1 parent 3db685b commit 391935b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
[tool.poetry]
55
package-mode = false
6+
requires-poetry = ">=2.0.0"
67

78
[tool.poetry.dependencies]
89
python = "^3.10"

src/backups.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import boto3 as boto3
2020
import botocore
21-
from botocore.exceptions import ClientError
21+
from botocore.exceptions import ClientError, ParamValidationError, SSLError
2222
from charms.data_platform_libs.v0.s3 import (
2323
CredentialsChangedEvent,
2424
S3Requirer,
@@ -284,6 +284,9 @@ def _create_bucket_if_not_exists(self) -> None:
284284
except ClientError:
285285
logger.warning("Bucket %s doesn't exist or you don't have access to it.", bucket_name)
286286
exists = False
287+
except SSLError as e:
288+
logger.error(f"error: {e!s} - Is TLS enabled and CA chain set on S3?")
289+
raise e
287290
if exists:
288291
return
289292

@@ -798,7 +801,7 @@ def _on_s3_credential_changed_primary(self, event: HookEvent) -> bool:
798801

799802
try:
800803
self._create_bucket_if_not_exists()
801-
except (ClientError, ValueError):
804+
except (ClientError, ValueError, ParamValidationError, SSLError):
802805
self._s3_initialization_set_failure(FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE)
803806
return False
804807

0 commit comments

Comments
 (0)