From a2e206494f688d74dca440bafe10075e53574bf2 Mon Sep 17 00:00:00 2001 From: William Fish Date: Tue, 31 May 2022 16:47:51 -0400 Subject: [PATCH] Doubling the MaximumBundleObjects from 10 to 20. The official hard limit is 255 ( for oci images ), and while testing use cases for bundles it was noticed the current max is pretty low, and doubling should still ensure very small oci sizes as well as give a little more flexablitliy in testing. Also updated the tests, so in the future if a change to the max happens, the tests should be g2g with no changes. --- docs/pipelines.md | 6 +- pkg/remote/oci/resolver.go | 2 +- pkg/remote/oci/resolver_test.go | 124 ++++++-------------------------- 3 files changed, 27 insertions(+), 105 deletions(-) diff --git a/docs/pipelines.md b/docs/pipelines.md index e271d70ebb3..d28e8080fb5 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -364,7 +364,11 @@ spec: `"true"` in the `feature-flags` configmap, see [`install.md`](./install.md#customizing-the-pipelines-controller-behavior)** You may also specify your `Task` reference using a `Tekton Bundle`. A `Tekton Bundle` is an OCI artifact that -contains Tekton resources like `Tasks` which can be referenced within a `taskRef`. +contains Tekton resources like `Tasks` which can be referenced within a `taskRef`. + +There is currently a hard limit of 20 objects in a bundle. + + ```yaml spec: diff --git a/pkg/remote/oci/resolver.go b/pkg/remote/oci/resolver.go index a764a0c2f2c..6a837ca7468 100644 --- a/pkg/remote/oci/resolver.go +++ b/pkg/remote/oci/resolver.go @@ -42,7 +42,7 @@ const ( // TitleAnnotation is an OCI annotation for the bundle title TitleAnnotation = "dev.tekton.image.name" // MaximumBundleObjects defines the maximum number of objects in a bundle - MaximumBundleObjects = 10 + MaximumBundleObjects = 20 ) // Resolver implements the Resolver interface using OCI images. diff --git a/pkg/remote/oci/resolver_test.go b/pkg/remote/oci/resolver_test.go index 6cefa890f73..c1501fa5b7a 100644 --- a/pkg/remote/oci/resolver_test.go +++ b/pkg/remote/oci/resolver_test.go @@ -61,6 +61,24 @@ func TestOCIResolver(t *testing.T) { t.Fatal(err) } + // setup to many objects in oci bundle test + toManyObjErr := fmt.Sprintf("contained more than the maximum %d allow objects", oci.MaximumBundleObjects) + + var toManyObj []runtime.Object + for i := 0; i <= oci.MaximumBundleObjects; i++ { + name := fmt.Sprintf("%d-task", i) + obj := v1beta1.Task{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + TypeMeta: metav1.TypeMeta{ + APIVersion: "tekton.dev/v1beta1", + Kind: "Task", + }, + } + toManyObj = append(toManyObj, &obj) + } + testcases := []struct { name string objs []runtime.Object @@ -129,111 +147,11 @@ func TestOCIResolver(t *testing.T) { }, }, { - name: "too-many-objects", - objs: []runtime.Object{ - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "first-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "second-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "third-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "fourth-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "fifth-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "sixth-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "seventh-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "eighth-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ninth-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "tenth-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - &v1beta1.Task{ - ObjectMeta: metav1.ObjectMeta{ - Name: "eleventh-task", - }, - TypeMeta: metav1.TypeMeta{ - APIVersion: "tekton.dev/v1beta1", - Kind: "Task", - }, - }, - }, + name: "too-many-objects", + objs: toManyObj, mapper: test.DefaultObjectAnnotationMapper, listExpected: []remote.ResolvedObject{}, - wantErr: "contained more than the maximum 10 allow objects", + wantErr: toManyObjErr, }, { name: "single-task-no-version",