Skip to content

feat: implement the driver's package, doctor, and status hooks - #491

Merged
tas50 merged 1 commit into
mainfrom
feat/driver-hooks
Aug 23, 2026
Merged

feat: implement the driver's package, doctor, and status hooks#491
tas50 merged 1 commit into
mainfrom
feat/driver-hooks

Conversation

@tas50

@tas50 tas50 commented Aug 23, 2026

Copy link
Copy Markdown
Member

Kitchen::Driver::Base defines three hooks for a driver to answer questions the CLI asks. This driver inherited all three unimplemented, so all three answered with a shrug:

$ 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
Instance             Driver  ... Last Action  Last Error  Live Status
default-ubuntu-2404  Docker  ... Created      <None>      unknown

Docker can answer all three.

package

Commits the container to an image — the artifact every other docker tool already takes. docker save gets a tarball from it.

-----> Packaging remote instance
       [Docker] Packaged default-ubuntu-2404 as default-ubuntu-2404:latest (sha256:1f51c590...)

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 commit reports it as a bare Error response from daemon: No such container: <64 hex characters>, which names neither the instance nor what to do next.

doctor

-----> The doctor is in
       Docker daemon at unix:///var/run/docker.sock is reachable, running 29.7.2.

Checks the daemon is reachable (and reports its version), that a configured tls_cacert / tls_cert / tls_key / 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. A true return is how Test Kitchen decides to exit non-zero.

status

Instance             Driver  ... Last Action  Last Error  Live Status
default-ubuntu-2404  Docker  ... Converged    <None>      running

running, stopped, gone (state names a container the daemon does not have), or not created — from the same two questions create and destroy already 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.04 containers. Every block above is captured from a real run. Also checked:

  • the packaged image runs — docker run --rm default-ubuntu-2404:latest cat /etc/os-releaseUbuntu 24.04.4 LTS
  • --live distinguishes all four states: stopped the container → stopped; docker rm -f behind Kitchen's back → gone
  • kitchen doctor exits 1 with a stale state file and 0 when healthy
  • package on 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.`
  • ordinary converge / destroy unaffected

rake style clean; markdownlint clean; rspec 332 examples, 0 failures (19 new).

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>
@tas50
tas50 merged commit 1366895 into main Aug 23, 2026
107 checks passed
@tas50
tas50 deleted the feat/driver-hooks branch August 23, 2026 19:28
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.

1 participant