Skip to content

Commit

Permalink
TEP-0090: Matrix - Max Matrix Combinations Count is 256
Browse files Browse the repository at this point in the history
[TEP-0090: Matrix][tep-0090] proposed executing a `PipelineTask` in
parallel `TaskRuns` and `Runs` with substitutions from combinations
of `Parameters` in a `Matrix`.

In #4947, we implemented the
[concurrency controls][cc]. In this change, we implemented that the
default value is 256 if it's not specified by the user.

[tep-0090]: https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md
[cc]: https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md#concurrency-control
  • Loading branch information
jerop authored and tekton-robot committed Jun 21, 2022
1 parent 9c2da98 commit 5ab5f20
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
14 changes: 9 additions & 5 deletions pkg/apis/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const (
DefaultManagedByLabelValue = "tekton-pipelines"
// DefaultCloudEventSinkValue is the default value for cloud event sinks.
DefaultCloudEventSinkValue = ""
// DefaultMaxMatrixCombinationsCount is used when no max matrix combinations count is specified.
DefaultMaxMatrixCombinationsCount = 256

defaultTimeoutMinutesKey = "default-timeout-minutes"
defaultServiceAccountKey = "default-service-account"
Expand Down Expand Up @@ -88,16 +90,18 @@ func (cfg *Defaults) Equals(other *Defaults) bool {
other.DefaultPodTemplate.Equals(cfg.DefaultPodTemplate) &&
other.DefaultAAPodTemplate.Equals(cfg.DefaultAAPodTemplate) &&
other.DefaultCloudEventsSink == cfg.DefaultCloudEventsSink &&
other.DefaultTaskRunWorkspaceBinding == cfg.DefaultTaskRunWorkspaceBinding
other.DefaultTaskRunWorkspaceBinding == cfg.DefaultTaskRunWorkspaceBinding &&
other.DefaultMaxMatrixCombinationsCount == cfg.DefaultMaxMatrixCombinationsCount
}

// NewDefaultsFromMap returns a Config given a map corresponding to a ConfigMap
func NewDefaultsFromMap(cfgMap map[string]string) (*Defaults, error) {
tc := Defaults{
DefaultTimeoutMinutes: DefaultTimeoutMinutes,
DefaultServiceAccount: DefaultServiceAccountValue,
DefaultManagedByLabelValue: DefaultManagedByLabelValue,
DefaultCloudEventsSink: DefaultCloudEventSinkValue,
DefaultTimeoutMinutes: DefaultTimeoutMinutes,
DefaultServiceAccount: DefaultServiceAccountValue,
DefaultManagedByLabelValue: DefaultManagedByLabelValue,
DefaultCloudEventsSink: DefaultCloudEventSinkValue,
DefaultMaxMatrixCombinationsCount: DefaultMaxMatrixCombinationsCount,
}

if defaultTimeoutMin, ok := cfgMap[defaultTimeoutMinutesKey]; ok {
Expand Down
33 changes: 19 additions & 14 deletions pkg/apis/config/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ func TestNewDefaultsFromConfigMap(t *testing.T) {
testCases := []testCase{
{
expectedConfig: &config.Defaults{
DefaultTimeoutMinutes: 50,
DefaultServiceAccount: "tekton",
DefaultManagedByLabelValue: "something-else",
DefaultTimeoutMinutes: 50,
DefaultServiceAccount: "tekton",
DefaultManagedByLabelValue: "something-else",
DefaultMaxMatrixCombinationsCount: 256,
},
fileName: config.GetDefaultsConfigName(),
},
Expand All @@ -57,6 +58,7 @@ func TestNewDefaultsFromConfigMap(t *testing.T) {
"label": "value2",
},
},
DefaultMaxMatrixCombinationsCount: 256,
},
fileName: "config-defaults-with-pod-template",
},
Expand All @@ -71,20 +73,22 @@ func TestNewDefaultsFromConfigMap(t *testing.T) {
expectedError: false,
fileName: "config-defaults-pod-template-err",
expectedConfig: &config.Defaults{
DefaultTimeoutMinutes: 50,
DefaultServiceAccount: "tekton",
DefaultManagedByLabelValue: config.DefaultManagedByLabelValue,
DefaultPodTemplate: &pod.Template{},
DefaultTimeoutMinutes: 50,
DefaultServiceAccount: "tekton",
DefaultManagedByLabelValue: config.DefaultManagedByLabelValue,
DefaultPodTemplate: &pod.Template{},
DefaultMaxMatrixCombinationsCount: 256,
},
},
{
expectedError: false,
fileName: "config-defaults-aa-pod-template-err",
expectedConfig: &config.Defaults{
DefaultTimeoutMinutes: 50,
DefaultServiceAccount: "tekton",
DefaultManagedByLabelValue: config.DefaultManagedByLabelValue,
DefaultAAPodTemplate: &pod.AffinityAssistantTemplate{},
DefaultTimeoutMinutes: 50,
DefaultServiceAccount: "tekton",
DefaultManagedByLabelValue: config.DefaultManagedByLabelValue,
DefaultAAPodTemplate: &pod.AffinityAssistantTemplate{},
DefaultMaxMatrixCombinationsCount: 256,
},
},
{
Expand Down Expand Up @@ -117,9 +121,10 @@ func TestNewDefaultsFromConfigMap(t *testing.T) {
func TestNewDefaultsFromEmptyConfigMap(t *testing.T) {
DefaultsConfigEmptyName := "config-defaults-empty"
expectedConfig := &config.Defaults{
DefaultTimeoutMinutes: 60,
DefaultManagedByLabelValue: "tekton-pipelines",
DefaultServiceAccount: "default",
DefaultTimeoutMinutes: 60,
DefaultManagedByLabelValue: "tekton-pipelines",
DefaultServiceAccount: "default",
DefaultMaxMatrixCombinationsCount: 256,
}
verifyConfigFileWithExpectedConfig(t, DefaultsConfigEmptyName, expectedConfig)
}
Expand Down

0 comments on commit 5ab5f20

Please sign in to comment.