Skip to content

Commit

Permalink
s3: workaround on-reload memleak when no role is set
Browse files Browse the repository at this point in the history
AxoSyslog leaks an amount of memory every time it's reloaded if an s3
destination is configured. As a quick workaround we partially revert the
patch introducing the use of `boto3.Session` when no `role()` is set.

Signed-off-by: Mate Ory <[email protected]>
  • Loading branch information
orymate committed Oct 1, 2024
1 parent fd5dfb1 commit 8215551
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions modules/python-modules/syslogng/modules/s3/s3_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ def open(self) -> bool:
if self.is_opened():
return True

self.session = Session(
aws_access_key_id=self.access_key if self.access_key != "" else None,
aws_secret_access_key=self.secret_key if self.secret_key != "" else None,
region_name=self.region,
)

if self.role != "":
self.session = Session(
aws_access_key_id=self.access_key if self.access_key != "" else None,
aws_secret_access_key=self.secret_key if self.secret_key != "" else None,
region_name=self.region,
)

# NOTE: The Session.set_credentials always creates a new Credentials object from the given keys.
# NOTE: The DeferredRefreshableCredentials class is a child of RefreshableCredentials which is a
# NOTE: child of the Credentials class.
Expand All @@ -271,10 +271,18 @@ def open(self) -> bool:
whoami = sts.get_caller_identity().get("Arn")
self.logger.info(f"Using {whoami} to access the bucket")

self.client = self.session.client(
service_name="s3",
endpoint_url=self.url if self.url != "" else None,
)
self.client = self.session.client(
service_name="s3",
endpoint_url=self.url if self.url != "" else None,
)
else:
self.client = client(
service_name="s3",
endpoint_url=self.url if self.url != "" else None,
aws_access_key_id=self.access_key if self.access_key != "" else None,
aws_secret_access_key=self.secret_key if self.secret_key != "" else None,
region_name=self.region,
)

is_opened = False
try:
Expand Down

0 comments on commit 8215551

Please sign in to comment.