Skip to content

Honor impersonation_chain in deferred Cloud Build tasks - #71644

Merged
potiuk merged 1 commit into
apache:mainfrom
SEPURI-SAI-KRISHNA:fix-cloud-build-trigger-impersonation
Aug 27, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
SEPURI-SAI-KRISHNA:fix-cloud-build-trigger-impersonation

Conversation

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor

CloudBuildCreateBuildTrigger accepts an impersonation_chain, stores it, and
serializes it — but built its hook without it:

def _get_async_hook(self) -> CloudBuildAsyncHook:
    return CloudBuildAsyncHook(gcp_conn_id=self.gcp_conn_id)

So the value travels correctly from CloudBuildCreateBuildOperator all the way into the
triggerer and is then discarded at the point of use. Once a CloudBuildCreateBuildOperator
task defers, its polling calls authenticate as the connection's service account rather than
the impersonated one.

Two ways this surfaces:

  • where impersonation exists because the base account deliberately lacks permission, the
    deferred poll fails with a 403 that does not mention impersonation;
  • where the base account has broader rights, the poll quietly succeeds under an identity
    the Dag author did not select.

The non-deferrable path is unaffected, so switching deferrable off appears to "fix" it.

Worth noting for reviewers: GoogleBaseHook.__init__ falls back to the connection's
impersonation_chain extra when the argument is absent, so deployments that configure
impersonation on the connection were never affected. The bug is limited to impersonation
configured on the operator — which is the documented parameter on every Google operator.

No newsfragment: this is a provider change, and provider changelogs are regenerated from
git log by the release manager.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

The trigger accepted, stored and serialized the impersonation chain but built
its hook without it, so a task that deferred authenticated as the connection's
service account instead of the impersonated one. The synchronous path was
unaffected, which made the divergence hard to spot.
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Aug 15, 2026
@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Contributor Author

Gentle ping on this one, it's been open since 12 August with no review yet.

It's a small change: the Cloud Build trigger builds its own hook on deferral and never receives the operator's impersonation_chain, so a deferred build polls as the default service account rather than the impersonated one. Two
files, +23/-1, CI green.

Happy to rebase or split it differently if that would help review.

@potiuk
potiuk merged commit 49c1e07 into apache:main Aug 27, 2026
86 checks passed
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
The trigger accepted, stored and serialized the impersonation chain but built
its hook without it, so a task that deferred authenticated as the connection's
service account instead of the impersonated one. The synchronous path was
unaffected, which made the divergence hard to spot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants