Repository navigation
Conversation
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
|
We had a discussion about this topic recently in another PR... need to take a look for this. We do not want to have provider (=aws) specific code in the generic CNCF provider. |
|
Ah, it was this here: #61936 |
This comment was marked as spam.
This comment was marked as spam.
jscheffl
left a comment
There was a problem hiding this comment.
If you request feedback: Then like in the previous PR this is a race condition specifically as needed for AWS credentials. Can you therefore please make this into the AWS specific provider package? I think the generic CNCF provider (in my view) should be neutral to any potential race condition of a specific other provider feature.
I assume it migt be best in EcsHook as the right place.
Pre-create ~/.aws/cli/cache in EksHook.generate_config_file() to prevent a FileExistsError when parallel tasks on the same Celery worker invoke aws eks get-token simultaneously. Older botocore versions call os.makedirs() without exist_ok=True, causing a race. The fix lives in the Amazon provider (not the CNCF Kubernetes provider) because the race condition is specific to the AWS CLI cache directory. closes: apache#60943
6e84965 to
09eee0a
Compare
This comment was marked as spam.
This comment was marked as spam.
jscheffl
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the rework.
Would kindly request one of the AWS provider maintainers for another pair of eyes.
This comment was marked as spam.
This comment was marked as spam.
|
I think you should not call for reviews on individual contributors. This limits your visibility. While Jarek is one of the most active this is a change rather in AWS territory, so I did not merge looking for some AWS maintainer review. @o-nikolas Can you make a review? |
|
The comment in #60943 (comment) suggest this issue is already resolved in botocore 1.40.2 airflow/providers/amazon/pyproject.toml Line 69 in be8252e I don't understand what are we fixing here? I am aware that previous attempts were to fix the issue in K8s provider (for users who use newer versions of k8s provider with older versions of amazon provider) but since that approach was a no go I don't understand the benefit of this PR |
|
Agreed with @eladkal here, I'll close this one unless @Vamsi-klu would like to make another argument as to why we need it. |
Summary
Pre-create cache directories used by exec-based authentication plugins before
establishing the Kubernetes API connection in
KubernetesHook.get_conn().When multiple tasks run concurrently on the same Celery worker, each may invoke
an exec-based credential plugin (e.g., AWS IAM authenticator) in parallel. Some
plugin implementations create their cache directories with
os.makedirs()without
exist_ok=True, which causes aFileExistsErrorrace condition whentwo processes attempt the creation simultaneously.
This fix defensively pre-creates known cache directories so they already exist
by the time any exec plugin runs.
Co-contributors: @codingrealitylabs @girlcoder-gaming
closes: #60943
Test plan
test_creates_cache_dirs— verifies directories are created when missingtest_no_error_when_dir_already_exists— verifies no error when dirs already existtest_get_conn_calls_ensure_cache_dirs— verifiesget_conn()calls the pre-creation functionWas generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Opus 4.6) following the guidelines