feat: Detect broken container images before collisions#35
Merged
Unbreathable merged 3 commits intomainfrom Mar 13, 2026
Merged
Conversation
containers is blocked
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes Docker image major-version parsing for service containers, uses it to validate supported Postgres versions and detect incompatible container re-creations, and adds unit tests for the new parsing helper.
Changes:
- Add
GetImageMajorVersionhelper to extract a major version from Docker image tags and add unit tests for it. - Update Postgres drivers to validate supported versions via parsed major version.
- Prevent reusing volumes across container re-creations when the existing container’s image major version differs from the new image.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/databases/postgres/postgres.go | Switch Postgres 18 driver’s version check to compare parsed major versions. |
| pkg/databases/postgres-legacy/postgres_legacy.go | Switch Postgres 14–17 legacy driver’s version check to compare parsed major versions. |
| mrunner/services/containers.go | Return image name from recoverMounts, add major-version mismatch protection, and add GetImageMajorVersion. |
| mrunner/services/containers_test.go | Add table-driven tests for GetImageMajorVersion. |
| mrunner/runner_deploy.go | Adjust image pull progress/success logging. |
| examples/scripts/go.mod | Remove indirect github.com/lib/pq dependency from examples module. |
| examples/scripts/go.sum | Remove github.com/lib/pq sums from examples module. |
Comments suppressed due to low confidence (2)
pkg/databases/postgres/postgres.go:57
imageVersion := strings.Split(image, ":")[1]can panic whenimagehas no tag (no:), and it also mis-parses images that include a registry port (e.g.registry:5000/postgres:18). Since this driver now relies onGetImageMajorVersion, consider removing thisSplitusage entirely (or replace with a safe tag extraction usingstrings.LastIndex) and make the unsupported-version log message use the parsed major/tag safely.
func NewDriver(image string) *PostgresDriver {
imageVersion := strings.Split(image, ":")[1]
// Supported (confirmed and tested) major versions for this Postgres driver
var supportedPostgresVersions = []int{18}
// Do a quick check to make sure the image version is actually supported
supported := false
imageMajor := mservices.GetImageMajorVersion(image)
for _, version := range supportedPostgresVersions {
if imageMajor == version {
supported = true
}
}
if !supported {
pgLog.Fatalln("ERROR: Version", imageVersion, "is currently not supported.")
}
pkg/databases/postgres-legacy/postgres_legacy.go:55
imageVersion := strings.Split(image, ":")[1]can panic whenimagehas no tag (no:), and it mis-parses images that include a registry port (e.g.registry:5000/postgres:14). Since this function now usesGetImageMajorVersion(image), consider removing theSplitor switching to a safe tag extraction (strings.LastIndex) and ensure the unsupported-version error prints the correct tag/major.
func NewDriver(image string) *PostgresDriver {
imageVersion := strings.Split(image, ":")[1]
// Supported (confirmed and tested) major versions for this Postgres driver
var supportedPostgresVersions = []int{14, 15, 16, 17}
// Do a quick check to make sure the image version is actually supported
supported := false
imageMajor := mservices.GetImageMajorVersion(image)
for _, version := range supportedPostgresVersions {
if imageMajor == version {
supported = true
}
}
if !supported {
pgLegacyLog.Fatalln("ERROR: Version", imageVersion, "is currently not supported.")
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tiemingo
approved these changes
Mar 13, 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.
Adds a check to make it so when the major version of the current container and the new container is different, an error will be thrown instead of the container being started likely causing a crash.
Read more in the issue.
Closing #34.