Skip to content

Commit

Permalink
Merge pull request #2069 from open-dynaMIX/healthz_log_cleanup
Browse files Browse the repository at this point in the history
fix(healthz): do not warn about expected events
  • Loading branch information
open-dynaMIX authored Sep 18, 2023
2 parents 1df85e2 + b747c1f commit fb6db63
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion caluma/caluma_core/health_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _check_media_storage_service():

# remove object
storage_client.remove_object(object_name)
assert not storage_client.stat_object(object_name)
assert not storage_client.stat_object(object_name, suppress_warning=True)

return {"ok": True}

Expand Down
8 changes: 6 additions & 2 deletions caluma/caluma_form/storage_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ def __init__(self):
self.bucket = settings.MINIO_STORAGE_MEDIA_BUCKET_NAME

@_retry_on_missing_bucket
def stat_object(self, object_name):
def stat_object(self, object_name, suppress_warning=False):
"""
Get stat of object in bucket.
:param object_name: str
:param suppress_warning: bool
:return: stat response if successful, otherwise None
"""
try:
return self.client.stat_object(self.bucket, object_name)
except S3Error as exc:
log.warning(f"Minio error, cannot stat object '{object_name}': {exc.code}")
if not suppress_warning:
log.warning(
f"Minio error, cannot stat object '{object_name}': {exc.code}"
)
return None

@_retry_on_missing_bucket
Expand Down
4 changes: 4 additions & 0 deletions caluma/caluma_form/tests/test_minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ def test_minio_handle_exceptions(exc_code, caplog, mocker):
assert caplog.messages == [
f"Minio error, cannot stat object 'test_object': {exc_code}"
]
assert len(caplog.messages) == 1
stat = client.stat_object("test_object", suppress_warning=True)
assert stat is None
assert len(caplog.messages) == 1

0 comments on commit fb6db63

Please sign in to comment.