Skip to content

EKSHook fails to fetch token in Airflow 3.0 #50771

Closed

Description

@andrewhharmon

Apache Airflow Provider(s)

amazon

Versions of Apache Airflow Providers

9.7.0

Apache Airflow version

3.0.0

Operating System

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"

Deployment

Astronomer

Deployment details

We use astronomer. this seemed to work ok with local dev but not when deployed to the cluster. Perhaps that's bc of different executor being used locally vs being deployed?

What happened

After upgrading to Airflow 3.0, the EksPodOperator started failing. It appears that its hook fails to fetch a token to auth to the K8s Server. This is bc the mechanism for fetching the token runs a script in a sub process. This script import the airflow hook. Bc it's in a separate process, it runs the airflow initialization step and fails initializing the database.

from airflow.providers.amazon.aws.hooks.eks import EksHook

What you think should happen instead

Properly fetch a token and connect to EKS

How to reproduce

Use the EKSPodOperator to run an Airflow task.

Anything else

As a workaround I created a custom hook/operator that doesn't use this script, but instead uses the aws cli python library to fetch the token. This works but requires the added dependency.

Also, I know Airflow technically isn't supported on MacOs, but the grep command used to create the Kubeconfig file uses the -P flag which isn't supported on MacOs. This made troubleshooting difficult as that was a red hearing.. but again, macOS isn't technically supported.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    on May 19, 2025
  2. boring-cyborg commented on May 19, 2025

    @boring-cyborg

    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.

  3. added
    needs-triage
    on May 19, 2025
  4. andrewhharmon commented on May 19, 2025

    @andrewhharmon
    ContributorAuthor

    oh, I also tried setting the env _AIRFLOW__AS_LIBRARY for the subprocess running the script. It got passed the db error, but failed on something about plugins dir and at that point wasn't sure what else to try.

  5. andrewhharmon commented on May 19, 2025

    @andrewhharmon
    ContributorAuthor

    it also appeared that a kuberentes_default connection was required even though in reality it shouldn't use that it uses an aws connection. perhaps worth taking a look at that as well?

  6. gopidesupavan commented on May 20, 2025

    @gopidesupavan
    Member

    Can you set this env variable os.environ["PYTHON_OPERATORS_VIRTUAL_ENV_MODE"] = "1" see if that works ? I will have to look eks, will check it soon not in next two days.

  7. o-nikolas commented on May 30, 2025

    @o-nikolas
    Contributor

    Can you set this env variable os.environ["PYTHON_OPERATORS_VIRTUAL_ENV_MODE"] = "1" see if that works ? I will have to look eks, will check it soon not in next two days.

    I tried this, and perhaps I didn't put it in the right spot, but the tests still fail 😢

  8. added
    provider:amazon
    and removed
    needs-triage
    on Jun 1, 2025
  9. gopidesupavan commented on Jun 2, 2025

    @gopidesupavan
    Member

    Can you set this env variable os.environ["PYTHON_OPERATORS_VIRTUAL_ENV_MODE"] = "1" see if that works ? I will have to look eks, will check it soon not in next two days.

    I tried this, and perhaps I didn't put it in the right spot, but the tests still fail 😢

    ah unfortunately dont have eks to try and test.

    The idea is to not initialise the db session, we have this issue one of the python operators and introduced that variable which will prevent re initialisation here https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/settings.py#L618

  10. o-nikolas commented on Jun 3, 2025

    @o-nikolas
    Contributor

    Fixed in #51333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providersgood first issuekind:bugprovider:amazon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions