Do not overwrite credentials with the wal-g prefix in the env dir - #1209
Open
daniel-schub wants to merge 2 commits into
Open
daniel-schub wants to merge 2 commits into
daniel-schub wants to merge 2 commits into
Conversation
Since WAL-E support was removed (zalando#1143), the storage name lists in write_walg_environment() no longer start with the WALE_*_PREFIX entry, so write_envdir_names[0] is already the WALG_*_PREFIX. The leftover "Set WALG_*_PREFIX for future compatibility" block still writes to write_envdir_names[1], which now points to a credentials variable: gs_names[1] -> GOOGLE_APPLICATION_CREDENTIALS s3_names[1] -> AWS_ACCESS_KEY_ID As a result the generated bucket prefix is written into the env dir as credentials. On GCS, wal-g tries to open the gs:// URL as a service account key file and fails with "error getting credentials using GOOGLE_APPLICATION_CREDENTIALS environment variable", which breaks archive_command and basebackups for setups that rely on the metadata service (for example GKE Workload Identity). On S3, AWS_ACCESS_KEY_ID is set to the s3:// URL even though AWS_INSTANCE_PROFILE is enabled. The block is obsolete now that the prefix is resolved directly into WALG_*_PREFIX above, so remove it.
daniel-schub
force-pushed
the
fix/walg-envdir-credentials-overwrite
branch
2 times, most recently
from
July 30, 2026 13:41
832d0b3 to
4531f2b
Compare
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.
Problem
configure_spilo.pywrites the generated wal-g bucket prefix into a credentials variable in the wal-g env dir, which breaks backups and WAL archiving whenever credentials come from the cloud metadata service instead of a key file.On GCS,
archive_commandfails with:because the env dir contains:
Cause
Before WAL-E was removed the storage name lists started with the WAL-E prefix, so index
1was the wal-g prefix:After #1143 the lists start with the wal-g prefix:
but the compatibility block that back-filled the wal-g prefix was kept and still writes to index
1:So index
1is nowGOOGLE_APPLICATION_CREDENTIALSfor GCS andAWS_ACCESS_KEY_IDfor S3. The block is also redundant, becausewrite_envdir_names[0]is alreadyWALG_*_PREFIXand is resolved a few lines above.Impact
GOOGLE_APPLICATION_CREDENTIALSmust be unset to fall back to the metadata service.AWS_ACCESS_KEY_IDis set to thes3://URL even thoughAWS_INSTANCE_PROFILE=truewas just enabled because no static keys were provided.The variable is rewritten on every pod start, so it cannot be worked around through the environment.
Fix
Remove the obsolete block.
Verification
Calling
write_walg_environment()with onlyWAL_GS_BUCKET/WAL_S3_BUCKETset and dumping the resulting env dir.Before:
After:
With the variable no longer poisoned,
wal-g backup-listandwal-g wal-pushsucceed again against GCS using metadata-service credentials.flake8 --max-line-length=120 postgres-appliance/scripts/configure_spilo.pyis clean.