Skip to content

Commit

Permalink
bake: raise maximum size limit and fix size check
Browse files Browse the repository at this point in the history
Similar to docker#2716.

Use the file size rather than the proto size, raise the allowed limit to
the same value for consistency, and improve the error message to include
the limit in human units.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
  • Loading branch information
jsternberg committed Oct 4, 2024
1 parent 4815316 commit 9fc6f39
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bake/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ import (
controllerapi "github.com/docker/buildx/controller/pb"
"github.com/docker/buildx/driver"
"github.com/docker/buildx/util/progress"
"github.com/docker/go-units"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/dockerui"
gwclient "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/session"
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
)

const maxBakeDefinitionSize = 2 * 1024 * 1024 // 2 MB

type Input struct {
State *llb.State
URL string
Expand Down Expand Up @@ -178,9 +180,9 @@ func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Refere
name := inp.URL
inp.URL = ""

if len(dt) > proto.Size(stat) {
if proto.Size(stat) > 1024*512 {
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size")
if int64(len(dt)) > stat.Size {
if stat.Size > maxBakeDefinitionSize {
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size (%s)", units.HumanSize(maxBakeDefinitionSize))
}

dt, err = ref.ReadFile(ctx, gwclient.ReadRequest{
Expand Down

0 comments on commit 9fc6f39

Please sign in to comment.