Skip to content

feat: Detect broken container images before collisions#35

Merged
Unbreathable merged 3 commits intomainfrom
feat/major-version-detection
Mar 13, 2026
Merged

feat: Detect broken container images before collisions#35
Unbreathable merged 3 commits intomainfrom
feat/major-version-detection

Conversation

@Unbreathable
Copy link
Contributor

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetImageMajorVersion helper 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 when image has 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 on GetImageMajorVersion, consider removing this Split usage entirely (or replace with a safe tag extraction using strings.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 when image has no tag (no :), and it mis-parses images that include a registry port (e.g. registry:5000/postgres:14). Since this function now uses GetImageMajorVersion(image), consider removing the Split or 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.

Unbreathable and others added 2 commits March 12, 2026 20:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Unbreathable Unbreathable requested a review from tiemingo March 12, 2026 19:17
@Unbreathable Unbreathable merged commit 204688a into main Mar 13, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants