fix(cli): detect existing pgdata/ subdir when resolving OPENSHIP_PGDATA - #494
Open
santhiprakash wants to merge 1 commit into
Open
fix(cli): detect existing pgdata/ subdir when resolving OPENSHIP_PGDATA#494santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
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
Fixes
resolvePgDataso re-runningopenship up --composeover an existing Postgres data volume that already has the cluster at/var/lib/postgresql/data/pgdatakeepsOPENSHIP_PGDATApointed at thepgdata/subdirectory, instead of defaulting to the volume root and causinginitdb: error: directory ... exists but is not empty.Motivation
dbVolumeExistsonly tells us that the<project>_postgres_datavolume exists; it doesn't say where the cluster is inside it. Since the EPERM fix in #350, fresh installs use apgdata/subdirectory, but older volumes may still have the cluster at the volume root. The previous code returned the root whenever the volume existed, which broke reinstalls over volumes created with the new subdirectory.Closes #487.
Changes
apps/cli/src/lib/compose.tspgDataLocation()to inspect the volume:pgdata/PG_VERSION→subdir, rootPG_VERSION→root, empty →empty, anything else →unknown.resolvePgData()uses the probe to pick the correctOPENSHIP_PGDATApath, and fails loudly when the volume is non-empty but unrecognizable.OPENSHIP_PGDATAenv comment to reflect the new logic.apps/cli/test/unit/compose-pgdata.test.ts(new)pgdata/cluster, legacy root cluster, and an unrecognizable non-empty volume.Verification
Checklist
bun run --cwd apps/cli testandbun run --cwd apps/cli lintpass locally