Skip to content

Commit bfff75b

Browse files
abayertekton-robot
authored andcommitted
[TEP-0100] Fields/flags/docs for embedded TaskRun and Run statuses in PipelineRuns
See https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md This adds new choices for how `TaskRun` and `Run` statuses are stored/referenced in `PipelineRun` statuses, depending on how the new feature flag, `embedded-status` is set: * `full` - the current default, with the `TaskRun` and `Run` statuses embedded in full. * `minimal` - instead of storing the full embedded statuses, information is stored about the task's version, kind, `PipelineTask` name, and the underlying name of the `TaskRun` or `Run`. This can be used to look up the `TaskRun` or `Run` itself and get the full status from there. Information which is specific to the `PipelineRun`, namely condition checks status and when expressions which may have blocked creation of an actual `TaskRun` or `Run` are stored as well. * `both` - both the full embedded `TaskRun` and `Run` statuses and the minimal references are stored. The condition check information will be removed from the minimal references once the now-deprecated condition check functionality is removed from Tekton Pipeline. As described in https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md#beta-api, 9 months after this change has been released in `v1beta1`, the default value for the `embedded-status` feature flag will be changed from `full` to `minimal`, and a few months after that, the `embedded-status` feature flag will be removed entirely and only the `minimal` behavior will remain. Note that this also may address tektoncd#4657, since I had to add documentation for `PipelineRunStatus`, and while I was there, I added some missing top-level fields to the `PipelineRun` definition. The actual implementation will follow this PR. Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
1 parent 30461c5 commit bfff75b

File tree

11 files changed

+498
-100
lines changed

11 files changed

+498
-100
lines changed

