From 1f7e0c8bcbeca7d1cc7e24bfcd22afb6ca502f6e Mon Sep 17 00:00:00 2001 From: Natalie Arellano Date: Thu, 14 Nov 2024 11:07:26 -0500 Subject: [PATCH] Emit a performance warning if containerd is enabled and we're exporting to the daemon Signed-off-by: Natalie Arellano --- pkg/client/build.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/client/build.go b/pkg/client/build.go index 50867e66c..750baa7ac 100644 --- a/pkg/client/build.go +++ b/pkg/client/build.go @@ -304,6 +304,11 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error { "Re-run with '--pull-policy=always' to silence this warning.") } + if !opts.Publish && usesContainerdStorage(c.docker) { + c.logger.Warnf("Exporting to docker daemon (building without --publish) and daemon uses containerd storage; performance may be significantly degraded.\n" + + "For more information, see https://github.com/buildpacks/pack/issues/2272.") + } + imageRef, err := c.parseReference(opts) if err != nil { return errors.Wrapf(err, "invalid image name '%s'", opts.Image) @@ -803,6 +808,21 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error { return c.logImageNameAndSha(ctx, opts.Publish, imageRef) } +func usesContainerdStorage(docker DockerClient) bool { + info, err := docker.Info(context.Background()) + if err != nil { + return false + } + + for _, driverStatus := range info.DriverStatus { + if driverStatus[0] == "driver-type" && driverStatus[1] == "io.containerd.snapshotter.v1" { + return true + } + } + + return false +} + func getTargetFromBuilder(builderImage imgutil.Image) (*dist.Target, error) { builderOS, err := builderImage.OS() if err != nil {