There is a bug in connecting to EKS using the airflow.providers.amazon.aws.operators.eks library in China. #45368
Closed
1 of 2 tasks
Labels
area:providers
good first issue
kind:bug
This is a clearly a bug
provider:amazon-aws
AWS/Amazon - related issues
Apache Airflow Provider(s)
amazon
Versions of Apache Airflow Providers
9.2.0
Even though I'm using the latest version, I think this bug exists in all historical versions.
Apache Airflow version
2.10.1
Operating System
Amazon Linux 2023
Deployment
Amazon (AWS) MWAA
Deployment details
You can reproduce this bug stably without any customization.
What happened
Their dag script to connect to EKS cluster using [from airflow.providers.amazon.aws.operators.eks import EksPodOperator] returned 401 .
script:
error log:
What you think should happen instead
Here's the investigation I've done:
Examining the source code for EksPodOperator shows that this class automatically generates a kube_config file if no external kube_config file is specified during initialization:
There seems to be a problem with this auto-generated kube_config file, so I printed the contents of the file in debug and examined the source code associated with it generating the contents of the file:
https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_modules/airflow/providers/amazon/aws/hooks/eks.html
Here it is executing a bash command, searching the COMMAND variable you can see the exact command executed as follows, you can see it is getting the eks token.
https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_modules/airflow/providers/amazon/aws/utils/eks_get_token.html
access_token from eks_hook.fetch_access_token_for_cluster(args.cluster_name) Check out the implementation of the eks_hook.fetch_access_token_for_cluster method: https://airflow.apache.org/docs/apache-airflow-providers-amazon/stable/_modules/airflow/providers/amazon/aws/hooks/eks.html
The address to access STS here points to the global address, not the China STS service address. So the eks token obtained cannot be used in China. The sts_url that should be used in China is f “https://sts.{session.region_name}.amazonaws.com.cn/?Action=GetCallerIdentity&Version=2011-06-15”
How to reproduce
You can easily reproduce this using the dag script above, provided you use the identity credentials of your China AWS account.
Anything else
no
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: