fix(gcp): fall back to 'host' key when 'clusterHost' missing from DB secret#800
Open
arniechops wants to merge 1 commit intomainfrom
Open
fix(gcp): fall back to 'host' key when 'clusterHost' missing from DB secret#800arniechops wants to merge 1 commit intomainfrom
arniechops wants to merge 1 commit intomainfrom
Conversation
lilyz-ai
approved these changes
Apr 3, 2026
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.
Summary
DB_SECRET_NAMEon GCP, the code only looks forclusterHost/clusterHostRokeys in the secret JSONhostinstead ofclusterHosthostto resolve toNone, resulting in[Errno -2] Name or service not knownDNS failureshostkey whenclusterHost/clusterHostRoare not present in the secretTest plan
DB_SECRET_NAMEset and secret containinghost(notclusterHost)clusterHost/clusterHostRostill work (backwards compatible)Greptile Summary
This PR fixes a DNS resolution failure (
[Errno -2] Name or service not known) that occurred when GCP'sDB_SECRET_NAMEenvironment variable was set and the referenced secret was created by Terraform — which useshostinstead ofclusterHost/clusterHostRoas the key name. The one-line ternary is expanded into anif/elseblock that uses Python'sorshort-circuit to preferclusterHostRo/clusterHostwhen present, then falls back tohost. The fix is backwards-compatible with secrets that already use the original key names.Key points:
orfallback correctly mirrors the precedence described in the PR (preferclusterHost*, fall back tohost).hostkey when the specialised keys are absent — consistent with the on-premises path which already doesDB_HOST_RO or DB_HOST.clusterHost/clusterHostRo.Confidence Score: 4/5
Safe to merge; the change is a targeted, backwards-compatible fallback with no risk of regression for existing secrets.
The logic is straightforward and correct. The
orshort-circuit ensures existing secrets usingclusterHost/clusterHostRoare unaffected, and secrets that only containhostwill now resolve properly. The only gap is a missing comment explaining the two secret formats, which is a style concern and doesn't affect correctness.No files require special attention beyond the single changed block in
model-engine/model_engine_server/db/base.py.Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[get_engine_url called] --> B{cloud_provider == 'gcp'?} B -- No --> C[Other provider path] B -- Yes --> D{DB_SECRET_NAME set?} D -- No --> E[Use env vars DB_HOST_RO / DB_HOST] D -- Yes --> F[Fetch secret from GCP Secret Manager] F --> G{read_only?} G -- Yes --> H["host = creds.get('clusterHostRo') or creds.get('host')"] G -- No --> I["host = creds.get('clusterHost') or creds.get('host')"] H --> J[Build postgresql:// URL] I --> J E --> JPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(gcp): fall back to 'host' key when '..." | Re-trigger Greptile
Context used:
Learnt From
scaleapi/scaleapi#126958