Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: [TEP-0135] remove deprecated disable-affinity-assistant feature flag #8603

Conversation

l-qing
Copy link
Member

@l-qing l-qing commented Mar 1, 2025

fix #8587

This field has been deprecated for about a year and half. So this is "removing" this feature flag from the codebase.

The field is kept in the go code to provide a backward compatibility for client code (like chains, …) but it will be disallowed by the webhook. It will also be completely ignore by the rest of the code.

Changes

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Action Required: The feature flag `disable-affinity-assistant` has been removed. Please use `coschedule` as a replacement. It was marked as deprecated in version v0.51 and has been completely removed in the current version. If you need to maintain the previous default behavior, set feature flag `coschedule` to `disabled`. For specific behavioral differences, please refer to: https://github.com/tektoncd/community/blob/main/teps/0135-coscheduling-pipelinerun-pods.md#tep-0135-coscheduling-pipelinerun-pods

/kind cleanup

@tekton-robot tekton-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. labels Mar 1, 2025
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 1, 2025
@tekton-robot tekton-robot requested review from afrittoli and dibyom March 1, 2025 07:04
@l-qing
Copy link
Member Author

l-qing commented Mar 1, 2025

/cc @vdemeester

@tekton-robot tekton-robot requested a review from vdemeester March 1, 2025 07:08
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{Name: config.GetFeatureFlagsConfigName(), Namespace: system.Namespace()},
Data: map[string]string{
featureFlagDisableAffinityAssistantKey: "true",
"coschedule": "disabled",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the action required, if you want to maintain the execution behavior, you may need to set the coschedule to disabled.

The focus is on the line of code below: (line: 53)

// GetAffinityAssistantBehavior returns an AffinityAssistantBehavior based on the
// combination of "disable-affinity-assistant" and "coschedule" feature flags
// TODO(#6740)(WIP): consume this function in the PipelineRun reconciler to determine Affinity Assistant behavior.
func GetAffinityAssistantBehavior(ctx context.Context) (AffinityAssistantBehavior, error) {
cfg := config.FromContextOrDefaults(ctx)
disableAA := cfg.FeatureFlags.DisableAffinityAssistant
coschedule := cfg.FeatureFlags.Coschedule
// at this point, we have validated that "coschedule" can only be "workspaces"
// when "disable-affinity-assistant" is false
if !disableAA {
return AffinityAssistantPerWorkspace, nil
}
switch coschedule {
case config.CoschedulePipelineRuns:
return AffinityAssistantPerPipelineRun, nil
case config.CoscheduleIsolatePipelineRun:
return AffinityAssistantPerPipelineRunWithIsolation, nil
case config.CoscheduleDisabled, config.CoscheduleWorkspaces:
return AffinityAssistantDisabled, nil
}

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

"test-pipeline-run-variable-substitution", "test-pipeline", "b-task", false),
taskRunObjectMetaWithAnnotations("test-pipeline-run-variable-substitution-b-task", "foo",
"test-pipeline-run-variable-substitution", "test-pipeline", "b-task", false, map[string]string{
"pipeline.tekton.dev/affinity-assistant": "affinity-assistant-0358aabfa2",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the previous setting of disable-affinity-assistant was true, the default behavior was not to add the relevant annotations. Now that the feature switch has been removed, the behavior has changed somewhat.

Theoretically, the previous effect can also be achieved by setting other feature switches.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has this been documented ?

  1. The behavior change
  2. what the previous effect is and how to achieve it be achieved with other feature switches ?

This would be good to have in the release notes as well

@l-qing l-qing closed this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Tekton Community Roadmap Mar 1, 2025
@l-qing l-qing reopened this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Mar 1, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

@l-qing l-qing closed this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Mar 1, 2025
@l-qing l-qing reopened this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Mar 1, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

@l-qing l-qing closed this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Mar 1, 2025
@l-qing l-qing reopened this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Mar 1, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

@l-qing l-qing closed this Mar 1, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Mar 1, 2025
@l-qing l-qing reopened this Mar 1, 2025
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2025
@l-qing l-qing force-pushed the feat/remove-deprecated-disable-affinity-assistant-field branch from e365ea3 to ec80a75 Compare March 12, 2025 02:07
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 12, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

@l-qing l-qing closed this Mar 12, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Mar 12, 2025
@l-qing l-qing reopened this Mar 12, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Mar 12, 2025
@l-qing l-qing closed this Mar 12, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Mar 12, 2025
@l-qing l-qing reopened this Mar 12, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Mar 12, 2025
@l-qing l-qing force-pushed the feat/remove-deprecated-disable-affinity-assistant-field branch from ec80a75 to 25d7a0c Compare March 12, 2025 07:20
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

disableCredsInit:
description: DisableAffinityAssistant bool `json:"disableAffinityAssistant,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those descriptions seems weird, don't they ?

@@ -188,7 +185,7 @@ var (
// FeatureFlags holds the features configurations
// +k8s:deepcopy-gen=true
type FeatureFlags struct {
DisableAffinityAssistant bool `json:"disableAffinityAssistant,omitempty"`
// DisableAffinityAssistant bool `json:"disableAffinityAssistant,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either we keep it as no-op (in order to not fail existing configuration), or we remove it, but we shouldn't keep the comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the strange annotations generated by hack/update-codegen.sh are due to the comments below. I removed the comments and regenerated it, and it worked fine.

Please have a look when you have time. Thank you!

@l-qing l-qing force-pushed the feat/remove-deprecated-disable-affinity-assistant-field branch from 25d7a0c to b39da59 Compare March 13, 2025 03:31
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

l-qing added 2 commits March 14, 2025 12:23
…ure flag

This field has been deprecated for about a year and half. So this is
"removing" this feature flag from the codebase.

The field is kept in the go code to provide a backward compatibility
for client code (like chains, …) but it will be disallowed by the
webhook. It will also be completely ignore by the rest of the code.
@l-qing l-qing force-pushed the feat/remove-deprecated-disable-affinity-assistant-field branch from b39da59 to 2c9f859 Compare March 14, 2025 04:23
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.2% 95.0% -0.2
pkg/internal/affinityassistant/affinityassistant_types.go 90.0% 87.5% -2.5

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester, waveywaves

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 19, 2025
Copy link
Member

@waveywaves waveywaves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good
just a few questions

@@ -46,6 +45,8 @@ The features listed below have been removed but may still be supported in releas
| [The `PipelineRun.Status.TaskRuns` and `PipelineRun.Status.Runs` fields and the `embedded-status` feature flag along with their functionalities have been tombstoned since v0.45.](https://github.com/tektoncd/community/blob/main/teps/0100-embedded-taskruns-and-runs-status-in-pipelineruns.md) | [[TEP100] Remove Taskruns and Runs Fields for PipelineRunStatus](https://github.com/tektoncd/pipeline/pull/6099) | Jan 25, 2023 | v0.44.0 | Jan 24, 2024 |
| PipelineResources are removed, along with the components of the API that rely on them as proposed in [TEP-0074](https://github.com/tektoncd/community/blob/main/teps/0074-deprecate-pipelineresources.md). See [Removed `PipelineResources` related features](#removed-pipelineresources-related-features) for more info. | [[TEP074] Remove Generic PipelineResources with Rest of Resources Types](https://github.com/tektoncd/pipeline/pull/6150) | Mar 8, 2023 | v0.44.0 | Jan 24, 2024 |
| v1alpha1 Runs are removed, as proposed in [TEP-0114](https://github.com/tektoncd/community/blob/main/teps/0114-custom-tasks-beta.md), along with the feature flags `enable-custom-task` and `custom-task-version`. | [TEP-0114: Remove support for v1alpha1.Run](https://github.com/tektoncd/pipeline/pull/6508) | April 7, 2023 | v0.44.0 | Jan 24, 2024 |
| [The `disable-affinity-assistant` feature flag is deprecated in favor of the `coschedule` feature flag](https://github.com/tektoncd/community/blob/main/teps/0135-coscheduling-pipelinerun-pods.md#tep-0135-coscheduling-pipelinerun-pods) | [cleanup: [TEP-0135] remove deprecated disable-affinity-assistant feature flag](https://github.com/tektoncd/pipeline/pull/8603) | Mar 1, 2025 | v0.68.0 | Jan 30, 2026 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@@ -188,12 +185,9 @@ var (
// FeatureFlags holds the features configurations
// +k8s:deepcopy-gen=true
type FeatureFlags struct {
DisableAffinityAssistant bool `json:"disableAffinityAssistant,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

switch coschedule {
case config.CoschedulePipelineRuns:
return AffinityAssistantPerPipelineRun, nil
case config.CoscheduleIsolatePipelineRun:
return AffinityAssistantPerPipelineRunWithIsolation, nil
case config.CoscheduleDisabled, config.CoscheduleWorkspaces:
case config.CoscheduleWorkspaces:
return AffinityAssistantPerWorkspace, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

"test-pipeline-run-variable-substitution", "test-pipeline", "b-task", false),
taskRunObjectMetaWithAnnotations("test-pipeline-run-variable-substitution-b-task", "foo",
"test-pipeline-run-variable-substitution", "test-pipeline", "b-task", false, map[string]string{
"pipeline.tekton.dev/affinity-assistant": "affinity-assistant-0358aabfa2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has this been documented ?

  1. The behavior change
  2. what the previous effect is and how to achieve it be achieved with other feature switches ?

This would be good to have in the release notes as well

@l-qing
Copy link
Member Author

l-qing commented Mar 28, 2025

@waveywaves

looks good just a few questions

has this been documented ?
The behavior change
what the previous effect is and how to achieve it be achieved with other feature switches ?

I understand that this is the information displayed in the table of the Release Notes link document.

The following chart summarizes the affinity assistant behaviors with different combinations of the "disable-affinity-assistant" and "coschedule" feature flags during migration (when both feature flags are present) and after the migration (when only the "coschedule" flag is present):

disable-affinity-assistant coschedule behavior during migration behavior after migration
false (default) disabled N/A: invalid disabled
false (default) workspaces (default) coschedule workspaces coschedule workspaces
false (default) pipelineruns N/A: invalid coschedule pipelineruns
false (default) isolate-pipelinerun N/A: invalid isolate pipelineruns
true disabled disabled disabled
true workspaces (default) disabled coschedule workspaces
true pipelineruns coschedule pipelineruns coschedule pipelineruns
true isolate-pipelinerun isolate pipelineruns isolate pipelineruns

Specifically, the previous behavior was disabled. To maintain the previous behavior now, you can set coschedule to false.
Since it’s impossible to list all the alternative feature switches to replace the previous ones in the release notes, a document link was ultimately provided.

@waveywaves
Copy link
Member

@l-qing thank you for your patience with this review
/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 28, 2025
@tekton-robot tekton-robot merged commit 8046853 into tektoncd:main Mar 28, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Question: Is there a plan to completely remove the deprecated disable-affinity-assistant configuration option?
5 participants