Pass impersonation_chain to the Dataflow trigger for Beam Java/Python operators - #72210
Open
afonsojanu wants to merge 1 commit into
Open
Conversation
… operators BeamRunJavaPipelineOperator and BeamRunPythonPipelineOperator both read self.dataflow_config.impersonation_chain when running the pipeline itself, but when deferrable mode kicks in and they build the trigger_args dict for DataflowJobStatusTrigger or DataflowJobStateCompleteTrigger, that field never makes it in. So a job that's meant to poll for completion under an impersonated service account ends up polling with whatever credentials the worker happens to have instead. Added impersonation_chain to both trigger_args dicts, and a test for each operator that checks the trigger actually receives it.
|
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
|
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.
Fixes #72135
BeamRunJavaPipelineOperator and BeamRunPythonPipelineOperator both use
self.dataflow_config.impersonation_chainwhen running the pipeline directly, but when deferrable mode is on and they buildtrigger_argsforDataflowJobStatusTrigger/DataflowJobStateCompleteTrigger, that value never gets passed through. So a deferred task ends up polling Dataflow for completion with whatever credentials the worker has, not the impersonated account the operator was configured with.Both trigger classes already accept
impersonation_chainin their constructor (seeairflow/providers/google/cloud/triggers/dataflow.py), so this is just a matter of including it in the dict the operators build.While looking at this I noticed the exact same pattern shows up in both operators, the Java one that the issue reports and the Python one that wasn't reported but has the identical bug, so I fixed both.
I added a test for each operator asserting the trigger it raises actually carries the configured impersonation_chain. I couldn't run the full provider test suite locally since it needs the breeze dev environment, but I verified the fix against the real installed package by patching in the modified module and driving it through the exact same code path the tests exercise, confirming it fails without the change (impersonation_chain comes through as None) and passes with it.
Ran ruff on both changed files with no issues.