Skip to content

Commit

Permalink
[TEP-114] Remove the feature flag custom-task-version
Browse files Browse the repository at this point in the history
This commit closes tektoncd#5837. It removes the feature flag
custom-task-version to stop supporting v1alpha1.Run as planed in
TEP-114. There will be a separate PR to remove the v1alpha1.Run tracking
by tektoncd#6498.

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
  • Loading branch information
Yongxuanzhang committed Apr 5, 2023
1 parent 633fd87 commit f6a89c9
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 900 deletions.
4 changes: 0 additions & 4 deletions config/config-feature-flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ data:
# in the TaskRun/PipelineRun such as the source from where a remote Task/Pipeline
# definition was fetched.
enable-provenance-in-status: "false"
# Setting this flag will determine the version for custom tasks created by PipelineRuns.
# Acceptable values are "v1beta1" and "v1alpha1".
# The default is "v1beta1".
custom-task-version: "v1beta1"
# 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.
Expand Down
6 changes: 0 additions & 6 deletions docs/additional-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,6 @@ Defaults to "ignore".
field contains metadata about resources used in the TaskRun/PipelineRun such as the
source from where a remote Task/Pipeline definition was fetched.

- `custom-task-version`: set this flag to "v1beta1" to have `PipelineRuns` create `CustomRuns`
from Custom Tasks. Set it to "v1alpha1" to have `PipelineRuns` create the legacy alpha
`Runs`. This may be needed if you are using legacy Custom Tasks that listen for `*v1alpha1.Run`
instead of `*v1beta1.CustomRun`. For more information, see [Runs](runs.md) and [CustomRuns](customruns.md).
Flag defaults to "v1beta1".

For example:

