feat: implement the driver's package, doctor, and status hooks - #491
Merged
Conversation
Kitchen::Driver::Base defines three hooks for a driver to answer questions
the CLI asks. This driver inherited all three unimplemented, so:
$ kitchen package default-ubuntu-2404
-----> Packaging remote instance # and nothing was produced
$ kitchen doctor default-ubuntu-2404
-----> The doctor is in # and nothing was checked
$ kitchen list --live
... Last Action Last Error Live Status
... Created <None> unknown
Docker can answer all three.
package commits the container to an image, which is the artifact every other
docker tool already takes; `docker save` gets a tarball from it. The image is
named after the instance, or by `package_name`. Packaging an instance that was
never created, or whose container is gone, is refused by name -- `docker
commit` reports the latter as a bare "No such container: <64 hex characters>".
doctor checks that the daemon is reachable and reports its version, that a
configured tls_cacert, tls_cert, tls_key, or dockerfile names a path that
exists, and that a container named in the state file is still there. Every
check runs and the results are OR-ed rather than returning at the first
problem: `kitchen doctor` exists to report the whole list at once.
status reports running, stopped, gone, or not created, from the same two
questions create and destroy already ask.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Kitchen::Driver::Basedefines three hooks for a driver to answer questions the CLI asks. This driver inherited all three unimplemented, so all three answered with a shrug:Docker can answer all three.
packageCommits the container to an image — the artifact every other docker tool already takes.
docker savegets a tarball from it.Named after the instance by default (already lowercase and dash-separated, so it is a valid repository name as it stands), or set
package_name.Packaging an instance that was never created, or one whose container is gone, is refused by name. The second is worth catching:
docker commitreports it as a bareError response from daemon: No such container: <64 hex characters>, which names neither the instance nor what to do next.doctorChecks the daemon is reachable (and reports its version), that a configured
tls_cacert/tls_cert/tls_key/dockerfilenames a path that exists, and that a container named in the state file is still there.Every check runs and the results are OR-ed rather than returning at the first problem —
kitchen doctorexists to report the whole list at once. A true return is how Test Kitchen decides to exit non-zero.statusrunning,stopped,gone(state names a container the daemon does not have), ornot created— from the same two questionscreateanddestroyalready ask. An instance with no container is answered without touching Docker.Not implemented
cache_directory, the fourth seam. It exists so a driver can hand the provisioner a host path to reuse between runs; this driver has no such path to offer, since everything lives inside the image and the container. Left inherited deliberately.Confirmation
Docker 29.7.2 (Docker Desktop 4.87.0, macOS/arm64), Test Kitchen 4.1.1, real
ubuntu-24.04containers. Every block above is captured from a real run. Also checked:docker run --rm default-ubuntu-2404:latest cat /etc/os-release→Ubuntu 24.04.4 LTS--livedistinguishes all four states: stopped the container →stopped;docker rm -fbehind Kitchen's back →gonekitchen doctorexits 1 with a stale state file and 0 when healthypackageon a removed container →Cannot package default-ubuntu-2404: the state file names container c94251d1..., which the daemon does not have. Run \kitchen destroy` to clear it.`converge/destroyunaffectedrake styleclean;markdownlintclean;rspec332 examples, 0 failures (19 new).