Fix #60269: Replace non-POSIX 'source' with '.' in EKS hook#61441
Open
idrisakorede wants to merge 3 commits intoapache:mainfrom
Open
Fix #60269: Replace non-POSIX 'source' with '.' in EKS hook#61441idrisakorede wants to merge 3 commits intoapache:mainfrom
idrisakorede wants to merge 3 commits intoapache:mainfrom
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
f982627 to
3adc5a2
Compare
vincbeck
reviewed
Feb 4, 2026
vincbeck
approved these changes
Feb 4, 2026
Contributor
|
I dont think I talk to a human but the code looks good |
Author
Thanks. But i don't get the human reference |
- Replace 'source' with POSIX-compliant '.' operator in COMMAND template - Update deprecated v1alpha1 to v1beta1 Kubernetes API version - Add shell compatibility tests for dash/POSIX shells - Update comment to reflect POSIX compliance Fixes apache#60269
Reduced to single assertion test as suggested by @vincbeck
f89341c to
cbc5481
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #60269: Replace non-POSIX 'source' with '.' in EKS hook
Problem
EksPodOperator fails with 401 Unauthorized errors when running on Debian/Ubuntu-based containers (Astronomer Runtime, official Airflow Docker images, MWAA, etc.).
Root Cause
The issue occurs in
airflow/providers/amazon/aws/hooks/eks.pyline 83, where theCOMMANDtemplate usessource:source {credentials_file}The problem:
sourceis a bash-specific builtin command, not a POSIX standard command. On Debian/Ubuntu systems,/bin/shis symlinked todash(not bash), which doesn't recognizesource:$ sh -c 'source /dev/null' sh: 1: source: not foundThis causes the credential loading to fail silently, resulting in 401 Unauthorized errors when the EKS token generation falls back to an empty credential chain.
Why This Is Hard to Detect
The bug is masked during local development when developers have
~/.aws/credentialsmounted in containers:source {credentials_file}fails silently (stderr not checked)eks_get_token.pyfalls back to boto3's default credential chain~/.aws/credentials→ token generation succeeds ✅In production/cloud environments without
~/.aws/directory, credentials are only available via the temp file that failed to source, causing 401 errors ❌Solution
This PR implements two fixes:
1. Use POSIX-Compliant Dot Operator
Replace
sourcewith.(dot operator), which is POSIX-compliant and works in all shells (bash, dash, sh):2. Update Deprecated Kubernetes API Version
Update the authentication API version from deprecated
v1alpha1tov1beta1:Note:
v1alpha1was deprecated in Kubernetes 1.24 and removed in 1.28.Changes Made
Testing
Added comprehensive test coverage in
test_eks.py:New Test Classes
TestEksHookShellCompatibility
test_command_template_is_posix_compliant: Verifies the template uses.notsourcetest_credential_loading_works_with_dash: Confirms credentials load correctly with dash shelltest_source_command_fails_with_dash: Documents the original bugTestEksHookKubernetesVersion
test_uses_stable_kubernetes_api_version: Ensures we're not using deprecated v1alpha1Manual Testing
Verified in Breeze (Debian-based container):
Impact
This fix resolves 401 Unauthorized errors for all Debian/Ubuntu-based Airflow deployments:
/bin/shisdashThe change is backward-compatible as the
.operator works in both bash and dash shells.Fixes #60269
Was generative AI tooling used to co-author this PR?