Hi,
I created a cluster that backups using wal-g to gcs. However when I try to clone that cluster (to point in time) from gcs it fails.
The source of failure is that envdir /home/postgres/etc/wal-e.d/env-clone-jarin-db-cluster doesn't contain variables that are needed (and are present in /home/postgres/etc/wal-e.d/env.
I can actually make the clone work by manually copying two variables from env to env-clone-jarin-db-cluster - GOOGLE_APPLICATION_CREDENTIALS and USE_WALG_RESTORE.
I use custom postgres-pod-config.yaml to set the variables:
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-pod-config
namespace: default
data:
USE_WALG_BACKUP: true
USE_WALG_RESTORE: true
WALG_GS_PREFIX: gs://jarin-test-backup/spilo/$(SCOPE)
CLONE_WALG_GS_PREFIX: gs://jarin-test-backup/spilo/$(CLONE_SCOPE)
WALE_BACKUP_THRESHOLD_PERCENTAGE: "100"
GOOGLE_APPLICATION_CREDENTIALS: /gcs/backup-google-credentials.json
Is there a way to set env variables in the clone envdir? If not I'd consider it a bug.
Are you trying to clone the cluster to another namespace, maybe? Then I think your config map has to exist in the other namespaces, too, regarding this line.
Nope, same namespace. Also, the config map (and environment variables) is propagated to the container successfully. All the variables are configured correctly in the envdir /home/postgres/etc/wal-e.d/env.
The problem is that cloning uses its own separate envdir /home/postgres/etc/wal-e.d/env-clone-jarin-db-cluster and this is where the variables are missing.
I suppose that the envdir isolation is deliberate (at least to separate CLONE_WALG_GS_PREFIX from WALG_GS_PREFIX), however it is isolated too much. For gcp restore to work, we need GOOGLE_APPLICATION_CREDENTIALS and USE_WALG_RESTORE as well.
ah ok. As of now I don't see if the operator can do something about this separate envdir. @CyberDem0n or @erthalion ?
Seems that I found the answer. Any env variable from postgres-pod-config confmap that starts with CLONE_ is copied to the clone envdir (after being stripped of the CLONE_ prefix). So adding CLONE_WALG_GS_PREFIX and CLONE_GOOGLE_APPLICATION_CREDENTIALS to the postgres-pod-config solved my problem.
Having it mentioned in the documentation would help.
Whaaat?! I did not know about this, sorry. That's def. not very intuitive. Will try to update the docs in this regard. Thanks for keep trying and posting the solution here.
Most helpful comment
Whaaat?! I did not know about this, sorry. That's def. not very intuitive. Will try to update the docs in this regard. Thanks for keep trying and posting the solution here.