Skip to content

Commit 7cf6f5b

Browse files
committed
change resource-verification-mode to verification-no-match-policy
This commits changes trusted resources feature flag from resource-verification-mode to verification-no-match-policy. This is a backward imcompatiable change as discussed in TEP--0091. Before this commit the feature flag is used to skip/enforce the verification. This commit changes this to check the existence of matched VerificationPolicy. So to enable the verification, users just need to apply VerificationPolicy to match the resources. To disable the verification, users need to remove the policies and set the verification-no-match-policy to allow (by default). Signed-off-by: Yongxuan Zhang [email protected]
1 parent 808c7fe commit 7cf6f5b

22 files changed

+334
-306
lines changed

config/config-feature-flags.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ data:
7676
# Setting this flag to "true" enables CloudEvents for CustomRuns and Runs, as long as a
7777
# CloudEvents sink is configured in the config-defaults config map
7878
send-cloudevents-for-runs: "false"
79-
# Setting this flag to "enforce" will enforce verification of tasks/pipeline. Failing to verify
80-
# will fail the taskrun/pipelinerun. "warn" will only log the err message and "skip"
81-
# will skip the whole verification
82-
resource-verification-mode: "skip"
79+
# Setting this flag to "deny" will enforce verification of tasks/pipeline. Failing to verify
80+
# will fail the taskrun/pipelinerun. "warn" will only log the err message and "allow"
81+
# will skip the whole verification if no matching policies are found.
82+
verification-no-match-policy: "allow"
8383
# Setting this flag to "true" enables populating the "provenance" field in TaskRun
8484
# and PipelineRun status. This field contains metadata about resources used
8585
# in the TaskRun/PipelineRun such as the source from where a remote Task/Pipeline

docs/additional-configs.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
---
33
title: "Additional Configuration Options"
44
linkTitle: "Additional Configuration Options"
5-
weight: 109
5+
weight: 109
66
description: >
77
Additional configurations when installing Tekton Pipelines
88
---
99
-->
10-
10+
1111
This document describes additional options to configure your Tekton Pipelines
1212
installation.
1313

@@ -98,7 +98,7 @@ Environment variables can be configured in the following ways, mentioned in orde
9898
3. Environment variables specified via a `default` `PodTemplate`.
9999
4. Environment variables specified via a `PodTemplate`.
100100

101-
The environment variables specified by a `PodTemplate` supercedes all other ways of specifying environment variables. However, there exists a configuration i.e. `default-forbidden-env`, the environment variable specified in this list cannot be updated via a `PodTemplate`.
101+
The environment variables specified by a `PodTemplate` supercedes all other ways of specifying environment variables. However, there exists a configuration i.e. `default-forbidden-env`, the environment variable specified in this list cannot be updated via a `PodTemplate`.
102102

103103
For example:
104104

