From c1df06a97081c8dda17209388b3744827d13c925 Mon Sep 17 00:00:00 2001 From: Chuang Wang Date: Tue, 4 Apr 2023 19:11:26 -0700 Subject: [PATCH] Promote the provenance field in status Fixes https://github.com/tektoncd/pipeline/issues/6309. Prior, the `provenance` field in status was an alpha feature gated by the dedicated feature flag named `enable-provenance-in-status` which is disabled by default. Now, we move this feature to beta by enabling this feature flag by default with the installation of Tekton Pipelines. In future, we will completely remove this feature flag once we feel this feature is stable. Signed-off-by: Chuang Wang --- config/config-feature-flags.yaml | 2 +- docs/additional-configs.md | 8 +- docs/pipelineruns.md | 4 +- pkg/apis/config/feature_flags.go | 2 +- pkg/apis/config/feature_flags_test.go | 10 +- .../testdata/feature-flags-all-flags-set.yaml | 2 +- .../v1beta1/pipelinerun_conversion_test.go | 9 +- .../v1beta1/taskrun_conversion_test.go | 9 +- .../pipelinerun/pipelinerun_test.go | 179 ++++++++++++++++-- pkg/reconciler/taskrun/taskrun_test.go | 44 +++-- test/conversion_test.go | 41 +++- test/custom_task_test.go | 55 ++++++ test/e2e-tests.sh | 2 +- test/larger_results_sidecar_logs_test.go | 40 +++- test/propagated_params_test.go | 10 + test/status_test.go | 37 +--- 16 files changed, 353 insertions(+), 101 deletions(-) diff --git a/config/config-feature-flags.yaml b/config/config-feature-flags.yaml index 2baa580b8f9..2a04a0fd073 100644 --- a/config/config-feature-flags.yaml +++ b/config/config-feature-flags.yaml @@ -85,7 +85,7 @@ data: # and PipelineRun status. This field contains metadata about resources used # in the TaskRun/PipelineRun such as the source from where a remote Task/Pipeline # definition was fetched. - enable-provenance-in-status: "false" + enable-provenance-in-status: "true" # Setting this flag will determine how Tekton pipelines will handle non-falsifiable provenance. # If set to "spire", then SPIRE will be used to ensure non-falsifiable provenance. # If set to "none", then Tekton will not have non-falsifiable provenance. diff --git a/docs/additional-configs.md b/docs/additional-configs.md index c9e67670424..9a5a0ea2209 100644 --- a/docs/additional-configs.md +++ b/docs/additional-configs.md @@ -245,10 +245,11 @@ Defaults to "ignore". - `results-from`: set this flag to "termination-message" to use the container's termination message to fetch results from. This is the default method of extracting results. Set it to "sidecar-logs" to enable use of a results sidecar logs to extract results instead of termination message. -- `enable-provenance-in-status`: set this flag to "true" to enable recording +- `enable-provenance-in-status`: Set this flag to `"true"` to enable populating the `provenance` field in `TaskRun` and `PipelineRun` status. The `provenance` field contains metadata about resources used in the TaskRun/PipelineRun such as the - source from where a remote Task/Pipeline definition was fetched. + source from where a remote Task/Pipeline definition was fetched. By default, this is set to `true`. + To disable populating this field, set this flag to `"false"`. For example: @@ -284,7 +285,6 @@ Features currently in "alpha" are: | [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) | | | [Object Params and Results](pipelineruns.md#specifying-parameters) | [TEP-0075](https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.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` | -| [`Provenance` field in Status](pipeline-api.md#provenance) | [issue#5550](https://github.com/tektoncd/pipeline/issues/5550) | N/A | `enable-provenance-in-status` | | [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 | | @@ -304,7 +304,7 @@ Features currently in "beta" are: | [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) | | | [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) | | [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) | - +| [`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`| ## Enabling larger results using sidecar logs diff --git a/docs/pipelineruns.md b/docs/pipelineruns.md index cc4371152f3..94e62050091 100644 --- a/docs/pipelineruns.md +++ b/docs/pipelineruns.md @@ -1317,7 +1317,9 @@ Your `PipelineRun`'s `status` field can contain the following fields: - [`kind`][kubernetes-overview] - Generally either `TaskRun` or `Run`. - [`apiVersion`][kubernetes-overview] - The API version for the underlying `TaskRun` or `Run`. - [`whenExpressions`](pipelines.md#guard-task-execution-using-when-expressions) - The list of when expressions guarding the execution of this task. - - `provenance` - Metadata about resources used in the PipelineRun such as the source from where a remote pipeline definition was fetched. + - `provenance` - Metadata about the runtime configuration and the resources used in the PipelineRun. The data in the `provenance` field will be recorded into the build provenance by the provenance generator i.e. (Tekton Chains). Currently, there are 2 subfields: + - `RefSource`: the source from where a remote pipeline definition was fetched. + - `FeatureFlags`: the configuration data of the `feature-flags` configmap. - `finallyStartTime`- The time at which the PipelineRun's `finally` Tasks, if any, began executing, in [RFC3339](https://tools.ietf.org/html/rfc3339) format. diff --git a/pkg/apis/config/feature_flags.go b/pkg/apis/config/feature_flags.go index b356b5c8467..3b5350db346 100644 --- a/pkg/apis/config/feature_flags.go +++ b/pkg/apis/config/feature_flags.go @@ -71,7 +71,7 @@ const ( // DefaultNoMatchPolicyConfig is the default value for "trusted-resources-verification-no-match-policy". DefaultNoMatchPolicyConfig = IgnoreNoMatchPolicy // DefaultEnableProvenanceInStatus is the default value for "enable-provenance-status". - DefaultEnableProvenanceInStatus = false + DefaultEnableProvenanceInStatus = true // DefaultResultExtractionMethod is the default value for ResultExtractionMethod DefaultResultExtractionMethod = ResultExtractionMethodTerminationMessage // DefaultMaxResultSize is the default value in bytes for the size of a result diff --git a/pkg/apis/config/feature_flags_test.go b/pkg/apis/config/feature_flags_test.go index b4d5ad5d31e..10cfa1150ea 100644 --- a/pkg/apis/config/feature_flags_test.go +++ b/pkg/apis/config/feature_flags_test.go @@ -65,9 +65,10 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { SendCloudEventsForRuns: true, EnforceNonfalsifiability: "spire", VerificationNoMatchPolicy: config.FailNoMatchPolicy, - EnableProvenanceInStatus: true, + EnableProvenanceInStatus: false, ResultExtractionMethod: "termination-message", - MaxResultSize: 4096, + + MaxResultSize: 4096, }, fileName: "feature-flags-all-flags-set", }, @@ -85,6 +86,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { RequireGitSSHSecretKnownHosts: config.DefaultRequireGitSSHSecretKnownHosts, SendCloudEventsForRuns: config.DefaultSendCloudEventsForRuns, VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, + EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus, ResultExtractionMethod: config.DefaultResultExtractionMethod, MaxResultSize: config.DefaultMaxResultSize, }, @@ -102,6 +104,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { RequireGitSSHSecretKnownHosts: config.DefaultRequireGitSSHSecretKnownHosts, SendCloudEventsForRuns: config.DefaultSendCloudEventsForRuns, VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, + EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus, ResultExtractionMethod: config.DefaultResultExtractionMethod, MaxResultSize: config.DefaultMaxResultSize, }, @@ -119,6 +122,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { RequireGitSSHSecretKnownHosts: config.DefaultRequireGitSSHSecretKnownHosts, SendCloudEventsForRuns: config.DefaultSendCloudEventsForRuns, VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, + EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus, ResultExtractionMethod: config.DefaultResultExtractionMethod, MaxResultSize: config.DefaultMaxResultSize, }, @@ -132,6 +136,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness, + EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus, ResultExtractionMethod: config.DefaultResultExtractionMethod, MaxResultSize: config.DefaultMaxResultSize, }, @@ -143,6 +148,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness, + EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus, ResultExtractionMethod: config.ResultExtractionMethodSidecarLogs, MaxResultSize: 8192, }, diff --git a/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml b/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml index 07f5f33a9de..696ca3c086c 100644 --- a/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml +++ b/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml @@ -28,4 +28,4 @@ data: send-cloudevents-for-runs: "true" enforce-nonfalsifiability: "spire" trusted-resources-verification-no-match-policy: "fail" - enable-provenance-in-status: "true" + enable-provenance-in-status: "false" diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go b/pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go index bf309b0a58d..61511d685d5 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go @@ -305,14 +305,7 @@ func TestPipelineRunConversion(t *testing.T) { URI: "test-uri", Digest: map[string]string{"sha256": "digest"}, }, - FeatureFlags: &config.FeatureFlags{ - RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, - EnableAPIFields: config.DefaultEnableAPIFields, - AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness, - VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, - ResultExtractionMethod: config.DefaultResultExtractionMethod, - MaxResultSize: config.DefaultMaxResultSize, - }, + FeatureFlags: config.DefaultFeatureFlags.DeepCopy(), }, }, }, diff --git a/pkg/apis/pipeline/v1beta1/taskrun_conversion_test.go b/pkg/apis/pipeline/v1beta1/taskrun_conversion_test.go index e0fe1b59127..b840641ad1f 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_conversion_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_conversion_test.go @@ -237,14 +237,7 @@ func TestTaskRunConversion(t *testing.T) { URI: "test-uri", Digest: map[string]string{"sha256": "digest"}, }, - FeatureFlags: &config.FeatureFlags{ - RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, - EnableAPIFields: config.DefaultEnableAPIFields, - AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness, - VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, - ResultExtractionMethod: config.DefaultResultExtractionMethod, - MaxResultSize: config.DefaultMaxResultSize, - }, + FeatureFlags: config.DefaultFeatureFlags.DeepCopy(), }}, }, }, diff --git a/pkg/reconciler/pipelinerun/pipelinerun_test.go b/pkg/reconciler/pipelinerun/pipelinerun_test.go index f2a96d371d5..31b3e4e01c3 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/pipelinerun/pipelinerun_test.go @@ -4590,6 +4590,15 @@ status: kind: CustomRun name: test-pipeline-run-finally-results-task-run-b pipelineTaskName: b-task + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableAPIFields: "stable" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `) expectedPr := expectedPrStatus @@ -4738,6 +4747,15 @@ status: kind: TaskRun name: test-pipeline-run-results-task-run-a pipelineTaskName: a-task + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableAPIFields: "stable" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `) expectedPr := expectedPrStatus @@ -4900,15 +4918,7 @@ metadata: Provenance: &v1beta1.Provenance{ RefSource: refSource.DeepCopy(), ConfigSource: (*v1beta1.ConfigSource)(refSource.DeepCopy()), - FeatureFlags: &config.FeatureFlags{ - RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, - EnableAPIFields: config.DefaultEnableAPIFields, - AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness, - VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, - EnableProvenanceInStatus: true, - ResultExtractionMethod: config.DefaultResultExtractionMethod, - MaxResultSize: config.DefaultMaxResultSize, - }, + FeatureFlags: config.DefaultFeatureFlags.DeepCopy(), }, }, } @@ -4959,9 +4969,8 @@ metadata: } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - ctx := ttesting.EnableFeatureFlagField(context.Background(), t, "enable-provenance-in-status") // mock first reconcile - if err := storePipelineSpecAndMergeMeta(ctx, pr, tc.reconcile1Args.pipelineSpec, tc.reconcile1Args.resolvedObjectMeta); err != nil { + if err := storePipelineSpecAndMergeMeta(context.Background(), pr, tc.reconcile1Args.pipelineSpec, tc.reconcile1Args.resolvedObjectMeta); err != nil { t.Errorf("storePipelineSpec() error = %v", err) } if d := cmp.Diff(pr, tc.wantPipelineRun); d != "" { @@ -4969,7 +4978,7 @@ metadata: } // mock second reconcile - if err := storePipelineSpecAndMergeMeta(ctx, pr, tc.reconcile2Args.pipelineSpec, tc.reconcile2Args.resolvedObjectMeta); err != nil { + if err := storePipelineSpecAndMergeMeta(context.Background(), pr, tc.reconcile2Args.pipelineSpec, tc.reconcile2Args.resolvedObjectMeta); err != nil { t.Errorf("storePipelineSpec() error = %v", err) } if d := cmp.Diff(pr, tc.wantPipelineRun); d != "" { @@ -7882,6 +7891,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }, { name: "p-finally", @@ -8036,6 +8055,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }} for _, tt := range tests { @@ -8232,6 +8261,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }} for _, tt := range tests { @@ -8334,6 +8373,7 @@ labels: t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRuns[i].Name, diff.PrintWantGot(d)) } } + if d := cmp.Diff(tt.expectedPipelineRun, pipelineRun, ignoreResourceVersion, ignoreTypeMeta, ignoreLastTransitionTime, ignoreStartTime, ignoreFinallyStartTime, cmpopts.EquateEmpty()); d != "" { t.Errorf("found PipelineRun does not match expected PipelineRun. Diff %s", diff.PrintWantGot(d)) } @@ -8629,6 +8669,16 @@ status: kind: TaskRun name: pr-matrix-include-6 pipelineTaskName: matrix-include + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }, { name: "p-finally", @@ -8821,6 +8871,16 @@ status: kind: TaskRun name: pr-matrix-include-6 pipelineTaskName: matrix-include + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }} for _, tt := range tests { @@ -8872,6 +8932,7 @@ spec: if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } + if d := cmp.Diff(tt.expectedPipelineRun, pipelineRun, ignoreResourceVersion, ignoreTypeMeta, ignoreLastTransitionTime, ignoreStartTime, ignoreFinallyStartTime, cmpopts.EquateEmpty()); d != "" { t.Errorf("expected PipelineRun was not created. Diff %s", diff.PrintWantGot(d)) } @@ -9042,6 +9103,16 @@ status: kind: TaskRun name: pr-matrix-include-2 pipelineTaskName: matrix-include + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }, } @@ -9094,6 +9165,7 @@ spec: if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } + if d := cmp.Diff(tt.expectedPipelineRun, pipelineRun, ignoreResourceVersion, ignoreTypeMeta, ignoreLastTransitionTime, ignoreStartTime, ignoreFinallyStartTime, cmpopts.EquateEmpty()); d != "" { t.Errorf("expected PipelineRun was not created. Diff %s", diff.PrintWantGot(d)) } @@ -9471,6 +9543,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }, { name: "p-finally", @@ -9636,6 +9718,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }} for _, tt := range tests { @@ -9687,6 +9779,7 @@ spec: if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } + if d := cmp.Diff(tt.expectedPipelineRun, pipelineRun, ignoreResourceVersion, ignoreTypeMeta, ignoreLastTransitionTime, ignoreStartTime, ignoreFinallyStartTime, cmpopts.EquateEmpty()); d != "" { t.Errorf("expected PipelineRun was not created. Diff %s", diff.PrintWantGot(d)) } @@ -9847,6 +9940,16 @@ status: kind: TaskRun name: pr-echo-platforms pipelineTaskName: echo-platforms + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }, { name: "indexing results in matrix.params", @@ -9999,6 +10102,16 @@ status: kind: TaskRun name: pr-echo-platforms-2 pipelineTaskName: echo-platforms + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }} for _, tt := range tests { @@ -10205,6 +10318,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), expectedTaskRuns: []*v1beta1.TaskRun{ mustParseTaskRunWithObjectMeta(t, @@ -10391,6 +10514,16 @@ status: kind: TaskRun name: pr-platforms-and-browsers-1 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), expectedTaskRuns: []*v1beta1.TaskRun{ mustParseTaskRunWithObjectMeta(t, @@ -10479,6 +10612,7 @@ status: if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } + if d := cmp.Diff(tt.expectedPipelineRun, pipelineRun, ignoreResourceVersion, ignoreTypeMeta, ignoreLastTransitionTime, ignoreStartTime, cmpopts.SortSlices(lessChildReferences), cmpopts.EquateEmpty()); d != "" { t.Errorf("expected PipelineRun was not created. Diff %s", diff.PrintWantGot(d)) } @@ -10793,6 +10927,16 @@ status: kind: CustomRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }, { name: "p-finally", @@ -10948,6 +11092,16 @@ status: kind: CustomRun name: pr-platforms-and-browsers-8 pipelineTaskName: platforms-and-browsers + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `), }} for _, tt := range tests { @@ -10999,6 +11153,7 @@ spec: if err != nil { t.Fatalf("Got an error getting reconciled run out of fake client: %s", err) } + if d := cmp.Diff(tt.expectedPipelineRun, pipelineRun, ignoreResourceVersion, ignoreTypeMeta, ignoreLastTransitionTime, ignoreStartTime, ignoreFinallyStartTime, cmpopts.EquateEmpty()); d != "" { t.Errorf("expected PipelineRun was not created. Diff %s", diff.PrintWantGot(d)) } diff --git a/pkg/reconciler/taskrun/taskrun_test.go b/pkg/reconciler/taskrun/taskrun_test.go index 23c891969d6..1139e790f30 100644 --- a/pkg/reconciler/taskrun/taskrun_test.go +++ b/pkg/reconciler/taskrun/taskrun_test.go @@ -1656,6 +1656,26 @@ status: startTime: "2021-12-31T23:59:59Z" completionTime: "2022-01-01T00:00:00Z" podName: "test-taskrun-results-type-mismatched-pod" + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableTektonOCIBundles: true + EnableAPIFields: "alpha" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `) reconciliatonError = fmt.Errorf("1 error occurred:\n\t* Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\"") toBeRetriedTaskRun = parse.MustParseV1beta1TaskRun(t, ` @@ -1698,6 +1718,15 @@ status: - reason: TimedOut status: "False" type: Succeeded + provenance: + featureFlags: + RunningInEnvWithInjectedSidecars: true + EnableAPIFields: "stable" + AwaitSidecarReadiness: true + VerificationNoMatchPolicy: "ignore" + EnableProvenanceInStatus: true + ResultExtractionMethod: "termination-message" + MaxResultSize: 4096 `) ) @@ -3771,15 +3800,7 @@ spec: Provenance: &v1beta1.Provenance{ RefSource: refSource.DeepCopy(), ConfigSource: (*v1beta1.ConfigSource)(refSource.DeepCopy()), - FeatureFlags: &config.FeatureFlags{ - RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars, - EnableAPIFields: config.DefaultEnableAPIFields, - AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness, - VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig, - EnableProvenanceInStatus: true, - ResultExtractionMethod: config.DefaultResultExtractionMethod, - MaxResultSize: config.DefaultMaxResultSize, - }, + FeatureFlags: config.DefaultFeatureFlags.DeepCopy(), }, }, } @@ -3831,9 +3852,8 @@ spec: for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - ctx := ttesting.EnableFeatureFlagField(context.Background(), t, "enable-provenance-in-status") // mock first reconcile - if err := storeTaskSpecAndMergeMeta(ctx, tr, tc.reconcile1Args.taskSpec, tc.reconcile1Args.resolvedObjectMeta); err != nil { + if err := storeTaskSpecAndMergeMeta(context.Background(), tr, tc.reconcile1Args.taskSpec, tc.reconcile1Args.resolvedObjectMeta); err != nil { t.Errorf("storePipelineSpec() error = %v", err) } if d := cmp.Diff(tr, tc.wantTaskRun); d != "" { @@ -3841,7 +3861,7 @@ spec: } // mock second reconcile - if err := storeTaskSpecAndMergeMeta(ctx, tr, tc.reconcile2Args.taskSpec, tc.reconcile2Args.resolvedObjectMeta); err != nil { + if err := storeTaskSpecAndMergeMeta(context.Background(), tr, tc.reconcile2Args.taskSpec, tc.reconcile2Args.resolvedObjectMeta); err != nil { t.Errorf("storePipelineSpec() error = %v", err) } if d := cmp.Diff(tr, tc.wantTaskRun); d != "" { diff --git a/test/conversion_test.go b/test/conversion_test.go index f2ffc5f6f98..3158c9a5030 100644 --- a/test/conversion_test.go +++ b/test/conversion_test.go @@ -81,7 +81,7 @@ spec: - name: messages mountPath: /messages imagePullPolicy: IfNotPresent - securityContext: + securityContext: runAsNonRoot: true timeout: 60s secret: @@ -109,7 +109,7 @@ spec: - name: messages mountPath: /messages imagePullPolicy: IfNotPresent - securityContext: + securityContext: runAsNonRoot: true sidecars: - name: server @@ -179,7 +179,7 @@ spec: - name: messages mountPath: /messages imagePullPolicy: IfNotPresent - securityContext: + securityContext: runAsNonRoot: true timeout: 60s secret: @@ -200,7 +200,7 @@ spec: - name: messages mountPath: /messages imagePullPolicy: IfNotPresent - securityContext: + securityContext: runAsNonRoot: true sidecars: - name: server @@ -405,7 +405,7 @@ spec: - name: output workspaces: - emptyDir: {} - name: output + name: output status: conditions: - reason: Succeeded @@ -447,7 +447,7 @@ spec: allowPrivilegeEscalation: false workspaces: - emptyDir: {} - name: output + name: output taskSpec: steps: - computeResources: {} @@ -477,7 +477,7 @@ spec: allowPrivilegeEscalation: false workspaces: - emptyDir: {} - name: output + name: output taskSpec: steps: - computeResources: {} @@ -741,6 +741,12 @@ func TestTaskRunCRDConversion(t *testing.T) { v1TaskRunExpected := parse.MustParseV1TaskRun(t, fmt.Sprintf(v1TaskRunExpectedYaml, v1beta1TaskRunName, namespace, v1beta1TaskRunName)) v1beta1TaskRunRoundTripExpected := parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(v1beta1TaskRunExpectedYaml, v1beta1TaskRunName, namespace, v1beta1TaskRunName)) + v1TaskRunExpected.Status.Provenance = &v1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + v1beta1TaskRunRoundTripExpected.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } if _, err := c.V1beta1TaskRunClient.Create(ctx, v1beta1TaskRun, metav1.CreateOptions{}); err != nil { t.Fatalf("Failed to create v1beta1 TaskRun: %s", err) } @@ -769,6 +775,13 @@ func TestTaskRunCRDConversion(t *testing.T) { v1beta1TaskRunExpected := parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(v1beta1TaskRunExpectedYaml, v1TaskRunName, namespace, v1TaskRunName)) v1TaskRunRoundTripExpected := parse.MustParseV1TaskRun(t, fmt.Sprintf(v1TaskRunExpectedYaml, v1TaskRunName, namespace, v1TaskRunName)) + v1beta1TaskRunExpected.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + v1TaskRunRoundTripExpected.Status.Provenance = &v1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + if _, err := c.V1TaskRunClient.Create(ctx, v1TaskRun, metav1.CreateOptions{}); err != nil { t.Fatalf("Failed to create v1 TaskRun: %s", err) } @@ -875,6 +888,13 @@ func TestPipelineRunCRDConversion(t *testing.T) { v1PipelineRunExpected := parse.MustParseV1PipelineRun(t, fmt.Sprintf(v1PipelineRunExpectedYaml, v1beta1ToV1PipelineRunName, namespace, v1beta1ToV1PipelineRunName)) v1beta1PRRoundTripExpected := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(v1beta1PipelineRunExpectedYaml, v1beta1ToV1PipelineRunName, namespace, v1beta1ToV1PipelineRunName)) + v1PipelineRunExpected.Status.Provenance = &v1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + v1beta1PRRoundTripExpected.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + if _, err := c.V1beta1PipelineRunClient.Create(ctx, v1beta1PipelineRun, metav1.CreateOptions{}); err != nil { t.Fatalf("Failed to create v1beta1 PipelineRun: %s", err) } @@ -903,6 +923,13 @@ func TestPipelineRunCRDConversion(t *testing.T) { v1beta1PipelineRunExpected := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(v1beta1PipelineRunExpectedYaml, v1ToV1beta1PRName, namespace, v1ToV1beta1PRName)) v1PRRoundTripExpected := parse.MustParseV1PipelineRun(t, fmt.Sprintf(v1PipelineRunExpectedYaml, v1ToV1beta1PRName, namespace, v1ToV1beta1PRName)) + v1beta1PipelineRunExpected.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + v1PRRoundTripExpected.Status.Provenance = &v1.Provenance{ + FeatureFlags: getFeatureFlagsBaseOnAPIFlag(t), + } + if _, err := c.V1PipelineRunClient.Create(ctx, v1PipelineRun, metav1.CreateOptions{}); err != nil { t.Fatalf("Failed to create v1 PipelineRun: %s", err) } diff --git a/test/custom_task_test.go b/test/custom_task_test.go index 44aba46a3d5..ac22631b875 100644 --- a/test/custom_task_test.go +++ b/test/custom_task_test.go @@ -20,8 +20,10 @@ limitations under the License. package test import ( + "bytes" "context" "fmt" + "os" "os/exec" "strings" "sync" @@ -30,6 +32,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "github.com/tektoncd/pipeline/test/diff" @@ -409,6 +412,8 @@ func TestWaitCustomTask_V1Beta1_PipelineRun(t *testing.T) { // Cleanup the controller after finishing the test defer cleanUpV1Beta1Controller(t) + featureFlags := getFeatureFlagsBaseOnAPIFlag(t) + for _, tc := range []struct { name string customRunDuration string @@ -635,6 +640,9 @@ func TestWaitCustomTask_V1Beta1_PipelineRun(t *testing.T) { }, }, }, + Provenance: &v1beta1.Provenance{ + FeatureFlags: featureFlags, + }, }, }, } @@ -710,3 +718,50 @@ func resetConfigMap(ctx context.Context, t *testing.T, c *clients, namespace, co t.Log(err) } } + +func getFeatureFlagsBaseOnAPIFlag(t *testing.T) *config.FeatureFlags { + t.Helper() + alphaFeatureFlags, _ := config.NewFeatureFlagsFromMap(map[string]string{ + "enable-api-fields": "alpha", + "results-from": "sidecar-logs", + "enable-tekton-oci-bundles": "true", + }) + betaFeatureFlags, _ := config.NewFeatureFlagsFromMap(map[string]string{ + "enable-api-fields": "beta", + }) + stableFeatureFlags := config.DefaultFeatureFlags.DeepCopy() + + enabledFeatureGate, err := getAPIFeatureGate() + if err != nil { + t.Fatalf("error reading enabled feature gate: %v", err) + } + switch enabledFeatureGate { + case "alpha": + return alphaFeatureFlags + case "beta": + return betaFeatureFlags + default: + return stableFeatureFlags + } +} + +// getAPIFeatureGate queries the tekton pipelines namespace for the +// current value of the "enable-api-fields" feature gate. +func getAPIFeatureGate() (string, error) { + ns := os.Getenv("SYSTEM_NAMESPACE") + if ns == "" { + ns = "tekton-pipelines" + } + + cmd := exec.Command("kubectl", "get", "configmap", "feature-flags", "-n", ns, "-o", `jsonpath="{.data['enable-api-fields']}"`) + output, err := cmd.Output() + if err != nil { + return "", fmt.Errorf("error getting feature-flags configmap: %w", err) + } + output = bytes.TrimSpace(output) + output = bytes.Trim(output, "\"") + if len(output) == 0 { + output = []byte("stable") + } + return string(output), nil +} diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index 9d65ded78e2..0a9a8c6f17b 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -69,7 +69,7 @@ function set_feature_gate() { kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" if [ "$gate" == "alpha" ]; then printf "enabling resolvers\n" - jsonpatch=$(printf "{\"data\": {\"enable-git-resolver\": \"true\", \"enable-hub-resolver\": \"true\", \"enable-bundles-resolver\": \"true\", \"enable-cluster-resolver\": \"true\", \"enable-provenance-in-status\": \"true\"}}") + jsonpatch=$(printf "{\"data\": {\"enable-git-resolver\": \"true\", \"enable-hub-resolver\": \"true\", \"enable-bundles-resolver\": \"true\", \"enable-cluster-resolver\": \"true\"}}") echo "resolvers-feature-flags ConfigMap patch: ${jsonpatch}" kubectl patch configmap resolvers-feature-flags -n tekton-pipelines-resolvers -p "$jsonpatch" fi diff --git a/test/larger_results_sidecar_logs_test.go b/test/larger_results_sidecar_logs_test.go index ef31475eaa4..11acafe5af1 100644 --- a/test/larger_results_sidecar_logs_test.go +++ b/test/larger_results_sidecar_logs_test.go @@ -45,7 +45,9 @@ var ( ) func TestLargerResultsSidecarLogs(t *testing.T) { - t.Parallel() + expectedFeatureFlags := getFeatureFlagsBaseOnAPIFlag(t) + previousResultExtractionMethod := expectedFeatureFlags.ResultExtractionMethod + type tests struct { name string pipelineName string @@ -61,18 +63,27 @@ func TestLargerResultsSidecarLogs(t *testing.T) { for _, td := range tds { td := td t.Run(td.name, func(t *testing.T) { - t.Parallel() ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() c, namespace := setUpSidecarLogs(ctx, t, requireAllGates(requireSidecarLogResultsGate)) + expectedFeatureFlags.ResultExtractionMethod = config.ResultExtractionMethodSidecarLogs + + // reset configmap + knativetest.CleanupOnInterrupt(func() { resetSidecarLogs(ctx, t, c, previousResultExtractionMethod) }, t.Logf) + defer resetSidecarLogs(ctx, t, c, previousResultExtractionMethod) knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf) defer tearDown(ctx, t, c, namespace) t.Logf("Setting up test resources for %q test in namespace %s", td.name, namespace) pipelineRun, expectedResolvedPipelineRun, expectedTaskRuns := td.pipelineRunFunc(t, namespace) + + expectedResolvedPipelineRun.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: expectedFeatureFlags, + } + prName := pipelineRun.Name _, err := c.V1beta1PipelineRunClient.Create(ctx, pipelineRun, metav1.CreateOptions{}) if err != nil { @@ -98,6 +109,9 @@ func TestLargerResultsSidecarLogs(t *testing.T) { t.Fatalf(`The resolved spec does not match the expected spec. Here is the diff: %v`, d) } for _, tr := range expectedTaskRuns { + tr.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: expectedFeatureFlags, + } t.Logf("Checking Taskrun %s", tr.Name) taskrun, _ := c.V1beta1TaskRunClient.Get(ctx, tr.Name, metav1.GetOptions{}) d = cmp.Diff(tr, taskrun, @@ -114,6 +128,7 @@ func TestLargerResultsSidecarLogs(t *testing.T) { t.Fatalf(`The expected taskrun does not match created taskrun. Here is the diff: %v`, d) } } + t.Logf("Successfully finished test %q", td.name) }) } @@ -162,7 +177,7 @@ spec: echo -n "$(params.param1)">> $(results.large-result.path); echo -n "$(params.param2)">> $(results.large-result.path); results: - - name: large-result + - name: large-result value: $(tasks.task2.results.large-result) `, namespace, strings.Repeat("a", 2000), strings.Repeat("b", 2000))) expectedPipelineRun := parse.MustParseV1beta1PipelineRun(t, fmt.Sprintf(` @@ -211,7 +226,7 @@ spec: echo -n "$(params.param1)">> $(results.large-result.path); echo -n "$(params.param2)">> $(results.large-result.path); results: - - name: large-result + - name: large-result value: $(tasks.task2.results.large-result) status: pipelineSpec: @@ -253,7 +268,7 @@ status: echo -n "$(params.param1)">> $(results.large-result.path); echo -n "$(params.param2)">> $(results.large-result.path); results: - - name: large-result + - name: large-result value: $(tasks.task2.results.large-result) pipelineResults: - name: large-result @@ -305,7 +320,7 @@ status: value: %s sidecars: - name: tekton-log-results - container: sidecar-tekton-log-results + container: sidecar-tekton-log-results `, namespace, strings.Repeat("a", 2000), strings.Repeat("b", 2000), strings.Repeat("a", 2000), strings.Repeat("b", 2000), strings.Repeat("a", 2000), strings.Repeat("b", 2000))) taskRun2 := parse.MustParseV1beta1TaskRun(t, fmt.Sprintf(` metadata: @@ -317,9 +332,9 @@ spec: params: - name: param1 type: string - value: %s + value: %s - name: param2 - type: string + type: string value: %s taskSpec: params: @@ -367,7 +382,7 @@ status: value: %s%s sidecars: - name: tekton-log-results - container: sidecar-tekton-log-results + container: sidecar-tekton-log-results `, namespace, strings.Repeat("a", 2000), strings.Repeat("b", 2000), strings.Repeat("a", 2000), strings.Repeat("b", 2000), strings.Repeat("a", 2000), strings.Repeat("b", 2000))) return pipelineRun, expectedPipelineRun, []*v1beta1.TaskRun{taskRun1, taskRun2} } @@ -384,3 +399,10 @@ func setUpSidecarLogs(ctx context.Context, t *testing.T, fn ...func(context.Cont } return c, ns } + +func resetSidecarLogs(ctx context.Context, t *testing.T, c *clients, previousResultExtractionMethod string) { + t.Helper() + if err := updateConfigMap(ctx, c.KubeClient, system.Namespace(), config.GetFeatureFlagsConfigName(), map[string]string{"results-from": previousResultExtractionMethod}); err != nil { + t.Fatal(err) + } +} diff --git a/test/propagated_params_test.go b/test/propagated_params_test.go index e1d9a7e4ff6..52e4c00c450 100644 --- a/test/propagated_params_test.go +++ b/test/propagated_params_test.go @@ -52,6 +52,8 @@ var ( func TestPropagatedParams(t *testing.T) { t.Parallel() + + expectedFeatureFlags := getFeatureFlagsBaseOnAPIFlag(t) type tests struct { name string pipelineName string @@ -91,6 +93,11 @@ func TestPropagatedParams(t *testing.T) { t.Logf("Setting up test resources for %q test in namespace %s", td.name, namespace) pipelineRun, expectedResolvedPipelineRun, expectedTaskRuns := td.pipelineRunFunc(t, namespace) + + expectedResolvedPipelineRun.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: expectedFeatureFlags, + } + prName := pipelineRun.Name _, err := c.V1beta1PipelineRunClient.Create(ctx, pipelineRun, metav1.CreateOptions{}) if err != nil { @@ -118,6 +125,9 @@ func TestPropagatedParams(t *testing.T) { } for _, tr := range expectedTaskRuns { t.Logf("Checking Taskrun %s", tr.Name) + tr.Status.Provenance = &v1beta1.Provenance{ + FeatureFlags: expectedFeatureFlags, + } taskrun, _ := c.V1beta1TaskRunClient.Get(ctx, tr.Name, metav1.GetOptions{}) d = cmp.Diff(tr, taskrun, ignoreTypeMeta, diff --git a/test/status_test.go b/test/status_test.go index 72b790d456e..d37c6b31291 100644 --- a/test/status_test.go +++ b/test/status_test.go @@ -33,16 +33,12 @@ import ( "github.com/tektoncd/pipeline/test/diff" "github.com/tektoncd/pipeline/test/parse" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/system" knativetest "knative.dev/pkg/test" "knative.dev/pkg/test/helpers" "sigs.k8s.io/yaml" ) var ( - provenanceFeatureFlags = requireAllGates(map[string]string{ - "enable-provenance-in-status": "true", - }) ignoreFeatureFlags = cmpopts.IgnoreFields(v1beta1.Provenance{}, "FeatureFlags") ) @@ -126,9 +122,9 @@ spec: // about the remote task i.e. refSource info . func TestProvenanceFieldInPipelineRunTaskRunStatus(t *testing.T) { ctx := context.Background() - c, namespace := setupProvenance(ctx, t, clusterFeatureFlags, provenanceFeatureFlags) - knativetest.CleanupOnInterrupt(func() { unsetProvenanceFlags(ctx, t, c) }, t.Logf) - defer unsetProvenanceFlags(ctx, t, c) + ctx, cancel := context.WithCancel(ctx) + defer cancel() + c, namespace := setup(ctx, t) knativetest.CleanupOnInterrupt(func() { tearDown(ctx, t, c, namespace) }, t.Logf) defer tearDown(ctx, t, c, namespace) @@ -152,9 +148,6 @@ func TestProvenanceFieldInPipelineRunTaskRunStatus(t *testing.T) { URI: fmt.Sprintf("/apis/%s/namespaces/%s/%s/%s@%s", v1beta1.SchemeGroupVersion.String(), namespace, "task", exampleTask.Name, exampleTask.UID), Digest: map[string]string{"sha256": sha256CheckSum(taskSpec)}, }, - FeatureFlags: &config.FeatureFlags{ - EnableProvenanceInStatus: true, - }, } // example pipeline @@ -304,27 +297,3 @@ func sha256CheckSum(input []byte) string { h.Write(input) return hex.EncodeToString(h.Sum(nil)) } - -func setupProvenance(ctx context.Context, t *testing.T, fn ...func(context.Context, *testing.T, *clients, string)) (*clients, string) { - t.Helper() - c, ns := setup(ctx, t) - configMapData := map[string]string{ - "enable-provenance-in-status": "true", - } - - if err := updateConfigMap(ctx, c.KubeClient, system.Namespace(), config.GetFeatureFlagsConfigName(), configMapData); err != nil { - t.Fatal(err) - } - return c, ns -} - -func unsetProvenanceFlags(ctx context.Context, t *testing.T, c *clients) { - t.Helper() - configMapData := map[string]string{ - "enable-provenance-in-status": "false", - } - - if err := updateConfigMap(ctx, c.KubeClient, system.Namespace(), config.GetFeatureFlagsConfigName(), configMapData); err != nil { - t.Fatal(err) - } -}