fix(ingestion): supply GCP credentials in a runtime that has none - #841
Merged
Conversation
With the import fixed, database_connectivity reaches the Cloud SQL connector and fails on DefaultCredentialsError. Dagster+ Serverless runs outside GCP, so there is no metadata server and google.auth.default() finds nothing. The service account key travels as a Dagster+ secret and is written to a file at runtime, because GOOGLE_APPLICATION_CREDENTIALS names a path rather than holding a value. The file is mode 600 in the process temporary directory, which the container discards with the run. Called before importing db.engine rather than after: that module builds its connector at import time and resolves credentials right then, so doing it afterwards would be too late. The dlt pipeline calls it too -- gcsfs resolves credentials the same way, so the raw zone would have failed identically once the loader got that far. Existing credentials are never shadowed, so a developer's gcloud login is used as-is. An unset key is not an error: locally google.auth finds its own, and in Serverless it fails loudly, which is correct in both cases. A path supplied instead of the key itself is rejected with a message saying so, since that mistake would otherwise surface deep inside google.auth. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Coverage✅ 79.28% total — gate is 75%. Coverage for the Python files changed in this PR
|
Contributor
|
Your pull request is automatically being deployed to Dagster Cloud.
|
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.
The import failure is fixed —
database_connectivitynow reaches the Cloud SQLconnector, which fails on
DefaultCredentialsError. Dagster+ Serverless runsoutside GCP, so there is no metadata server and
google.auth.default()findsnothing.
Approach
The service account key travels as a Dagster+ secret and is written to a file at
runtime, because
GOOGLE_APPLICATION_CREDENTIALSnames a path rather thanholding a value. Mode 600, in the process temporary directory, discarded with
the run.
Ordering matters. It runs before importing
db.engine— that modulebuilds its connector at import time and resolves credentials right then, so
doing it afterwards would be too late. The dlt pipeline calls it too:
gcsfsresolves credentials the same way, so the raw zone would have failed identically
once the loader got that far. Fixing one and not the other would just move the
error.
Behaviour
GOOGLE_APPLICATION_CREDENTIALSalready setgoogle.authfinds its own; in Serverless it fails loudly, which is correctgoogle.authSix tests cover these. 48 pass overall.
Before this helps
A key has to exist — Terraform deliberately does not mint one, since that would
put a long-lived credential in state:
Then export it as
INGESTION_GCP_CREDENTIALS_JSONand run the new phase:Still ahead
After this,
database_connectivityshould authenticate and fail on the missingPostgres role —
terraform applywithcloud_sql_instanceset, theningestion_role.sqlwith the IAMCREATE ROLElines uncommented.🤖 Generated with Claude Code