fix: warn on postgres image change when the implied data directory mismatches the mounted volume - #5005
Open
Siumauricio wants to merge 1 commit into
Open
fix: warn on postgres image change when the implied data directory mismatches the mounted volume#5005Siumauricio wants to merge 1 commit into
Siumauricio wants to merge 1 commit into
Conversation
…tches the mounted volume
Comment on lines
+112
to
+117
| const mounts = (data as any)?.mounts ?? []; | ||
| const dataMount = mounts.find( | ||
| (mount: { type: string; mountPath: string }) => | ||
| mount.type === "volume" && | ||
| POSTGRES_DATA_PATH_REGEX.test(mount.mountPath), | ||
| ); |
Contributor
There was a problem hiding this comment.
Ambiguous data-volume selection
When a Postgres service has another volume under /var/lib/postgresql before its persisted data volume, find selects that unrelated mount for comparison, causing the warning to report the wrong current path or disappear when the unrelated path matches the image expectation.
Knowledge Base Used: Managed Databases
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
The Postgres data-directory mount path is derived from the docker image once at creation (
getMountPath) and persisted as a mount. Changing the image later never reconciles it, so a service can silently become internally inconsistent:postgres:18→ switch toghcr.io/railwayapp-templates/postgres-ssl:18: the volume stays at/var/lib/postgresql/18/dockerbut the image enforces/var/lib/postgresql/data→ crash loop before Postgres starts.postgres:16→ switch topostgres:18: the volume stays at/var/lib/postgresql/databut PG18's PGDATA is/var/lib/postgresql/18/docker, outside the mounted volume → starts with an empty cluster (looks like data loss).Creation-time selection is fine (#3048); the gap is image changes on existing services.
Change
In the database Advanced settings, when editing the Docker Image of a postgres service, compare the data path implied by the typed image against the service's persisted volume mount (only mounts under
/var/lib/postgresql). On mismatch, show a warning explaining that changing the image does not migrate data and pointing to the Volumes section, before the user saves.No behavior change for compatible images, other database types, or custom mount layouts outside
/var/lib/postgresql.Closes #4717
Greptile Summary
This PR adds an Advanced-settings warning when a Postgres image implies a different data directory than the persisted volume mount.
Confidence Score: 4/5
The PR needs a more reliable way to identify the persisted Postgres data volume before merging, because an additional PostgreSQL-tree volume can suppress or misdirect the warning.
The new warning uses an ambiguous first-match lookup even though Postgres services can have multiple arbitrary volume mounts, leaving the incompatible-image scenario reachable without an accurate warning.
Files Needing Attention: apps/dokploy/components/dashboard/postgres/advanced/show-custom-command.tsx
Reviews (1): Last reviewed commit: "fix: warn when the postgres image implie..." | Re-trigger Greptile
Context used: