apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
37.07k stars 14.29k forks source link

kubectl token invalid when airflow debug mode enabled #42282

Open jiribroulik opened 1 month ago

jiribroulik commented 1 month ago

Apache Airflow version

2.10.1

If "Other Airflow 2 version" selected, which one?

2.9.2

What happened?

when airflow debug mode is enabled the kubeconfig sh script greps for invalid token thus unable to connect to k8s cluster. I hit the issue in aws eks environment.

What you think should happen instead?

No response

How to reproduce

enable debug mode and then run any kubectl command from your dag. You will get 401 error saying: unable to parse the token, wrong formatting. The reason for this is that the grep get the sessionToken instead of k8s token that authenticates with k8s api.

this is how to change the logging level: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#logging-level

this is the grep that get aws sessionToken instead of k8s api token: https://github.com/apache/airflow/blob/main/airflow/providers/amazon/aws/hooks/eks.py#L89

and this is the token it matches: 'X-Amz-Security-Token': b'IQoJb3JpZ2luX2VjEN3//////////wEaCXVzLWVhc3QtMSJHMEUCIQDGkojyARf8ka1imf4+Nztaon03YN+dEtEYxUvLY1n/FQIgO9eCbrKKQ5h9nY6fZwKKNvd7w48PyQgx4JzCEBbLchgqjAUIFhABGgwzMzEwMTM5ODY5MzYiDHsX+8rDL/scEHQDtSrpBD3IlZLQyF8xB11v57aTFDlqf4b+NPmfGRIxtg5DtJgQAeHXqdWHVG1q/sLP74pzM2TmDVDuoIEU7PHFySR

Operating System

ubuntu

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

Code of Conduct

boring-cyborg[bot] commented 1 month ago

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.