You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "VincentChantreau (via GitHub)" <gi...@apache.org> on 2024/03/07 15:37:07 UTC
[I] Glue Hook not using aws_conn_id for logs access [airflow]
VincentChantreau opened a new issue, #37976:
URL: https://github.com/apache/airflow/issues/37976
### Apache Airflow Provider(s)
amazon
### Versions of Apache Airflow Providers
8.16.0
### Apache Airflow version
2.8.1
### Operating System
Apache Airflow Official Docker Image
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
Deployed on AWS EKS
### What happened
When using the Glue Operator and enabling the verbose parameter, we get the following error.
It's seems that the the GlueHook is not using a LogHook, but rather a newly instancied boto3 client here :
https://github.com/apache/airflow/blob/19ebcac2395ef9a6b6ded3a2faa29dc960c1e635/airflow/providers/amazon/aws/hooks/glue.py#L228
**So this new instance of boto3 client is using the pod ServiceAccount IAM credentials and not the provided Hook (via aws_conn_id) which are differents.**
So when we are using the Operator with the verbose parameter set to True, we get this stack trace:
```
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/providers/amazon/aws/operators/glue.py", line 207, in execute
glue_job_run = self.glue_job_hook.job_completion(self.job_name, self._job_run_id, self.verbose)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/providers/amazon/aws/hooks/glue.py", line 288, in job_completion
ret = self._handle_state(job_run_state, job_name, run_id, verbose, next_log_tokens)
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/providers/amazon/aws/hooks/glue.py", line 325, in _handle_state
self.print_job_logs(
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/providers/amazon/aws/hooks/glue.py", line 269, in print_job_logs
continuation_tokens.output_stream_continuation = display_logs_from(
File "/home/airflow/.local/lib/python3.10/site-packages/airflow/providers/amazon/aws/hooks/glue.py", line 236, in display_logs_from
for response in paginator.paginate(
File "/home/airflow/.local/lib/python3.10/site-packages/botocore/paginate.py", line 269, in __iter__
response = self._make_request(current_kwargs)
File "/home/airflow/.local/lib/python3.10/site-packages/botocore/paginate.py", line 357, in _make_request
return self._method(**current_kwargs)
File "/home/airflow/.local/lib/python3.10/site-packages/botocore/client.py", line 553, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/airflow/.local/lib/python3.10/site-packages/botocore/client.py", line 1009, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.AccessDeniedException: An error occurred (AccessDeniedException) when calling the FilterLogEvents operation: User: arn:aws:sts::***redacted*** is not authorized to perform: logs:FilterLogEvents on resource: arn:aws:logs:***redacted***: because no identity-based policy allows the logs:FilterLogEvents action
```
### What you think should happen instead
The GlueHook should create a LogHook like in the SageMaker hook
https://github.com/apache/airflow/blob/19ebcac2395ef9a6b6ded3a2faa29dc960c1e635/airflow/providers/amazon/aws/hooks/sagemaker.py#L156 that will use the Hook provided when instanciating the Operator via the aws_conn_id
### How to reproduce
1. Create an Airflow AWS Connection with a role ARN different than the one used by the Workers.
2. Execute a GlueJobOperator task with verbose parameter set to True
```
GlueJobOperator(
aws_conn_id=connection_id,
task_id=task_id,
job_name=job_name,
verbose=True,
*args,
**kwargs,
)
```
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Glue Hook not using aws_conn_id for logs access resulting in Error [airflow]
Posted by "VincentChantreau (via GitHub)" <gi...@apache.org>.
VincentChantreau commented on issue #37976:
URL: https://github.com/apache/airflow/issues/37976#issuecomment-1986856593
@eladkal I've submitted a PR to address the issue :)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Glue Hook not using aws_conn_id for logs access [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #37976:
URL: https://github.com/apache/airflow/issues/37976#issuecomment-1983779548
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Glue Hook not using aws_conn_id for logs access resulting in Error [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck closed issue #37976: Glue Hook not using aws_conn_id for logs access resulting in Error
URL: https://github.com/apache/airflow/issues/37976
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org