aws / amazon-mwaa-docker-images

Apache License 2.0
27 stars 11 forks source link

fix: checking for empty string log_group_arn #65

Closed agupta01 closed 5 months ago

agupta01 commented 5 months ago

Issue #, if available: When the MWAA__LOGGING__AIRFLOW_*_LOG_GROUP_ARN are set to empty strings, the logging configs are unable to parse them. This results in the following error:

mwaa-280-webserver  | CloudWatch logging is disabled for SubprocessLogHandler
mwaa-280-webserver  | Traceback (most recent call last):
mwaa-280-webserver  |   File "/python/mwaa/logging/utils.py", line 19, in parse_arn
mwaa-280-webserver  |     log_group = split_arn[6]
mwaa-280-webserver  |                 ~~~~~~~~~^^^
mwaa-280-webserver  | IndexError: list index out of range
mwaa-280-webserver  |
mwaa-280-webserver  | The above exception was the direct cause of the following exception:
mwaa-280-webserver  |
mwaa-280-webserver  | Traceback (most recent call last):
mwaa-280-webserver  |   File "/usr/local/lib/python3.11/logging/config.py", line 573, in configure
mwaa-280-webserver  |     handler = self.configure_handler(handlers[name])
mwaa-280-webserver  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mwaa-280-webserver  |   File "/usr/local/lib/python3.11/logging/config.py", line 757, in configure_handler
mwaa-280-webserver  |     result = factory(**kwargs)
mwaa-280-webserver  |              ^^^^^^^^^^^^^^^^^
mwaa-280-webserver  |   File "/python/mwaa/logging/cloudwatch_handlers.py", line 428, in __init__
mwaa-280-webserver  |     super().__init__(log_group_arn, kms_key_arn, enabled)
mwaa-280-webserver  |   File "/python/mwaa/logging/cloudwatch_handlers.py", line 59, in __init__
mwaa-280-webserver  |     self.log_group_name, self.region_name = parse_arn(log_group_arn)
mwaa-280-webserver  |                                             ^^^^^^^^^^^^^^^^^^^^^^^^
mwaa-280-webserver  |   File "/python/mwaa/logging/utils.py", line 24, in parse_arn
mwaa-280-webserver  |     raise RuntimeError(f"Invalid log group ARN: {log_group_arn}") from ex
mwaa-280-webserver  | RuntimeError: Invalid log group ARN:

Description of changes: This PR changes the null check for the arn to if log_group_arn, so that if log_group_arn = "", it will not pass the check and we will not set up logging.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.