Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(healthz): do not warn about expected events #2069

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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