Emit a performance warning if containerd is enabled and we're exporting to the daemon

Signed-off-by: Natalie Arellano <narellano@vmware.com>
This commit is contained in:
Natalie Arellano 2024-11-14 11:07:26 -05:00
parent be2c8be464
commit 1f7e0c8bcb
1 changed files with 20 additions and 0 deletions

View File

@ -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 {