Skip to content

Commit

Permalink
hud: improve 'entity too large' errors and raise limit (#4702)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicks committed Jun 29, 2021
1 parent 2af3565 commit d2476ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
7 changes: 4 additions & 3 deletions internal/engine/configs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var ownerSelector = labels.SelectorFromSet(labels.Set{LabelOwnerKind: LabelOwner
type object interface {
ctrlclient.Object
GetSpec() interface{}
GetGroupVersionResource() schema.GroupVersionResource
}

type objectSet map[schema.GroupVersionResource]typedObjectSet
Expand Down Expand Up @@ -196,7 +197,7 @@ func updateObjects(ctx context.Context, client ctrlclient.Client, newObjects, ol
if old == nil {
err := client.Create(ctx, obj)
if err != nil {
errs = append(errs, err)
errs = append(errs, fmt.Errorf("create %s/%s: %v", obj.GetGroupVersionResource().Resource, obj.GetName(), err))
}
continue
}
Expand All @@ -208,7 +209,7 @@ func updateObjects(ctx context.Context, client ctrlclient.Client, newObjects, ol
obj.SetResourceVersion(old.GetResourceVersion())
err := client.Update(ctx, obj)
if err != nil {
errs = append(errs, err)
errs = append(errs, fmt.Errorf("update %s/%s: %v", obj.GetGroupVersionResource().Resource, obj.GetName(), err))
}
continue
}
Expand All @@ -228,7 +229,7 @@ func updateObjects(ctx context.Context, client ctrlclient.Client, newObjects, ol

err := client.Delete(ctx, obj)
if err != nil {
errs = append(errs, err)
errs = append(errs, fmt.Errorf("delete %s/%s: %v", obj.GetGroupVersionResource().Resource, obj.GetName(), err))
}
}
}
Expand Down
28 changes: 27 additions & 1 deletion internal/hud/server/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ import (
"github.com/tilt-dev/tilt/pkg/openapi"
)

// https://twitter.com/ow/status/1356978380198072321
//
// By default, the API server request limit is 3MB. Certain Helm Charts with
// CRDs have bigger payloads than this, so we bumped it to 20MB.
//
// (Some custom API servers set it to 100MB, see
// https://github.com/kubernetes/kubernetes/pull/73805)
//
// This doesn't mean large 20MB payloads are fine. Iteratively applying a 20MB
// payload over and over will slow down the overall system, simply on copying
// and encoding/decoding costs alone.
//
// The underlying apiserver libraries have the ability to set this limit on a
// per-resource level (rather than a per-server level). If that's ever exposed,
// we should adjust this limit to be higher for KubernetesApply and lower for
// other resource types.
//
// It also might make sense to help the user break up large payloads. For
// example, we could automatically split large CRDs into their own resources.
const maxRequestBodyBytes = int64(20 * 1024 * 1024)

type WebListener net.Listener
type APIServerPort int

Expand Down Expand Up @@ -136,7 +157,12 @@ func ProvideTiltServerOptions(ctx context.Context,
return nil, err
}

return o.Config()
config, err := o.Config()
if err != nil {
return nil, err
}
config.GenericConfig.MaxRequestBodyBytes = maxRequestBodyBytes
return config, nil
}

// Generate the server config, removing options that are not needed for testing.
Expand Down

0 comments on commit d2476ce

Please sign in to comment.