Skip to content

Commit

Permalink
Remove logged warnings for maintenance mode check (#4396)
Browse files Browse the repository at this point in the history
Every time a request hits the app, a `MAINTENANCE_MODE` S3 warning is thrown when it is off. This is going to flood the logs with a not-so-needed warning.
  • Loading branch information
rnovak338 authored Oct 17, 2024
1 parent b0af93d commit a72e525
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def is_maintenance_on():
Get current status of maintenance mode.
"""

return file_exists(S3_FILENAME)
return file_exists(S3_FILENAME, show_warning=False)


def change_maintenance(enabled):
Expand All @@ -37,7 +37,7 @@ def change_maintenance(enabled):

# turn off.
else:
if file_exists(S3_FILENAME):
if file_exists(S3_FILENAME, show_warning=False):
s3_client.delete_object(
Bucket=settings.AWS_PRIVATE_STORAGE_BUCKET_NAME, Key=S3_FILENAME
)
Expand Down
5 changes: 3 additions & 2 deletions backend/dissemination/file_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_filename(report_id, file_type):
raise Http404()


def file_exists(filename):
def file_exists(filename, show_warning=True):
# this client uses the internal endpoint url because we're making a request to S3 from within the app
s3_client = boto3_client(
service_name="s3",
Expand All @@ -57,7 +57,8 @@ def file_exists(filename):

return True
except ClientError:
logger.warn(f"Unable to locate file {filename} in S3!")
if show_warning:
logger.warn(f"Unable to locate file {filename} in S3!")
return False


Expand Down

0 comments on commit a72e525

Please sign in to comment.