Skip to content

Commit

Permalink
Emit a performance warning if containerd is enabled and we're exporti…
Browse files Browse the repository at this point in the history
…ng to the daemon

Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano committed Nov 14, 2024
1 parent be2c8be commit 1f7e0c8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

Check warning on line 310 in pkg/client/build.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/build.go#L308-L310

Added lines #L308 - L310 were not covered by tests

imageRef, err := c.parseReference(opts)
if err != nil {
return errors.Wrapf(err, "invalid image name '%s'", opts.Image)
Expand Down Expand Up @@ -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
}

Check warning on line 820 in pkg/client/build.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/build.go#L819-L820

Added lines #L819 - L820 were not covered by tests
}

return false
}

func getTargetFromBuilder(builderImage imgutil.Image) (*dist.Target, error) {
builderOS, err := builderImage.OS()
if err != nil {
Expand Down

0 comments on commit 1f7e0c8

Please sign in to comment.