```yaml
Expand Down
3 changes: 2 additions & 1 deletion docs/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,8 @@ no `runAfter` can be specified in `finally` tasks.

## Using Custom Tasks

Custom Tasks have been promoted from `v1alpha1` to `v1beta1`. Starting from `v0.43.0`, Pipeline Controller is able to create either `v1alpha1` or `v1beta1` Custom Task gated by a feature flag `custom-task-version`, defaulting to `v1beta1`. You can set `custom-task-version` to `v1alpha1` or `v1beta1` to control which version to create.
Custom Tasks have been promoted from `v1alpha1` to `v1beta1`. Starting from `v0.43.0` to `v0.46.0`, Pipeline Controller is able to create either `v1alpha1` or `v1beta1` Custom Task gated by a feature flag `custom-task-version`, defaulting to `v1beta1`. You can set `custom-task-version` to `v1alpha1` or `v1beta1` to control which version to create.
Starting from `v0.47.0`, feature flag `custom-task-version` is removed and only `v1beta1` Custom Task will be supported.

We'll remove the flag `custom-task-version` and the entire alpha Custom Task in release v0.47.0 (tracked in the issue #5837). See the [migration doc](migrating-v1alpha1.Run-to-v1beta1.CustomRun.md) for details.

Expand Down
29 changes: 0 additions & 29 deletions pkg/apis/config/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ const (
ResultExtractionMethodTerminationMessage = "termination-message"
// ResultExtractionMethodSidecarLogs is the value used for "results-from" as a way to extract results from tasks using sidecar logs.
ResultExtractionMethodSidecarLogs = "sidecar-logs"
// CustomTaskVersionAlpha is the value used for "custom-task-version" when the PipelineRun reconciler should create
// v1alpha1.Runs.
CustomTaskVersionAlpha = "v1alpha1"
// CustomTaskVersionBeta is the value used for "custom-task-version" when the PipelineRun reconciler should create
// v1beta1.CustomRuns.
CustomTaskVersionBeta = "v1beta1"
// DefaultDisableAffinityAssistant is the default value for "disable-affinity-assistant".
DefaultDisableAffinityAssistant = false
// DefaultDisableCredsInit is the default value for "disable-creds-init".
Expand Down Expand Up @@ -82,8 +76,6 @@ const (
DefaultResultExtractionMethod = ResultExtractionMethodTerminationMessage
// DefaultMaxResultSize is the default value in bytes for the size of a result
DefaultMaxResultSize = 4096
// DefaultCustomTaskVersion is the default value for "custom-task-version"
DefaultCustomTaskVersion = CustomTaskVersionBeta

disableAffinityAssistantKey = "disable-affinity-assistant"
disableCredsInitKey = "disable-creds-init"
Expand All @@ -98,7 +90,6 @@ const (
enableProvenanceInStatus = "enable-provenance-in-status"
resultExtractionMethod = "results-from"
maxResultSize = "max-result-size"
customTaskVersion = "custom-task-version"
)

// FeatureFlags holds the features configurations
Expand All @@ -123,7 +114,6 @@ type FeatureFlags struct {
EnableProvenanceInStatus bool
ResultExtractionMethod string
MaxResultSize int
CustomTaskVersion string
}

// GetFeatureFlagsConfigName returns the name of the configmap containing all
Expand Down Expand Up @@ -200,9 +190,6 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) {
if err := setMaxResultSize(cfgMap, DefaultMaxResultSize, &tc.MaxResultSize); err != nil {
return nil, err
}
if err := setCustomTaskVersion(cfgMap, DefaultCustomTaskVersion, &tc.CustomTaskVersion); err != nil {
return nil, err
}

// Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if
// enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of
Expand Down Expand Up @@ -263,22 +250,6 @@ func setResultExtractionMethod(cfgMap map[string]string, defaultValue string, fe
return nil
}

// setCustomTaskVersion sets the "custom-task-version" flag based on the content of a given map.
// If the feature gate is invalid or missing then an error is returned.
func setCustomTaskVersion(cfgMap map[string]string, defaultValue string, feature *string) error {
value := defaultValue
if cfg, ok := cfgMap[customTaskVersion]; ok {
value = strings.ToLower(cfg)
}
switch value {
case CustomTaskVersionAlpha, CustomTaskVersionBeta:
*feature = value
default:
return fmt.Errorf("invalid value for feature flag %q: %q", customTaskVersion, value)
}
return nil
}

// setMaxResultSize sets the "max-result-size" flag based on the content of a given map.
// If the feature gate is invalid or missing then an error is returned.
func setMaxResultSize(cfgMap map[string]string, defaultValue int, feature *int) error {
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/config/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
fileName: config.GetFeatureFlagsConfigName(),
},
Expand All @@ -69,7 +68,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
EnableProvenanceInStatus: true,
ResultExtractionMethod: "termination-message",
MaxResultSize: 4096,
CustomTaskVersion: "v1beta1",
},
fileName: "feature-flags-all-flags-set",
},
Expand All @@ -89,7 +87,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
fileName: "feature-flags-enable-api-fields-overrides-bundles-and-custom-tasks",
},
Expand All @@ -107,7 +104,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
fileName: "feature-flags-bundles-and-custom-tasks",
},
Expand All @@ -125,7 +121,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
fileName: "feature-flags-beta-api-fields",
},
Expand All @@ -139,7 +134,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
fileName: "feature-flags-enforce-nonfalsifiability-spire",
},
Expand All @@ -151,7 +145,6 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
AwaitSidecarReadiness: config.DefaultAwaitSidecarReadiness,
ResultExtractionMethod: config.ResultExtractionMethodSidecarLogs,
MaxResultSize: 8192,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
fileName: "feature-flags-results-via-sidecar-logs",
},
Expand Down Expand Up @@ -182,7 +175,6 @@ func TestNewFeatureFlagsFromEmptyConfigMap(t *testing.T) {
EnableProvenanceInStatus: config.DefaultEnableProvenanceInStatus,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
}
verifyConfigFileWithExpectedFeatureFlagsConfig(t, FeatureFlagsConfigEmptyName, expectedConfig)
}
Expand Down Expand Up @@ -229,8 +221,6 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) {
fileName: "feature-flags-invalid-max-result-size-too-large",
}, {
fileName: "feature-flags-invalid-max-result-size-bad-value",
}, {
fileName: "feature-flags-invalid-custom-task-version",
}, {
fileName: "feature-flags-enforce-nonfalsifiability-bad-flag",
}, {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/config/testdata/feature-flags-all-flags-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ data:
enforce-nonfalsifiability: "spire"
trusted-resources-verification-no-match-policy: "fail"
enable-provenance-in-status: "true"
custom-task-version: "v1beta1"

This file was deleted.

1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/pipelinerun_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ func TestPipelineRunConversion(t *testing.T) {
VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
},
},
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/taskrun_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ func TestTaskRunConversion(t *testing.T) {
VerificationNoMatchPolicy: config.DefaultNoMatchPolicyConfig,
ResultExtractionMethod: config.DefaultResultExtractionMethod,
MaxResultSize: config.DefaultMaxResultSize,
CustomTaskVersion: config.DefaultCustomTaskVersion,
},
}},
},
Expand Down
8 changes: 0 additions & 8 deletions pkg/reconciler/pipelinerun/cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,6 @@ func TestGetChildObjectsFromPRStatusForTaskNames(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
ctx, _ := ttesting.SetupFakeContext(t)
cfg := config.NewStore(logtesting.TestLogger(t))
cm := newFeatureFlagsConfigMap()
if tc.useV1Beta1CustomTask {
cm = withCustomTaskVersion(cm, config.CustomTaskVersionBeta)
}
cfg.OnConfigChanged(cm)
ctx = cfg.ToContext(ctx)

trNames, customRunNames, runNames, err := getChildObjectsFromPRStatusForTaskNames(ctx, tc.prStatus, tc.taskNames)

if tc.hasError {
Expand Down
80 changes: 7 additions & 73 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,6 @@ func (c *Reconciler) resolvePipelineState(
return r, nil
}

cfg := config.FromContextOrDefaults(ctx)
if cfg.FeatureFlags.CustomTaskVersion == config.CustomTaskVersionAlpha {
getRunObjectFunc = func(name string) (v1beta1.RunObject, error) {
r, err := c.runLister.Runs(pr.Namespace).Get(name)
if err != nil {
return nil, err
}
// If we just return c.runLister.Runs(...).Get(...) and there is no run, we end up returning
// a v1beta1.RunObject that won't == nil, so do an explicit check.
if r == nil {
return nil, nil
}
return r, nil
}
}
resolvedTask, err := resources.ResolvePipelineTask(ctx,
*pr,
fn,
Expand Down Expand Up @@ -904,7 +889,6 @@ func (c *Reconciler) createRunObject(ctx context.Context, runName string, params
ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "createRunObject")
defer span.End()
logger := logging.FromContext(ctx)
cfg := config.FromContextOrDefaults(ctx)
taskRunSpec := pr.GetTaskRunSpec(rpt.PipelineTask.Name)
params = append(params, rpt.PipelineTask.Params...)

Expand All @@ -925,44 +909,6 @@ func (c *Reconciler) createRunObject(ctx context.Context, runName string, params
Annotations: getTaskrunAnnotations(pr),
}

if cfg.FeatureFlags.CustomTaskVersion == config.CustomTaskVersionAlpha {
r := &v1alpha1.Run{
ObjectMeta: objectMeta,
Spec: v1alpha1.RunSpec{
Retries: rpt.PipelineTask.Retries,
Ref: rpt.PipelineTask.TaskRef,
Params: params,
ServiceAccountName: taskRunSpec.TaskServiceAccountName,
Timeout: taskTimeout,
Workspaces: workspaces,
},
}
if rpt.PipelineTask.TaskSpec != nil {
j, err := json.Marshal(rpt.PipelineTask.TaskSpec.Spec)
if err != nil {
return nil, err
}
r.Spec.Spec = &v1alpha1.EmbeddedRunSpec{
TypeMeta: runtime.TypeMeta{
APIVersion: rpt.PipelineTask.TaskSpec.APIVersion,
Kind: rpt.PipelineTask.TaskSpec.Kind,
},
Metadata: rpt.PipelineTask.TaskSpec.Metadata,
Spec: runtime.RawExtension{
Raw: j,
},
}
}
// Set the affinity assistant annotation in case the custom task creates TaskRuns or Pods
// that can take advantage of it.
if !c.isAffinityAssistantDisabled(ctx) && pipelinePVCWorkspaceName != "" {
r.Annotations[workspace.AnnotationAffinityAssistantName] = getAffinityAssistantName(pipelinePVCWorkspaceName, pr.Name)
}

logger.Infof("Creating a new Run object %s", runName)
return c.PipelineClientSet.TektonV1alpha1().Runs(pr.Namespace).Create(ctx, r, metav1.CreateOptions{})
}

r := &v1beta1.CustomRun{
ObjectMeta: objectMeta,
Spec: v1beta1.CustomRunSpec{
Expand Down Expand Up @@ -1279,7 +1225,6 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr
ctx, span := c.tracerProvider.Tracer(TracerName).Start(ctx, "updatePipelineRunStatusFromInformer")
defer span.End()
logger := logging.FromContext(ctx)
cfg := config.FromContextOrDefaults(ctx)

// Get the pipelineRun label that is set on each TaskRun. Do not include the propagated labels from the
// Pipeline and PipelineRun. The user could change them during the lifetime of the PipelineRun so the
Expand All @@ -1292,24 +1237,13 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr
}
var runObjects []v1beta1.RunObject

if cfg.FeatureFlags.CustomTaskVersion == config.CustomTaskVersionAlpha {
legacyRuns, err := c.runLister.Runs(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list Runs %#v", err)
return err
}
for _, lr := range legacyRuns {
runObjects = append(runObjects, lr)
}
} else {
customRuns, err := c.customRunLister.CustomRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list CustomRuns %#v", err)
return err
}
for _, cr := range customRuns {
runObjects = append(runObjects, cr)
}
customRuns, err := c.customRunLister.CustomRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list CustomRuns %#v", err)
return err
}
for _, cr := range customRuns {
runObjects = append(runObjects, cr)
}

return updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, runObjects)
Expand Down
Loading

0 comments on commit f6a89c9

Please sign in to comment.