-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEP-0090: Matrix - Minimal Status is Required
[TEP-0090: Matrix][tep-0090] proposed executing a `PipelineTask` in parallel `TaskRuns` and `Runs` with substitutions from combinations of `Parameters` in a `Matrix`. The status of `PipelineRuns` with fanned-out `PipelineTasks` will list all the `TaskRuns` and `Runs` created. In [TEP-0100][tep-0100] we proposed changes to `PipelineRun` status to reduce the amount of information stored about the status of `TaskRuns` and `Runs` to improve performance, reduce memory bloat and improve extensibility. With the minimal `PipelineRun` status, we can handle `Matrix` without exacerbating the performance and storage issues that were there before. In this change, we validate that minimal embedded status is enabled when a `PipelineTask` has a `Matrix`. [tep-0090]: https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md [tep-0100]: https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md
- Loading branch information
Showing
5 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2022 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/tektoncd/pipeline/pkg/apis/config" | ||
"knative.dev/pkg/apis" | ||
) | ||
|
||
// ValidateEmbeddedStatus checks that the embedded-status feature gate is set to the wantEmbeddedStatus value and, | ||
// if not, returns an error stating which feature is dependent on the status and what the current status actually is. | ||
func ValidateEmbeddedStatus(ctx context.Context, featureName, wantEmbeddedStatus string) *apis.FieldError { | ||
embeddedStatus := config.FromContextOrDefaults(ctx).FeatureFlags.EmbeddedStatus | ||
if embeddedStatus != wantEmbeddedStatus { | ||
message := fmt.Sprintf(`%s requires "embedded-status" feature gate to be %q but it is %q`, featureName, wantEmbeddedStatus, embeddedStatus) | ||
return apis.ErrGeneric(message) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
Copyright 2022 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/tektoncd/pipeline/pkg/apis/config" | ||
) | ||
|
||
func TestValidateEmbeddedStatus(t *testing.T) { | ||
status := "minimal" | ||
flags, err := config.NewFeatureFlagsFromMap(map[string]string{ | ||
"embedded-status": status, | ||
}) | ||
if err != nil { | ||
t.Fatalf("error creating feature flags from map: %v", err) | ||
} | ||
cfg := &config.Config{ | ||
FeatureFlags: flags, | ||
} | ||
ctx := config.ToContext(context.Background(), cfg) | ||
if err := ValidateEmbeddedStatus(ctx, "test feature", status); err != nil { | ||
t.Errorf("unexpected error for compatible feature gates: %q", err) | ||
} | ||
} | ||
|
||
func TestValidateEmbeddedStatusError(t *testing.T) { | ||
flags, err := config.NewFeatureFlagsFromMap(map[string]string{ | ||
"embedded-status": config.FullEmbeddedStatus, | ||
}) | ||
if err != nil { | ||
t.Fatalf("error creating feature flags from map: %v", err) | ||
} | ||
cfg := &config.Config{ | ||
FeatureFlags: flags, | ||
} | ||
ctx := config.ToContext(context.Background(), cfg) | ||
err = ValidateEmbeddedStatus(ctx, "test feature", config.MinimalEmbeddedStatus) | ||
if err == nil { | ||
t.Errorf("error expected for incompatible feature gates") | ||
} | ||
} |