docs/install.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ features](#alpha-features) to be used.
390390
to "false" to guard a `Task` and its dependent `Tasks`. It defaults to "true". For more information, see [guarding
391391
`Task` execution using `when` expressions](pipelines.md#guard-task-execution-using-whenexpressions).
392392

393+
- `embedded-status`: set this flag to "full" to enable full embedding of `TaskRun` and `Run` statuses in the
394+
`PipelineRun` status. Set it to "minimal" to populate the `ChildReferences` field in the `PipelineRun` status with
395+
name, kind, and API version information for each `TaskRun` and `Run` in the `PipelineRun` instead. Set it to "both" to
396+
do both. For more information, see [Configuring usage of `TaskRun` and `Run` embedded statuses](pipelineruns.md#configuring-usage-of-taskrun-and-run-embedded-statuses). **NOTE**: This functionality is not yet active.
397+
393398
For example:
394399

395400
```yaml
@@ -423,6 +428,7 @@ Features currently in "alpha" are:
423428
| [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) | |
424429
| [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) | | |
425430
| [Matrix](./matrix.md) | [TEP-0090](https://github.com/tektoncd/community/blob/main/teps/0090-matrix.md) | | |
431+
| [Embedded Statuse](pipelineruns.md#configuring-usage-of-taskrun-and-run-embedded-statuses) | [TEP-0100](https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md) | | |
426432

427433
## Configuring High Availability
428434

docs/pipelineruns.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ weight: 500
2323
- [Specifying <code>Workspaces</code>](#specifying-workspaces)
2424
- [Specifying <code>LimitRange</code> values](#specifying-limitrange-values)
2525
- [Configuring a failure timeout](#configuring-a-failure-timeout)
26-
- [Monitoring execution status](#monitoring-execution-status)
26+
- [<code>PipelineRun</code> status](#pipelinerun-status)
27+
- [The <code>status</code> field](#the-status-field)
28+
- [Configuring usage of <code>TaskRun</code> and <code>Run</code> embedded statuses](#configuring-usage-of-taskrun-and-run-embedded-statuses)
29+
- [Monitoring execution status](#monitoring-execution-status)
2730
- [Cancelling a <code>PipelineRun</code>](#cancelling-a-pipelinerun)
2831
- [Gracefully cancelling a <code>PipelineRun</code>](#gracefully-cancelling-a-pipelinerun)
2932
- [Gracefully stopping a <code>PipelineRun</code>](#gracefully-stopping-a-pipelinerun)
@@ -67,10 +70,11 @@ A `PipelineRun` definition supports the following fields:
6770
object that supplies specific execution credentials for the `Pipeline`.
6871
- [`serviceAccountNames`](#mapping-serviceaccount-credentials-to-tasks) - Maps specific `serviceAccountName` values
6972
to `Tasks` in the `Pipeline`. This overrides the credentials set for the entire `Pipeline`.
70-
- [`taskRunSpec`](#specifying-taskrunspecs) - Specifies a list of `PipelineRunTaskSpec` which allows for setting `ServiceAccountName` and [`Pod` template](./podtemplates.md) for each task. This overrides the `Pod` template set for the entire `Pipeline`.
71-
- [`timeout`](#configuring-a-failure-timeout) - Specifies the timeout before the `PipelineRun` fails.
72-
- [`podTemplate`](#specifying-a-pod-template) - Specifies a [`Pod` template](./podtemplates.md) to use as the basis
73-
for the configuration of the `Pod` that executes each `Task`.
73+
- [`taskRunSpecs`](#specifying-taskrunspecs) - Specifies a list of `PipelineRunTaskSpec` which allows for setting `ServiceAccountName` and [`Pod` template](./podtemplates.md) for each task. This overrides the `Pod` template set for the entire `Pipeline`.
74+
- [`timeout`](#configuring-a-failure-timeout) - Specifies the timeout before the `PipelineRun` fails. `timeout` is deprecated and will eventually be removed, so consider using `timeouts` instead.
75+
- [`timeouts`](#configuring-a-failure-timeout) - Specifies the timeout before the `PipelineRun` fails. `timeouts` allows more granular timeout configuration, at the pipeline, tasks, and finally levels
76+
- [`podTemplate`](#specifying-a-pod-template) - Specifies a [`Pod` template](./podtemplates.md) to use as the basis for the configuration of the `Pod` that executes each `Task`.
77+
- [`workspaces`](#specifying-workspaces) - Specifies a set of workspace bindings which must match the names of workspaces declared in the pipeline being used.
7478

7579
[kubernetes-overview]:
7680
https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#required-fields
@@ -560,7 +564,43 @@ The `timeout` value is a `duration` conforming to Go's
560564
values are `1h30m`, `1h`, `1m`, and `60s`. If you set the global timeout to 0, all `PipelineRuns`
561565
that do not have an individual timeout set will fail immediately upon encountering an error.
562566

563-
## Monitoring execution status
567+
## `PipelineRun` status
568+
569+
### The `status` field
570+
571+
Your `PipelineRun`'s `status` field can contain the following fields:
572+
573+
- Required:
574+
- `status` - Most relevant, `status.conditions`, which contains the latest observations of the `PipelineRun`'s state. [See here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties) for information on typical status properties.
575+
- `startTime` - The time at which the `PipelineRun` began executing, in [RFC3339](https://tools.ietf.org/html/rfc3339) format.
576+
- `completionTime` - The time at which the `PipelineRun` finished executing, in [RFC3339](https://tools.ietf.org/html/rfc3339) format.
577+
- [`pipelineSpec`](pipelines.md#configuring-a-pipeline) - The exact `PipelineSpec` used when starting the `PipelineRun`.
578+
- Optional:
579+
- `taskRuns` - A map of `TaskRun` names to detailed information about the status of that `TaskRun`. This is deprecated and will be removed in favor of using `childReferences`.
580+
- `runs` - A map of custom task `Run` names to detailed information about the status of that `Run`. This is deprecated and will be removed in favor of using `childReferences`.
581+
- [`pipelineResults`](pipelines.md#emitting-results-from-a-pipeline) - Results emitted by this `PipelineRun`.
582+
- `skippedTasks` - A list of `Task`s which were skipped when running this `PipelineRun` due to [when expressions](pipelines.md#guard-task-execution-using-when-expressions), including the when expressions applying to the skipped task.
583+
- `childReferences` - A list of references to each `TaskRun` or `Run` in this `PipelineRun`, which can be used to look up the status of the underlying `TaskRun` or `Run`. Each entry contains the following:
584+
- [`kind`][kubernetes-overview] - Generally either `TaskRun` or `Run`.
585+
- [`apiVersion`][kubernetes-overview] - The API version for the underlying `TaskRun` or `Run`.
586+
- `conditionChecks` - A list of [condition checks](conditions.md) performed for this `TaskRun`. `conditions` are deprecated and this will be removed in the future.
587+
- [`whenExpressions`](pipelines.md#guard-task-execution-using-when-expressions) - The list of when expressions guarding the execution of this task.
588+
589+
### Configuring usage of `TaskRun` and `Run` embedded statuses
590+
591+
Currently, the default behavior is for the statuses of `TaskRun`s and `Run`s within this `PipelineRun`
592+
to be embedded in the `status.taskRuns` and `status.runs` fields. This will change in the future to
593+
instead default to `status.childReferences` being populated with references to the `TaskRun`s and
594+
`Run`s, which can be used to look up their statuses.
595+
596+
This behavior can be controlled by changing the `embedded-status` feature flag in the `feature-flags`
597+
config map. See [`install.md`](./install.md#customizing-the-pipelines-controller-behavior) for more
598+
information on feature flags. The possible values for `embedded-status` are:
599+
- `full` - The current default behavior of populating `status.taskRuns` and `status.runs`, without populating `status.childReferences`.
600+
- `minimal` - Just populate `status.childReferences`, not `status.taskRuns` or `status.runs`.
601+
- `both` - Populate `status.childReferences` as well as `status.taskRuns` and `status.runs`.
602+
603+
### Monitoring execution status
564604

565605
As your `PipelineRun` executes, its `status` field accumulates information on the execution of each `TaskRun`
566606
as well as the `PipelineRun` as a whole. This information includes the name of the pipeline `Task` associated

pkg/apis/config/feature_flags.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ const (
3030
StableAPIFields = "stable"
3131
// AlphaAPIFields is the value used for "enable-api-fields" when alpha APIs should be usable as well.
3232
AlphaAPIFields = "alpha"
33+
// FullEmbeddedStatus is the value used for "embedded-status" when the full statuses of TaskRuns and Runs should be
34+
// embedded in PipelineRunStatusFields, but ChildReferences should not be used.
35+
FullEmbeddedStatus = "full"
36+
// BothEmbeddedStatus is the value used for "embedded-status" when full embedded statuses of TaskRuns and Runs as
37+
// well as ChildReferences should be used in PipelineRunStatusFields.
38+
BothEmbeddedStatus = "both"
39+
// MinimalEmbeddedStatus is the value used for "embedded-status" when only ChildReferences should be used in
40+
// PipelineRunStatusFields.
41+
MinimalEmbeddedStatus = "minimal"
3342
// DefaultDisableAffinityAssistant is the default value for "disable-affinity-assistant".
3443
DefaultDisableAffinityAssistant = false
3544
// DefaultDisableCredsInit is the default value for "disable-creds-init".
@@ -48,6 +57,8 @@ const (
4857
DefaultEnableAPIFields = StableAPIFields
4958
// DefaultSendCloudEventsForRuns is the default value for "send-cloudevents-for-runs".
5059
DefaultSendCloudEventsForRuns = false
60+
// DefaultEmbeddedStatus is the default value for "embedded-status".
61+
DefaultEmbeddedStatus = FullEmbeddedStatus
5162

5263
disableAffinityAssistantKey = "disable-affinity-assistant"
5364
disableCredsInitKey = "disable-creds-init"
@@ -58,6 +69,7 @@ const (
5869
enableAPIFields = "enable-api-fields"
5970
scopeWhenExpressionsToTask = "scope-when-expressions-to-task"
6071
sendCloudEventsForRuns = "send-cloudevents-for-runs"
72+
embeddedStatus = "embedded-status"
6173
)
6274

6375
// FeatureFlags holds the features configurations
@@ -72,6 +84,7 @@ type FeatureFlags struct {
7284
ScopeWhenExpressionsToTask bool
7385
EnableAPIFields string
7486
SendCloudEventsForRuns bool
87+
EmbeddedStatus string
7588
}
7689

7790
// GetFeatureFlagsConfigName returns the name of the configmap containing all
@@ -120,6 +133,9 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) {
120133
if err := setFeature(sendCloudEventsForRuns, DefaultSendCloudEventsForRuns, &tc.SendCloudEventsForRuns); err != nil {
121134
return nil, err
122135
}
136+
if err := setEmbeddedStatus(cfgMap, DefaultEmbeddedStatus, &tc.EmbeddedStatus); err != nil {
137+
return nil, err
138+
}
123139

124140
// Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if
125141
// enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of
@@ -157,6 +173,22 @@ func setEnabledAPIFields(cfgMap map[string]string, defaultValue string, feature
157173
return nil
158174
}
159175

176+
// setEmbeddedStatus sets the "embedded-status" flag based on the content of a given map.
177+
// If the feature gate is invalid or missing then an error is returned.
178+
func setEmbeddedStatus(cfgMap map[string]string, defaultValue string, feature *string) error {
179+
value := defaultValue
180+
if cfg, ok := cfgMap[embeddedStatus]; ok {
181+
value = strings.ToLower(cfg)
182+
}
183+
switch value {
184+
case FullEmbeddedStatus, BothEmbeddedStatus, MinimalEmbeddedStatus:
185+
*feature = value
186+
default:
187+
return fmt.Errorf("invalid value for feature flag %q: %q", embeddedStatus, value)
188+
}
189+
return nil
190+
}
191+
160192
// NewFeatureFlagsFromConfigMap returns a Config for the given configmap
161193
func NewFeatureFlagsFromConfigMap(config *corev1.ConfigMap) (*FeatureFlags, error) {
162194
return NewFeatureFlagsFromMap(config.Data)

pkg/apis/config/feature_flags_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
3838
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
3939
ScopeWhenExpressionsToTask: config.DefaultScopeWhenExpressionsToTask,
4040
EnableAPIFields: "stable",
41+
EmbeddedStatus: config.DefaultEmbeddedStatus,
4142
},
4243
fileName: config.GetFeatureFlagsConfigName(),
4344
},
@@ -51,6 +52,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
5152
ScopeWhenExpressionsToTask: true,
5253
EnableAPIFields: "alpha",
5354
SendCloudEventsForRuns: true,
55+
EmbeddedStatus: "both",
5456
},
5557
fileName: "feature-flags-all-flags-set",
5658
},
@@ -64,6 +66,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
6466

6567
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
6668
ScopeWhenExpressionsToTask: config.DefaultScopeWhenExpressionsToTask,
69+
EmbeddedStatus: config.DefaultEmbeddedStatus,
6770
},
6871
fileName: "feature-flags-enable-api-fields-overrides-bundles-and-custom-tasks",
6972
},
@@ -75,6 +78,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
7578

7679
RunningInEnvWithInjectedSidecars: config.DefaultRunningInEnvWithInjectedSidecars,
7780
ScopeWhenExpressionsToTask: config.DefaultScopeWhenExpressionsToTask,
81+
EmbeddedStatus: config.DefaultEmbeddedStatus,
7882
},
7983
fileName: "feature-flags-bundles-and-custom-tasks",
8084
},
@@ -95,6 +99,7 @@ func TestNewFeatureFlagsFromEmptyConfigMap(t *testing.T) {
9599
RunningInEnvWithInjectedSidecars: true,
96100
ScopeWhenExpressionsToTask: config.DefaultScopeWhenExpressionsToTask,
97101
EnableAPIFields: "stable",
102+
EmbeddedStatus: config.DefaultEmbeddedStatus,
98103
}
99104
verifyConfigFileWithExpectedFeatureFlagsConfig(t, FeatureFlagsConfigEmptyName, expectedConfig)
100105
}
@@ -137,6 +142,8 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) {
137142
fileName: "feature-flags-invalid-boolean",
138143
}, {
139144
fileName: "feature-flags-invalid-enable-api-fields",
145+
}, {
146+
fileName: "feature-flags-invalid-embedded-status",
140147
}, {
141148
fileName: "feature-flags-invalid-scope-when-expressions-to-task",
142149
}} {

pkg/apis/config/testdata/feature-flags-all-flags-set.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ data:
2626
scope-when-expressions-to-task: "true"
2727
enable-api-fields: "alpha"
2828
send-cloudevents-for-runs: "true"
29+
embedded-status: "both"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2021 The Tekton Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: v1
16+
kind: ConfigMap
17+
metadata:
18+
name: feature-flags
19+
namespace: tekton-pipelines
20+
data:
21+
embedded-status: "im-not-a-valid-feature-gate"

0 commit comments

Comments
 (0)