diff --git a/pkg/cmd/server/start.go b/pkg/cmd/server/start.go index a3f8067d..0d1b93b9 100644 --- a/pkg/cmd/server/start.go +++ b/pkg/cmd/server/start.go @@ -49,15 +49,16 @@ const ( // PorchServerOptions contains state for master/api server type PorchServerOptions struct { - RecommendedOptions *genericoptions.RecommendedOptions - LocalStandaloneDebugging bool // Enables local standalone running/debugging of the apiserver. - CacheDirectory string - CoreAPIKubeconfigPath string - FunctionRunnerAddress string - DefaultImagePrefix string - RepoSyncFrequency time.Duration - UseGitCaBundle bool - DisableValidatingAdmissionPolicy bool + RecommendedOptions *genericoptions.RecommendedOptions + LocalStandaloneDebugging bool // Enables local standalone running/debugging of the apiserver. + CacheDirectory string + CoreAPIKubeconfigPath string + FunctionRunnerAddress string + DefaultImagePrefix string + RepoSyncFrequency time.Duration + UseGitCaBundle bool + DisableValidatingAdmissionPolicy bool + MaxRequestBodySize int64 SharedInformerFactory informers.SharedInformerFactory StdOut io.Writer @@ -172,11 +173,9 @@ func (o *PorchServerOptions) Config() (*apiserver.Config, error) { o.SharedInformerFactory = informerFactory return []admission.PluginInitializer{}, nil } - if o.DisableValidatingAdmissionPolicy { o.RecommendedOptions.Admission.DisablePlugins = []string{"ValidatingAdmissionPolicy"} } - serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs) serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme)) @@ -186,6 +185,7 @@ func (o *PorchServerOptions) Config() (*apiserver.Config, error) { serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme)) serverConfig.OpenAPIConfig.Info.Title = OpenAPITitle serverConfig.OpenAPIConfig.Info.Version = OpenAPIVersion + serverConfig.MaxRequestBodyBytes = o.MaxRequestBodySize if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil { return nil, err @@ -245,6 +245,7 @@ func (o *PorchServerOptions) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&o.FunctionRunnerAddress, "function-runner", "", "Address of the function runner gRPC service.") fs.StringVar(&o.DefaultImagePrefix, "default-image-prefix", "gcr.io/kpt-fn/", "Default prefix for unqualified function names") fs.StringVar(&o.CacheDirectory, "cache-directory", "", "Directory where Porch server stores repository and package caches.") + fs.Int64Var(&o.MaxRequestBodySize, "max-request-body-size", 6*1024*1024, "Maximum size of the request body in bytes.") fs.BoolVar(&o.UseGitCaBundle, "use-git-cabundle", false, "Determine whether to use a user-defined CaBundle for TLS towards git.") fs.BoolVar(&o.DisableValidatingAdmissionPolicy, "disable-validating-admissions-policy", true, "Determine whether to (dis|en)able the Validating Admission Policy, which requires k8s version >= v1.30") fs.DurationVar(&o.RepoSyncFrequency, "repo-sync-frequency", 60*time.Second, "Frequency in seconds at which registered repositories will be synced.") diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index d939a6d4..74c54f3e 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -2856,3 +2856,43 @@ func (t *PorchSuite) TestPackageRevisionFieldSelectors(ctx context.Context) { } } } + +func (t *PorchSuite) TestLargePackageRevision(ctx context.Context) { + const ( + repository = "large-pkg-rev" + ) + + t.RegisterMainGitRepositoryF(ctx, repository) + pr := porchapi.PackageRevision{ + TypeMeta: metav1.TypeMeta{ + Kind: porchapi.PackageRevisionGVR.Resource, + APIVersion: porchapi.SchemeGroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: t.Namespace, + }, + Spec: porchapi.PackageRevisionSpec{ + PackageName: "new-package", + WorkspaceName: "workspace", + RepositoryName: repository, + Tasks: []porchapi.Task{ + { + Type: porchapi.TaskTypeInit, + Init: &porchapi.PackageInitTaskSpec{ + Description: "this is a test", + }, + }, + }, + }, + } + + t.CreateE(ctx, &pr) + + var prr porchapi.PackageRevisionResources + + t.GetE(ctx, client.ObjectKey{Name: pr.Name, Namespace: pr.Namespace}, &prr) + + prr.Spec.Resources["largefile.txt"] = strings.Repeat("a", 4*1024*1024) + + t.UpdateE(ctx, &prr) +}