zachliu opened a new issue #11663:
URL: https://github.com/apache/airflow/issues/11663
<!--
Welcome to Apache Airflow! For a smooth issue process, try to answer the
following questions.
Don't worry if they're not all applicable; just try to include what you can
:-)
If you need to include code snippets or logs, please put them in fenced code
blocks. If they're super-long, please use the details tag like
<details><summary>super-long log</summary> lots of stuff </details>
Please delete these comment blocks before submitting the issue.
-->
<!--
IMPORTANT!!!
PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
Please complete the next sections or the issue will be closed.
These questions are the first thing we need to know to understand the
context.
-->
**Apache Airflow version**: v1.10.12
**Kubernetes version (if you are using kubernetes)** (use `kubectl
version`): N/A
**Environment**:
- **Cloud provider or hardware configuration**: AWS
- **OS** (e.g. from /etc/os-release): Deployed in ECS Fargate
- **Install tools**: poetry
**What happened**:
I'm having this issue **randomly** (I've calculated the error rate to be
between 1~2% based on the # of ECS tasks running each day) where the
`aws_logs_hook` is unable the obtain existing log entries from Cloudwatch:
```
Traceback (most recent call last):
File
"/usr/local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line
979, in _run_raw_task
result = task_copy.execute(context=context)
File
"/usr/local/lib/python3.8/site-packages/airflow/contrib/operators/ecs_operator.py",
line 152, in execute
self._check_success_task()
File
"/usr/local/lib/python3.8/site-packages/airflow/contrib/operators/ecs_operator.py",
line 175, in _check_success_task
for event in self.get_logs_hook().get_log_events(self.awslogs_group,
stream_name):
File
"/usr/local/lib/python3.8/site-packages/airflow/contrib/hooks/aws_logs_hook.py",
line 81, in get_log_events
response = self.get_conn().get_log_events(logGroupName=log_group,
File "/usr/local/lib/python3.8/site-packages/botocore/client.py", line
337, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.8/site-packages/botocore/client.py", line
656, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceNotFoundException: An error occurred
(ResourceNotFoundException) when calling the GetLogEvents operation: The
specified log stream does not exist.
```
The resource does exist when I check the cloudwatch UI.
Note: this is not the same issue as
https://github.com/apache/airflow/issues/9486 where the log stream name setup
is erroneous.
<!-- (please include exact error messages if you can) -->
**What you expected to happen**:
This could be a simple API glitch when using boto3 to get the log events. We
could add a retry mechanism
[here](https://github.com/apache/airflow/blob/6416d898060706787861ff8ecbc4363152a35f45/airflow/contrib/hooks/aws_logs_hook.py#L81).
<!-- What do you think went wrong? -->
**How to reproduce it**:
Running enough # of ECS task with ECS Operator
<!---
As minimally and precisely as possible. Keep in mind we do not have access
to your cluster or dags.
If you are using kubernetes, please attempt to recreate the issue using
minikube or kind.
## Install minikube/kind
- Minikube https://minikube.sigs.k8s.io/docs/start/
- Kind https://kind.sigs.k8s.io/docs/user/quick-start/
If this is a UI bug, please provide a screenshot of the bug or a link to a
youtube video of the bug in action
You can include images using the .md style of

To record a screencast, mac users can use QuickTime and then create an
unlisted youtube video with the resulting .mov file.
--->
**Anything else we need to know**:
<!--
How often does this problem occur? Once? Every time etc?
Any relevant logs to include? Put them here in side a detail tag:
<details><summary>x.log</summary> lots of stuff </details>
-->
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]