Repository navigation
Make container startup safe under concurrency and surface the failures Docker reports. - #36
Merged
Merged
Conversation
The tooling network carried the label the library prunes by, so a test run of any project using the library removed it between two targets. The fixed container name made two targets collide, test-file never created the network, and the migrations mount had no consumer.
…nd the removal on failure.
…ailures Docker reports. - Reuse the container another process created first instead of failing on the name conflict, and hand it over only once it has started. - Raise DockerCommandExecutionFailed when a file copy or the MySQL setup fails, and remove the container nobody holds. - Start a container once more when its network was pruned before it started. - Bound the container creation by withPullTimeout() instead of the default timeout of the client. - Count the time each readiness check takes toward the timeout, and raise the MySQL default to 60 seconds. - Quote the database name as an identifier in the MySQL setup. - Replace the rebuilding withers with clone and split the internal steps into collaborators. - Freeze the clock and the host environment in the unit tests instead of sleeping and spawning processes.
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
runIfNotExists()is documented as shared by every PHP process that asks for the same name, yet six processes asking at the same time ended with one container and fiveDockerCommandExecutionFailed, because looking the container up and creating it were two separate steps. Several failures were also swallowed: adocker cpthat failed left the container running without its files, and a database setup MySQL rejected was ignored, so the root grants were silently missing.What changes
DockerCommandExecutionFailedand removes the container that was created.DockerCommandExecutionFailedcarrying the MySQL error. The database name is quoted as an identifier, so a name such asmy-dbno longer breaks the setup and drops the grants with it.run()that fails to start, to satisfy a wait strategy, or (MySQL) to accept connections is removed before the failure is raised, since nothing else holds it.withPullTimeout()bounds the container creation, which includes the image pull, instead of the 60 seconds of the default client timeout. It defaults to 300 seconds.ContainerWaitForDependencyhonors its timeout. The time each check takes now counts toward it: a 2 second timeout with a 250 millisecond check took 4 seconds before and takes 2 seconds after. Since the MySQL readiness wait was effectively longer than its 30 seconds, its default is now 60 seconds.docker inspect --type container <name>instead ofdocker psfollowed bydocker inspect.Internally, the definitions copy themselves with
clone, the startup steps are split into collaborators without private methods, and the unit tests freeze the clock and the host environment instead of sleeping and spawning processes. The unit suite went from 27 to 3 seconds and the mutation run from 8 minutes 34 seconds to under 3 minutes on the same machine, with every mutant still killed.The tooling network no longer carries the label the library prunes by,
make test-filecreates the network, and the fixed container name is gone, so two targets can run side by side.Public API
The change is breaking, so the release is
6.0.0.Changed: a failed file copy and a rejected MySQL setup now raise
DockerCommandExecutionFailedinstead of being ignored. The MySQL readiness timeout defaults to 60 seconds. A customDockerClientreceives the container creation and the reaper throughexecuteWithTimeout(), and the lookup of an existing container asdocker inspect --type container <name>.Added:
GenericDockerContainer::withPullTimeout(),MySQLDockerContainer::withPullTimeout()andFlywayDockerContainer::withPullTimeout().Related issue
None.
Checklist
make reviewpasses.make testspasses.