Skip to content

Commit

Permalink
[DPE-5713] Catch wrong parameters exception on bucket create function…
Browse files Browse the repository at this point in the history
… call (#701)

* add extra try-catch

* fix missing tls-ca-chain case
  • Loading branch information
lucasgameiroborges authored Jan 19, 2025
1 parent 3db685b commit 391935b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

[tool.poetry]
package-mode = false
requires-poetry = ">=2.0.0"

[tool.poetry.dependencies]
python = "^3.10"
Expand Down
7 changes: 5 additions & 2 deletions src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

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

try:
self._create_bucket_if_not_exists()
except (ClientError, ValueError):
except (ClientError, ValueError, ParamValidationError, SSLError):
self._s3_initialization_set_failure(FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE)
return False

Expand Down

0 comments on commit 391935b

Please sign in to comment.