@@ -238,7 +238,7 @@ The default is `false`. For more information, see the [associated issue](https:/
238238
most stable features to be used. Set it to "alpha" to allow [alpha
239239
features](#alpha-features) to be used.
240240

241-
- `resource-verification-mode`: Setting this flag to "enforce" will enforce verification of tasks/pipeline. Failing to verify will fail the taskrun/pipelinerun. "warn" will only log the err message and "skip" will skip the whole verification.
241+
- `verification-no-match-policy`: Setting this flag to "enforce" will enforce verification of tasks/pipeline. Failing to verify will fail the taskrun/pipelinerun. "warn" will only log the err message and "skip" will skip the whole verification.
242242
- `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.
243243

244244
- `enable-provenance-in-status`: set this flag to "true" to enable recording
@@ -285,7 +285,7 @@ Features currently in "alpha" are:
285285
| [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) | |
286286
| [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) | |
287287
| [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) | | |
288-
| [Trusted Resources](./trusted-resources.md) | [TEP-0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md) | N/A | `resource-verification-mode` |
288+
| [Trusted Resources](./trusted-resources.md) | [TEP-0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md) | N/A | `verification-no-match-policy` |
289289
| [`Provenance` field in Status](pipeline-api.md#provenance) | [issue#5550](https://github.com/tektoncd/pipeline/issues/5550) | N/A | `enable-provenance-in-status` |
290290
| [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` |
291291

@@ -313,7 +313,7 @@ To exceed this limit of 4096 bytes, you can enable larger results using sidecar
313313

314314
**Note**: to enable this feature, you need to grant `get` access to all `pods/log` to the `Tekton pipeline controller`. This means that the tekton pipeline controller has the ability to access the pod logs.
315315

316-
1. Create a cluster role and rolebinding by applying the following spec to provide log access to `tekton-pipelines-controller`.
316+
1. Create a cluster role and rolebinding by applying the following spec to provide log access to `tekton-pipelines-controller`.
317317

318318
```
319319
kubectl apply -f optional_config/enable-log-access-to-controller/
@@ -326,7 +326,7 @@ kubectl patch cm feature-flags -n tekton-pipelines -p '{"data":{"results-from":"
326326
```
327327
328328
3. If you want the size per result to be something other than 4096 bytes, you can set the `max-result-size` feature flag in bytes by setting `max-result-size: 8192(whatever you need here)`. **Note:** The value you can set here cannot exceed the size of the CRD limit of 1.5 MB.
329-
329+
330330
```
331331
kubectl patch cm feature-flags -n tekton-pipelines -p '{"data":{"max-result-size":"<VALUE-IN-BYTES>"}}'
332332
```

docs/trusted-resources.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ metadata:
5454
app.kubernetes.io/instance: default
5555
app.kubernetes.io/part-of: tekton-pipelines
5656
data:
57-
resource-verification-mode: "enforce"
57+
verification-no-match-policy: "deny"
5858
```
5959
60-
**Note:** `resource-verification-mode` needs to be set as `enforce` or `warn` to enable resource verification.
60+
`verification-no-match-policy` configurations:
61+
* `allow`: Don't fail the taskrun/pipelinerun if no matching policies are found. Don't log.
62+
* `warn`: Don't fail the taskrun/pipelinerun and log a warning if no matching policies are found.
63+
* `deny`: Fail the taskrun/pipelinerun if no matching policies are found.
6164

62-
`resource-verification-mode` configurations:
63-
* `enforce`: Failing verification will mark the taskruns/pipelineruns as failed.
64-
* `warn`: Log warning but don't fail the taskruns/pipelineruns.
65-
* `skip`: Directly skip the verification.
65+
**Notes:**
66+
* To skip the verification: make sure if no policies exist and `verification-no-match-policy` is set to `allow`.
67+
* To enable the verification: install VerificationPolicy to match the resources.
6668

6769
Or patch the new values:
6870
```bash
69-
kubectl patch configmap feature-flags -n tekton-pipelines -p='{"data":{"resource-verification-mode":"enforce"}}
71+
kubectl patch configmap feature-flags -n tekton-pipelines -p='{"data":{"verification-no-match-policy":"deny"}}
7072
```
7173

7274
#### Config key at VerificationPolicy

pkg/apis/config/feature_flags.go

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ const (
3333
AlphaAPIFields = "alpha"
3434
// BetaAPIFields is the value used for "enable-api-fields" when beta APIs should be usable as well.
3535
BetaAPIFields = "beta"
36-
// EnforceResourceVerificationMode is the value used for "resource-verification-mode" when verification is applied and fail the
36+
// DenyNoMatchPolicy is the value used for "verification-no-match-policy" when verification is applied and fail the
3737
// TaskRun or PipelineRun when verification fails
38-
EnforceResourceVerificationMode = "enforce"
39-
// WarnResourceVerificationMode is the value used for "resource-verification-mode" when verification is applied but only log
38+
DenyNoMatchPolicy = "deny"
39+
// WarnNoMatchPolicy is the value used for "verification-no-match-policy" when verification is applied but only log
4040
// the warning when verification fails
41-
WarnResourceVerificationMode = "warn"
42-
// SkipResourceVerificationMode is the value used for "resource-verification-mode" when verification is skipped
43-
SkipResourceVerificationMode = "skip"
41+
WarnNoMatchPolicy = "warn"
42+
// AllowNoMatchPolicy is the value used for "verification-no-match-policy" when verification is skipped
43+
AllowNoMatchPolicy = "allow"
4444
// ResultExtractionMethodTerminationMessage is the value used for "results-from" as a way to extract results from tasks using kubernetes termination message.
4545
ResultExtractionMethodTerminationMessage = "termination-message"
4646
// ResultExtractionMethodSidecarLogs is the value used for "results-from" as a way to extract results from tasks using sidecar logs.
@@ -73,8 +73,8 @@ const (
7373
EnforceNonfalsifiabilityNone = ""
7474
// DefaultEnforceNonfalsifiability is the default value for "enforce-nonfalsifiability".
7575
DefaultEnforceNonfalsifiability = EnforceNonfalsifiabilityNone
76-
// DefaultResourceVerificationMode is the default value for "resource-verification-mode".
77-
DefaultResourceVerificationMode = SkipResourceVerificationMode
76+
// DefaultNoMatchPolicyConfig is the default value for "verification-no-match-policy".
77+
DefaultNoMatchPolicyConfig = AllowNoMatchPolicy
7878
// DefaultEnableProvenanceInStatus is the default value for "enable-provenance-status".
7979
DefaultEnableProvenanceInStatus = false
8080
// DefaultResultExtractionMethod is the default value for ResultExtractionMethod
@@ -93,7 +93,7 @@ const (
9393
enableAPIFields = "enable-api-fields"
9494
sendCloudEventsForRuns = "send-cloudevents-for-runs"
9595
enforceNonfalsifiability = "enforce-nonfalsifiability"
96-
verificationMode = "resource-verification-mode"
96+
verificationMode = "verification-no-match-policy"
9797
enableProvenanceInStatus = "enable-provenance-in-status"
9898
resultExtractionMethod = "results-from"
9999
maxResultSize = "max-result-size"
@@ -113,7 +113,7 @@ type FeatureFlags struct {
113113
SendCloudEventsForRuns bool
114114
AwaitSidecarReadiness bool
115115
EnforceNonfalsifiability string
116-
ResourceVerificationMode string
116+
VerificationNoMatchPolicy string
117117
EnableProvenanceInStatus bool
118118
ResultExtractionMethod string
119119
MaxResultSize int
@@ -182,7 +182,7 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) {
182182
if err := setFeature(sendCloudEventsForRuns, DefaultSendCloudEventsForRuns, &tc.SendCloudEventsForRuns); err != nil {
183183
return nil, err
184184
}
185-
if err := setResourceVerificationMode(cfgMap, DefaultResourceVerificationMode, &tc.ResourceVerificationMode); err != nil {
185+
if err := setVerificationNoMatchPolicy(cfgMap, DefaultNoMatchPolicyConfig, &tc.VerificationNoMatchPolicy); err != nil {
186186
return nil, err
187187
}
188188
if err := setFeature(enableProvenanceInStatus, DefaultEnableProvenanceInStatus, &tc.EnableProvenanceInStatus); err != nil {
@@ -292,15 +292,15 @@ func setMaxResultSize(cfgMap map[string]string, defaultValue int, feature *int)
292292
return nil
293293
}
294294

295-
// setResourceVerificationMode sets the "resource-verification-mode" flag based on the content of a given map.
295+
// setVerificationNoMatchPolicy sets the "verification-no-match-policy" flag based on the content of a given map.
296296
// If the value is invalid or missing then an error is returned.
297-
func setResourceVerificationMode(cfgMap map[string]string, defaultValue string, feature *string) error {
297+
func setVerificationNoMatchPolicy(cfgMap map[string]string, defaultValue string, feature *string) error {
298298
value := defaultValue
299299
if cfg, ok := cfgMap[verificationMode]; ok {
300300
value = strings.ToLower(cfg)
301301
}
302302
switch value {
303-
case EnforceResourceVerificationMode, WarnResourceVerificationMode, SkipResourceVerificationMode:
303+
case DenyNoMatchPolicy, WarnNoMatchPolicy, AllowNoMatchPolicy:
304304
*feature = value
305305
default:
306306
return fmt.Errorf("invalid value for feature flag %q: %q", verificationMode, value)
@@ -328,18 +328,25 @@ func EnableStableAPIFields(ctx context.Context) context.Context {
328328
return setEnableAPIFields(ctx, StableAPIFields)
329329
}
330330

331-
// CheckEnforceResourceVerificationMode returns true if the ResourceVerificationMode is EnforceResourceVerificationMode
331+
// CheckAllowVerificationNoMatchPolicy returns true if the VerificationNoMatchPolicy is AllowNoMatchPolicy
332332
// else returns false
333-
func CheckEnforceResourceVerificationMode(ctx context.Context) bool {
333+
func CheckAllowVerificationNoMatchPolicy(ctx context.Context) bool {
334334
cfg := FromContextOrDefaults(ctx)
335-
return cfg.FeatureFlags.ResourceVerificationMode == EnforceResourceVerificationMode
335+
return cfg.FeatureFlags.VerificationNoMatchPolicy == AllowNoMatchPolicy
336336
}
337337

338-
// CheckWarnResourceVerificationMode returns true if the ResourceVerificationMode is WarnResourceVerificationMode
338+
// CheckDenyVerificationNoMatchPolicy returns true if the VerificationNoMatchPolicy is DenyNoMatchPolicy
339339
// else returns false
340-
func CheckWarnResourceVerificationMode(ctx context.Context) bool {
340+
func CheckDenyVerificationNoMatchPolicy(ctx context.Context) bool {
341341
cfg := FromContextOrDefaults(ctx)
342-
return cfg.FeatureFlags.ResourceVerificationMode == WarnResourceVerificationMode
342+
return cfg.FeatureFlags.VerificationNoMatchPolicy == DenyNoMatchPolicy
343+
}
344+
345+
// CheckWarnVerificationNoMatchPolicy returns true if the VerificationNoMatchPolicy is WarnNoMatchPolicy
346+
// else returns false
347+
func CheckWarnVerificationNoMatchPolicy(ctx context.Context) bool {
348+
cfg := FromContextOrDefaults(ctx)
349+
return cfg.FeatureFlags.VerificationNoMatchPolicy == WarnNoMatchPolicy
343350
}
344351

345352
// CheckAlphaOrBetaAPIFields return true if the enable-api-fields is either set to alpha or set to beta

0 commit comments

Comments
 (0)