From 25a9d6af6c46f76ff25e52cb0d7c13eb43d665a8 Mon Sep 17 00:00:00 2001 From: Khurram Baig Date: Tue, 17 Oct 2023 21:03:34 +0530 Subject: [PATCH] [TEP-0104] Task-level Resource Requirements to beta Setting of Task-level Resource Requirements was introduced in v0.39.0. This is a crucial feature required by our customers when running Pipelines at large scale. This promotes TEP-0104 to beta such that these features can be used by the task authors and pipeline authors in a cluster when enable-api-fields is either set to beta or alpha. --- docs/additional-configs.md | 17 +++++++++-------- docs/compute-resources.md | 2 +- pkg/apis/pipeline/v1/pipelinerun_validation.go | 2 +- .../pipeline/v1/pipelinerun_validation_test.go | 4 ++-- pkg/apis/pipeline/v1/taskrun_validation.go | 2 +- pkg/apis/pipeline/v1/taskrun_validation_test.go | 6 +++--- .../pipeline/v1beta1/pipelinerun_validation.go | 2 +- .../v1beta1/pipelinerun_validation_test.go | 16 ++++++++++++++-- pkg/apis/pipeline/v1beta1/taskrun_validation.go | 2 +- .../pipeline/v1beta1/taskrun_validation_test.go | 4 ++-- pkg/pod/pod.go | 2 +- 11 files changed, 36 insertions(+), 23 deletions(-) diff --git a/docs/additional-configs.md b/docs/additional-configs.md index 1f923812010..a4a5150e88e 100644 --- a/docs/additional-configs.md +++ b/docs/additional-configs.md @@ -311,7 +311,6 @@ Features currently in "alpha" are: | [Windows Scripts](./tasks.md#windows-scripts) | [TEP-0057](https://github.com/tektoncd/community/blob/main/teps/0057-windows-support.md) | [v0.28.0](https://github.com/tektoncd/pipeline/releases/tag/v0.28.0) | | | [Debug](./debug.md) | [TEP-0042](https://github.com/tektoncd/community/blob/main/teps/0042-taskrun-breakpoint-on-failure.md) | [v0.26.0](https://github.com/tektoncd/pipeline/releases/tag/v0.26.0) | | | [Step and Sidecar Overrides](./taskruns.md#overriding-task-steps-and-sidecars) | [TEP-0094](https://github.com/tektoncd/community/blob/main/teps/0094-specifying-resource-requirements-at-runtime.md) | [v0.34.0](https://github.com/tektoncd/pipeline/releases/tag/v0.34.0) | | -| [Task-level Resource Requirements](compute-resources.md#task-level-compute-resources-configuration) | [TEP-0104](https://github.com/tektoncd/community/blob/main/teps/0104-tasklevel-resource-requirements.md) | [v0.39.0](https://github.com/tektoncd/pipeline/releases/tag/v0.39.0) | | | [Trusted Resources](./trusted-resources.md) | [TEP-0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md) | N/A | `trusted-resources-verification-no-match-policy` | | [Larger Results via Sidecar Logs](#enabling-larger-results-using-sidecar-logs) | [TEP-0127](https://github.com/tektoncd/community/blob/main/teps/0127-larger-results-via-sidecar-logs.md) | [v0.43.0](https://github.com/tektoncd/pipeline/releases/tag/v0.43.0) | `results-from` | | [Configure Default Resolver](./resolution.md#configuring-built-in-resolvers) | [TEP-0133](https://github.com/tektoncd/community/blob/main/teps/0133-configure-default-resolver.md) | N/A | | @@ -331,14 +330,16 @@ except where otherwise noted. Features currently in "beta" are: -| Feature | Proposal | Alpha Release | Beta Release | Individual Flag | `enable-api-fields=beta` required for `v1beta1` | -|:-------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|:------------------------------------------------| -| [Array Results and Array Indexing](pipelineruns.md#specifying-parameters) | [TEP-0076](https://github.com/tektoncd/community/blob/main/teps/0076-array-result-types.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | [v0.45.0](https://github.com/tektoncd/pipeline/releases/tag/v0.45.0) | | No | -| [Object Parameters and Results](pipelineruns.md#specifying-parameters) | [TEP-0075](https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md) | | [v0.46.0](https://github.com/tektoncd/pipeline/releases/tag/v0.46.0) | | No | -| [Remote Tasks](./taskruns.md#remote-tasks) and [Remote Pipelines](./pipelineruns.md#remote-pipelines) | [TEP-0060](https://github.com/tektoncd/community/blob/main/teps/0060-remote-resolution.md) | | [v0.41.0](https://github.com/tektoncd/pipeline/releases/tag/v0.41.0) | | No | -| [`Provenance` field in Status](pipeline-api.md#provenance)| [issue#5550](https://github.com/tektoncd/pipeline/issues/5550)| [v0.41.0](https://github.com/tektoncd/pipeline/releases/tag/v0.41.0)| [v0.48.0](https://github.com/tektoncd/pipeline/releases/tag/v0.48.0) | `enable-provenance-in-status` | No | -| [Isolated `Step` & `Sidecar` `Workspaces`](./workspaces.md#isolated-workspaces) | [TEP-0029](https://github.com/tektoncd/community/blob/main/teps/0029-step-workspaces.md) | [v0.24.0](https://github.com/tektoncd/pipeline/releases/tag/v0.24.0) | [v0.50.0](https://github.com/tektoncd/pipeline/releases/tag/v0.50.0) | | Yes | +| Feature | Proposal | Alpha Release | Beta Release | Individual Flag | `enable-api-fields=beta` required for `v1beta1` | +|:-------------------------------------------------------------------|:------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|:---------------------------------------------------------------------|:----------------|:---| +| [Array Results and Array Indexing](pipelineruns.md#specifying-parameters) | [TEP-0076](https://github.com/tektoncd/community/blob/main/teps/0076-array-result-types.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | [v0.45.0](https://github.com/tektoncd/pipeline/releases/tag/v0.45.0) | | No | +| [Object Parameters and Results](pipelineruns.md#specifying-parameters) | [TEP-0075](https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md) | | [v0.46.0](https://github.com/tektoncd/pipeline/releases/tag/v0.46.0) | | No | +| [Remote Tasks](./taskruns.md#remote-tasks) and [Remote Pipelines](./pipelineruns.md#remote-pipelines) | [TEP-0060](https://github.com/tektoncd/community/blob/main/teps/0060-remote-resolution.md) | | [v0.41.0](https://github.com/tektoncd/pipeline/releases/tag/v0.41.0) | | No | +| [`Provenance` field in Status](pipeline-api.md#provenance)| [issue#5550](https://github.com/tektoncd/pipeline/issues/5550)| [v0.41.0](https://github.com/tektoncd/pipeline/releases/tag/v0.41.0)| [v0.48.0](https://github.com/tektoncd/pipeline/releases/tag/v0.48.0) | `enable-provenance-in-status`| No | +| [Isolated `Step` & `Sidecar` `Workspaces`](./workspaces.md#isolated-workspaces) | [TEP-0029](https://github.com/tektoncd/community/blob/main/teps/0029-step-workspaces.md) | [v0.24.0](https://github.com/tektoncd/pipeline/releases/tag/v0.24.0) | [v0.50.0](https://github.com/tektoncd/pipeline/releases/tag/v0.50.0) | | Yes | | [Matrix](./matrix.md) | [TEP-0090](https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | [v0.53.0](https://github.com/tektoncd/pipeline/releases/tag/v0.53.0) | | No | +| [Task-level Resource Requirements](compute-resources.md#task-level-compute-resources-configuration) | [TEP-0104](https://github.com/tektoncd/community/blob/main/teps/0104-tasklevel-resource-requirements.md) | [v0.39.0](https://github.com/tektoncd/pipeline/releases/tag/v0.39.0) | | + ## Enabling larger results using sidecar logs diff --git a/docs/compute-resources.md b/docs/compute-resources.md index ca9cf65e3ec..40de3fe70d4 100644 --- a/docs/compute-resources.md +++ b/docs/compute-resources.md @@ -44,7 +44,7 @@ Therefore, the pod will have no effective CPU limit. ## Task-level Compute Resources Configuration -**([alpha only](https://github.com/tektoncd/pipeline/blob/main/docs/additional-configs.md#alpha-features))** +**([beta](https://github.com/tektoncd/pipeline/blob/main/docs/additional-configs.md#beta-features))** Tekton allows users to specify resource requirements of [`Steps`](./tasks.md#defining-steps), which run sequentially. However, the pod's effective resource requirements are still the diff --git a/pkg/apis/pipeline/v1/pipelinerun_validation.go b/pkg/apis/pipeline/v1/pipelinerun_validation.go index ee7a6dc2c53..e554263705a 100644 --- a/pkg/apis/pipeline/v1/pipelinerun_validation.go +++ b/pkg/apis/pipeline/v1/pipelinerun_validation.go @@ -290,7 +290,7 @@ func validateTaskRunSpec(ctx context.Context, trs PipelineTaskRunSpec) (errs *ap errs = errs.Also(validateSidecarSpecs(trs.SidecarSpecs).ViaField("sidecarSpecs")) } if trs.ComputeResources != nil { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.AlphaAPIFields).ViaField("computeResources")) + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.BetaAPIFields).ViaField("computeResources")) errs = errs.Also(validateTaskRunComputeResources(trs.ComputeResources, trs.StepSpecs)) } if trs.PodTemplate != nil { diff --git a/pkg/apis/pipeline/v1/pipelinerun_validation_test.go b/pkg/apis/pipeline/v1/pipelinerun_validation_test.go index a0748fa7590..6ebff9a9bba 100644 --- a/pkg/apis/pipeline/v1/pipelinerun_validation_test.go +++ b/pkg/apis/pipeline/v1/pipelinerun_validation_test.go @@ -1040,7 +1040,7 @@ func TestPipelineRunSpec_Invalidate(t *testing.T) { ), withContext: cfgtesting.EnableAlphaAPIFields, }, { - name: "computeResources disallowed without alpha feature gate", + name: "computeResources disallowed without beta feature gate", spec: v1.PipelineRunSpec{ PipelineRef: &v1.PipelineRef{Name: "foo"}, TaskRunSpecs: []v1.PipelineTaskRunSpec{ @@ -1053,7 +1053,7 @@ func TestPipelineRunSpec_Invalidate(t *testing.T) { }, }, withContext: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"").ViaIndex(0).ViaField("taskRunSpecs"), + wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").ViaIndex(0).ViaField("taskRunSpecs"), }} for _, ps := range tests { diff --git a/pkg/apis/pipeline/v1/taskrun_validation.go b/pkg/apis/pipeline/v1/taskrun_validation.go index d3915dc5d87..87294c4cdc1 100644 --- a/pkg/apis/pipeline/v1/taskrun_validation.go +++ b/pkg/apis/pipeline/v1/taskrun_validation.go @@ -87,7 +87,7 @@ func (ts *TaskRunSpec) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(validateSidecarSpecs(ts.SidecarSpecs).ViaField("sidecarSpecs")) } if ts.ComputeResources != nil { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.AlphaAPIFields).ViaField("computeResources")) + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.BetaAPIFields).ViaField("computeResources")) errs = errs.Also(validateTaskRunComputeResources(ts.ComputeResources, ts.StepSpecs)) } diff --git a/pkg/apis/pipeline/v1/taskrun_validation_test.go b/pkg/apis/pipeline/v1/taskrun_validation_test.go index 8dae7195b2f..c895cbe5834 100644 --- a/pkg/apis/pipeline/v1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1/taskrun_validation_test.go @@ -773,7 +773,7 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { ), wc: cfgtesting.EnableAlphaAPIFields, }, { - name: "computeResources disallowed without alpha feature gate", + name: "computeResources disallowed without beta feature gate", spec: v1.TaskRunSpec{ TaskRef: &v1.TaskRef{ Name: "foo", @@ -785,7 +785,7 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { }, }, wc: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), + wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\""), }} for _, ts := range tests { @@ -864,7 +864,7 @@ func TestTaskRunSpec_Validate(t *testing.T) { }, }, }, - wc: cfgtesting.EnableAlphaAPIFields, + wc: cfgtesting.EnableBetaAPIFields, }, { name: "valid sidecar and task-level (spec.resources) resource requirements", spec: v1.TaskRunSpec{ diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go b/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go index ad6d5cbbdb4..56d44138805 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_validation.go @@ -334,7 +334,7 @@ func validateTaskRunSpec(ctx context.Context, trs PipelineTaskRunSpec) (errs *ap errs = errs.Also(validateSidecarOverrides(trs.SidecarOverrides).ViaField("sidecarOverrides")) } if trs.ComputeResources != nil { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.AlphaAPIFields).ViaField("computeResources")) + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.BetaAPIFields).ViaField("computeResources")) errs = errs.Also(validateTaskRunComputeResources(trs.ComputeResources, trs.StepOverrides)) } if trs.TaskPodTemplate != nil { diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go b/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go index 9f76c1825f4..b21439ef949 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go @@ -1159,7 +1159,7 @@ func TestPipelineRunSpec_Invalidate(t *testing.T) { ), withContext: cfgtesting.EnableAlphaAPIFields, }, { - name: "computeResources disallowed without alpha feature gate", + name: "computeResources disallowed without beta feature gate", spec: v1beta1.PipelineRunSpec{ PipelineRef: &v1beta1.PipelineRef{Name: "foo"}, TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{ @@ -1172,7 +1172,7 @@ func TestPipelineRunSpec_Invalidate(t *testing.T) { }, }, withContext: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\"").ViaIndex(0).ViaField("taskRunSpecs"), + wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").ViaIndex(0).ViaField("taskRunSpecs"), }} for _, ps := range tests { @@ -1208,6 +1208,18 @@ func TestPipelineRunSpec_Validate(t *testing.T) { }, }, { name: "valid task-level (taskRunSpecs.resources) resource requirements configured", + spec: v1beta1.PipelineRunSpec{ + PipelineRef: &v1beta1.PipelineRef{Name: "pipeline"}, + TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{{ + PipelineTaskName: "pipelineTask", + ComputeResources: &corev1.ResourceRequirements{ + Requests: corev1.ResourceList{corev1.ResourceMemory: corev1resources.MustParse("2Gi")}, + }, + }}, + }, + withContext: cfgtesting.EnableBetaAPIFields, + }, { + name: "valid task-level (taskRunSpecs.resources) resource requirements configured with stepOverride", spec: v1beta1.PipelineRunSpec{ PipelineRef: &v1beta1.PipelineRef{Name: "pipeline"}, TaskRunSpecs: []v1beta1.PipelineTaskRunSpec{{ diff --git a/pkg/apis/pipeline/v1beta1/taskrun_validation.go b/pkg/apis/pipeline/v1beta1/taskrun_validation.go index e49856d2c50..e5108a6464c 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_validation.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_validation.go @@ -82,7 +82,7 @@ func (ts *TaskRunSpec) Validate(ctx context.Context) (errs *apis.FieldError) { errs = errs.Also(validateSidecarOverrides(ts.SidecarOverrides).ViaField("sidecarOverrides")) } if ts.ComputeResources != nil { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.AlphaAPIFields).ViaField("computeResources")) + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "computeResources", config.BetaAPIFields).ViaField("computeResources")) errs = errs.Also(validateTaskRunComputeResources(ts.ComputeResources, ts.StepOverrides)) } diff --git a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go index 1aaa409741c..6e604fb6e36 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go @@ -761,7 +761,7 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { ), wc: cfgtesting.EnableAlphaAPIFields, }, { - name: "computeResources disallowed without alpha feature gate", + name: "computeResources disallowed without beta feature gate", spec: v1beta1.TaskRunSpec{ TaskRef: &v1beta1.TaskRef{ Name: "foo", @@ -773,7 +773,7 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { }, }, wc: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" but it is \"stable\""), + wantErr: apis.ErrGeneric("computeResources requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\""), }, { name: "uses resources", spec: v1beta1.TaskRunSpec{ diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index e99ee7e2c62..cfc7d69d683 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -184,7 +184,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta if err != nil { return nil, err } - if alphaAPIEnabled && taskRun.Spec.ComputeResources != nil { + if taskRun.Spec.ComputeResources != nil { tasklevel.ApplyTaskLevelComputeResources(steps, taskRun.Spec.ComputeResources) } windows := usesWindows(taskRun)