Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: bump docker-compose to v2.24.5, set healthcheck.start_interval to 1s in Docker v25+ #5745

Merged
merged 5 commits into from Feb 2, 2024

Conversation

stasadev
Copy link
Member

@stasadev stasadev commented Jan 26, 2024

The Issue

It's time to update docker-compose.

The most significant change in v2.24.0:

Breaking change ⚠️
service hash computation logic has been updated to fully ignore replicas/scale. Due to this change, after upgrade all services will be recreated.

How This PR Solves The Issue

  • Bumps docker-compose
  • Adds a new custom function templateCanUse(feature string) for use in templates, which can perform more complex checks on the go side.
  • Adds healthcheck.start_interval (default is 5s and we use 1s) when it is really available (only for Docker Engine API 1.44+, i.e. for Docker v25+) https://docs.docker.com/engine/reference/builder/#healthcheck

@github-actions github-actions bot added dependencies Pull requests that update a dependency file maintenance labels Jan 26, 2024
Copy link

github-actions bot commented Jan 26, 2024

@stasadev
Copy link
Member Author

The new docker-compose has new aggressive checks, tests are failing:

can't set healthcheck.start_interval as feature require Docker Engine v25 or later

Related issue:

@rfay
Copy link
Member

rfay commented Jan 26, 2024

Pretty weird! Nice job chasing it. But it needs to be fixed somewhere or we're stuck with old compose. Seems like compose bug.

@stasadev
Copy link
Member Author

Yes, I will see what can be changed.

@stasadev stasadev changed the title build: bump docker-compose to v2.24.3 build: bump docker-compose to v2.24.4 Jan 30, 2024
@stasadev stasadev changed the title build: bump docker-compose to v2.24.4 build: bump docker-compose to v2.24.5 Jan 30, 2024
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, I'm probably going to be OK with it, but it does look fragile for the future. I'd sure rather it be fixed in docker-compose. Interested in doing a PR there?

@@ -747,6 +747,7 @@ type composeYAMLVars struct {
Hostnames []string
Timezone string
ComposerVersion string
DockerVersion string
Copy link
Member

Choose a reason for hiding this comment

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

Let's use DockerEngineVersion here

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to use a different technique: introduce a new custom function templateCanUse(feature string) for use in templates, which can perform more complex checks on the go side.

@stasadev
Copy link
Member Author

I'd sure rather it be fixed in docker-compose.

I think they made a reasonable change with error, because healthcheck.start_interval didn't work before Docker v25 and should be considered an invalid option.

it does look fragile for the future

Agree, and for this reason I added a check specifically for the Docker API version https://docs.docker.com/engine/api/#api-version-matrix
This API version (e.g. 1.44) is much more stable than the Docker version (e.g. 25.0.1). The same comparison is used inside docker-compose.

@stasadev
Copy link
Member Author

Looking deeper into the code base, there is a check for the minimum version of Docker to use with DDEV:

// DockerVersionConstraint is the current minimum version of Docker required for DDEV.
// See https://godoc.org/github.com/Masterminds/semver#hdr-Checking_Version_Constraints
// for examples defining version constraints.
// REMEMBER TO CHANGE docs/ddev-installation.md if you touch this!
// The constraint MUST HAVE a -pre of some kind on it for successful comparison.
// See https://github.com/ddev/ddev/pull/738.. and regression https://github.com/ddev/ddev/issues/1431
var DockerVersionConstraint = ">= 20.10.0-alpha1"

And it does some exotic things in comparison, like removing _ce for OpenSUSE (they add this suffix to the version):

// CheckDockerVersion determines if the Docker version of the host system meets the provided version
// constraints. See https://godoc.org/github.com/Masterminds/semver#hdr-Checking_Version_Constraints
// for examples defining version constraints.
func CheckDockerVersion(versionConstraint string) error {
defer util.TimeTrack()()
currentVersion, err := GetDockerVersion()
if err != nil {
return fmt.Errorf("no docker")
}
// If Docker version has "_ce", remove it. This happens on OpenSUSE Tumbleweed at least
currentVersion = strings.TrimSuffix(currentVersion, "_ce")

From what I can see, people who build Docker can override the Docker version as they wish, for example from the Arch package (people can set any VERSION env they want when building):

https://gitlab.archlinux.org/archlinux/packaging/packages/docker/-/blob/381210628f4f895b2cee908ffa1179f7ff1150d4/PKGBUILD#L87-94

I would rather set the minimum API version to use with DDEV - this value is set and controlled only by Docker.

@rfay, what do you think about this? (Of course, this is beyond the scope of this PR, and can be done in a new PR).

@rfay
Copy link
Member

rfay commented Jan 31, 2024

API version sounds like a fine thing to me.

In general, we've been trying to support as much as we can all the time, and been pretty successful with it over the long term.

@stasadev stasadev marked this pull request as ready for review February 2, 2024 11:20
@stasadev stasadev requested a review from a team as a code owner February 2, 2024 11:20
@stasadev stasadev changed the title build: bump docker-compose to v2.24.5 build: bump docker-compose to v2.24.5, add templateCanUse function for yaml Feb 2, 2024
@stasadev
Copy link
Member Author

stasadev commented Feb 2, 2024

I've updated the PR description with more information about the changes made, it should be fine to merge.

@rfay
Copy link
Member

rfay commented Feb 2, 2024

I'll try to manually test. Looks good to me also.

@rfay
Copy link
Member

rfay commented Feb 2, 2024

I guess my major worry would be that since healthcheck.start_interval was previously ignored, it not being ignored when using Docker v25 might cause some new issues.

@stasadev
Copy link
Member Author

stasadev commented Feb 2, 2024

This check healthcheck.start_interval will simply start in 1s, not in 5s (default).
https://docs.docker.com/engine/reference/builder/#healthcheck

@stasadev stasadev changed the title build: bump docker-compose to v2.24.5, add templateCanUse function for yaml build: bump docker-compose to v2.24.5, set healthcheck.start_interval to 1s in Docker v25+ Feb 2, 2024
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

It looks great to me. I tested against Docker 25.0.2 (Docker Desktop) and against Docker 24.0.7 (colima) and the behavior was correct.

The reason I was a little hesitant was that I have misunderstood these configuration values and misused them many times during DDEV's history :)


return m
}

// templateCanUse will return true if the given feature is available.
// This is used in YAML templates to determine whether to use a feature or not.
func templateCanUse(feature string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Pretty brilliant, thanks.

@rfay rfay merged commit d8053c3 into ddev:master Feb 2, 2024
34 checks passed
@stasadev stasadev deleted the 20240126_stasadev_bump_compose_2.24.3 branch February 5, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants