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

libcnb-test: Use Docker CLI instead of Bollard and the Docker daemon API #620

Closed
edmorley opened this issue Jul 31, 2023 · 0 comments · Fixed by #621
Closed

libcnb-test: Use Docker CLI instead of Bollard and the Docker daemon API #620

edmorley opened this issue Jul 31, 2023 · 0 comments · Fixed by #621
Assignees
Labels
enhancement New feature or request faster compiles Things that improve compile times libcnb-test

Comments

@edmorley
Copy link
Member

edmorley commented Jul 31, 2023

Currently libcnb-test runs various Docker related actions/commands using the bollard crate.

Whilst at first glance using a Rust client for Docker seems preferable, it actually has a number of disadvantages:

  • Bollard's APIs mostly map to lower-level Docker daemon API primitives, meaning that what might otherwise be a single action using the Docker CLI instead requires the correct combination of multiple daemon API calls and associated edge case/error handling. This means we effectively have to reimplement parts of the Docker CLI, increasing effort of implementing any new feature and the chance of implementation error - which has already resulted in bugs: libcnb-test: Exit status of commands run via run_shell_command and shell_exec are not checked #446.
  • The whole point of libcnb-test is that it's as representative as possible of how end users use CNBs and run the resultant images. End users don't run their containers using direct Docker daemon API calls, they use the Docker CLI. Plus, for maintainers of libcnb-test (or anyone debugging an issue with it), it's much harder to understand the codebase in terms of both Bollard+the Docker daemon API (particularly given their docs aren't great), given that we ourselves are really only used to the Docker CLI.
  • Bollard has a very heavy dependency tree (partly due to requiring the tokio runtime) - for example, it increases the number of the Python CNB's transitive dependencies by 50%.

GUS-W-13853580.

@edmorley edmorley added enhancement New feature or request libcnb-test labels Jul 31, 2023
@edmorley edmorley self-assigned this Jul 31, 2023
edmorley added a commit that referenced this issue Aug 1, 2023
Previously libcnb-test ran its various Docker related actions/commands
(excluding those handled by Pack CLI) using the bollard crate.

Whilst at first glance using a Rust client for Docker seems preferable,
it turns out that using Bollard/the Docker daemon API actually has a
number of disadvantages, which are explained in more detail in #620.

Now:
- The Docker CLI is used instead of Bollard+Tokio+the Docker daemon API,
  which is simpler to understand/maintain and also avoids ~55 additional
  transitive dependencies.
- The `run_shell_command` and `shell_exec` commands are now run as
  attached `docker run` invocations, making it trivial to check their
  exit code, fixing #446.
- Whenever errors occur, the error output is now easier for end users to
  understand, since it's presented as Docker CLI output with which they
  will be more familiar (vs Docker daemon/Bollard API errors).

As part of this change, `ContainerConfig::entrypoint` can no longer
accept a vector of strings, since the Docker CLI's `--entrypoint` arg
only accepts a single value, unlike the Docker daemon API. However,
since the purpose of `libcnb-test` is to replicate typical end-user
usage of the buildpacks and resultant images, this actually improves
alignment of the framework with the use-cases we want to test.

Fixes #446.
Closes #620.
GUS-W-11382688.
GUS-W-13853580.
@edmorley edmorley added the faster compiles Things that improve compile times label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request faster compiles Things that improve compile times libcnb-test
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant