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

1.25: feature gate cleanup #109435

Merged
merged 2 commits into from May 5, 2022
Merged

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Apr 12, 2022

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Sorting is meant to decrease the risk of code conflicts during the period before code freeze.

Removal of GA features is part of the usual maintenance and was due for several features in 1.25.

Special notes for your reviewer:

Discussed here: https://groups.google.com/g/kubernetes-sig-architecture/c/7J6_YYvdugc/m/rr1jde6JBgAJ

Does this PR introduce a user-facing change?

Feature gates that graduated to GA in 1.23 or earlier and were unconditionally enabled have been removed: CSIServiceAccountToken, ConfigurableFSGroupPolicy, EndpointSlice, EndpointSliceNodeName, EndpointSliceProxying, GenericEphemeralVolume, IPv6DualStack, IngressClassNamespacedParams, StorageObjectInUseProtection, TTLAfterFinished, VolumeSubpath, WindowsEndpointSliceProxying

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 12, 2022
@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 12, 2022
@fedebongio
Copy link
Contributor

/sig architecture
/remove-sig api-machinery
/cc @deads2k @thockin @liggitt

@k8s-ci-robot k8s-ci-robot added sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. and removed sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Apr 12, 2022
@mtaufen
Copy link
Contributor

mtaufen commented Apr 12, 2022

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 12, 2022
@mtaufen
Copy link
Contributor

mtaufen commented Apr 12, 2022

We should also include a presubmit test that ensures these files remain sorted.

@mtaufen
Copy link
Contributor

mtaufen commented Apr 12, 2022

A tool for sorting it would be useful also.

@mtaufen
Copy link
Contributor

mtaufen commented Apr 12, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2022
APIServerIdentity: {Default: false, PreRelease: featuregate.Alpha},
APIServerTracing: {Default: false, PreRelease: featuregate.Alpha},
OpenAPIEnums: {Default: true, PreRelease: featuregate.Beta},
APIListChunking: {Default: true, PreRelease: featuregate.Beta},
Copy link
Member

Choose a reason for hiding this comment

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

I think we could get rid of the need to list the features here with something like this:

type FeatureSet struct{
  features map[Feature]FeatureSpec
}

func (f *FeatureSet) Register(feature Feature, default bool, prerelease prerelease) Feature {
  f.features[feature] = FeatureSpec{Default: default, PreRelease: prerelease}
  return feature
}

Then the feature declarations just call Register on the default feature set, e.g.

	// owner: @smarterclayton
	// alpha: v1.8
	// beta: v1.9
	//
	// Allow API clients to retrieve resource lists in chunks rather than
	// all at once.
-	APIListChunking featuregate.Feature = "APIListChunking"
+	APIListChunking = defaultKubernetesFeatureGates.Register("APIListChunking", true, featuregate.Beta)

I also like that this keeps the state next to the definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same idea, but didn't pursue it because of one drawback: APIListChunking has to become a global variable instead of a constant, right?

Is that relevant or can we trust all code to never write to these variables?

The Register also needs to be a bit more complicated or we need additional flavors of it because some feature gates also have LockToDefault: true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tallclair: ping ^^^

Copy link
Contributor

@mtaufen mtaufen May 4, 2022

Choose a reason for hiding this comment

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

Maybe we should err on the side of splitting sorting the file from refactoring the feature gate mechanism into separate PRs. Hard to review both at once.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm in favor of moving forward with this change and punting on the larger refactor.

@pohly that's a good point about non-const (I really with go had immutability...). You could probably do something hacky like:

// ...
const APIListChunking featuregate.Feature = "APIListChunking"
var _ = defaultKubernetesFeatureGates.Register(APIListChunking, true, featuregate.Beta)

Note that var _ = is required to call the function outside a method, hence the hackiness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's doable and looks like an improvement over the current approach. I can follow up with that in a second PR once this one has been merged.

Who can provide LGTM and approval?

Copy link
Member

Choose a reason for hiding this comment

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

@liggitt ?? ^

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 15, 2022
@pohly
Copy link
Contributor Author

pohly commented May 4, 2022

... and we have merge conflicts 😢

I'll wait a bit for merging of the backlog to settled down and then update, but can we then merge this quickly?

Merge conflicts become less likely when:
- features are sorted alphabetically because
  then changes are more likely to be done in
  different parts of the files
- blank lines separate the hash entries because
  gofmt then doesn't change the formating of
  other entries when adding or removing one

Merge conflicts where pretty common shortly before a code freeze when everyone
added new features at the end of the files.
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 5, 2022
@pohly
Copy link
Contributor Author

pohly commented May 5, 2022

I've rebased. The first commit is impossible to review manually, so here's some evidence that it really only shuffles lines around. The only non-whitespace changes are the extra comment lines that I added about sorting:

$ for i in $(find . -name kube_features.go); do echo $i:; diff --ignore-all-space <(git show origin/master:$i | sort -u)  <(git show HEAD~:$i | sort -u); done
./pkg/features/kube_features.go:
6a7
> //
10a12
> 	// across the file.
244a247
> // Entries are separated from each other with blank lines to avoid sweeping gofmt changes
259a263
> 	// Feature gates should be listed in alphabetical, case-sensitive
413a418
> 	// of code conflicts because changes are more likely to be scattered
581a587
> 	// (upper before any lower case character) order. This reduces the risk
588a595
> // when adding or removing one entry.
./staging/src/k8s.io/component-base/logs/kube_features.go:
./staging/src/k8s.io/controller-manager/pkg/features/kube_features.go:
6a7
> 	// across the file.
20a22
> 	// Feature gates should be listed in alphabetical, case-sensitive
30c32,33
< 	// MyFeature() bool
---
> 	// MyFeature featuregate.Feature = "MyFeature"
> 	// of code conflicts because changes are more likely to be scattered
39a43
> 	// (upper before any lower case character) order. This reduces the risk
./staging/src/k8s.io/apiextensions-apiserver/pkg/features/kube_features.go:
./staging/src/k8s.io/apiserver/pkg/features/kube_features.go:
6a7
> 	// across the file.
72a74
> 	// Feature gates should be listed in alphabetical, case-sensitive
89c91,92
< 	// MyFeature() bool
---
> 	// MyFeature featuregate.Feature = "MyFeature"
> 	// of code conflicts because changes are more likely to be scattered
135a139
> 	// (upper before any lower case character) order. This reduces the risk

@mtaufen : can you take another look?

This removes all feature definitions that were marked for removal in 1.25, with
some exceptions:
- some features were marked for removal in 1.25 although they only graduated
  to GA in 1.24 - that seems too soon, so the comment was updated instead
- CSIVolumeFSGroupPolicy and PodDisruptionBudget are still used in the code, so
  removing them will be more work and was deferred
@pohly
Copy link
Contributor Author

pohly commented May 5, 2022

/retest

@liggitt
Copy link
Member

liggitt commented May 5, 2022

verified diff:

diff <(git show upstream/master:pkg/features/kube_features.go | egrep "featuregate.Feature =|Default:" | sed -E 's/\s+/ /g' | sort) \
     <(git show HEAD:pkg/features/kube_features.go | egrep "featuregate.Feature =|Default:" | sed -E 's/\s+/ /g' | sort)
38,39d37
<  CSIServiceAccountToken featuregate.Feature = "CSIServiceAccountToken"
<  CSIServiceAccountToken: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.23
72,77d69
<  EndpointSlice featuregate.Feature = "EndpointSlice"
<  EndpointSlice: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
<  EndpointSliceNodeName featuregate.Feature = "EndpointSliceNodeName"
<  EndpointSliceNodeName: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
<  EndpointSliceProxying featuregate.Feature = "EndpointSliceProxying"
<  EndpointSliceProxying: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
85c77
<  ExpandCSIVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.25
---
>  ExpandCSIVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.26
87c79
<  ExpandInUsePersistentVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.25
---
>  ExpandInUsePersistentVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.26
89c81
<  ExpandPersistentVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.25
---
>  ExpandPersistentVolumes: {Default: true, PreRelease: featuregate.GA}, // remove in 1.26
96,97d87
<  GenericEphemeralVolume featuregate.Feature = "GenericEphemeralVolume"
<  GenericEphemeralVolume: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
108,109d97
<  IPv6DualStack featuregate.Feature = "IPv6DualStack"
<  IPv6DualStack: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
130,131d117
<  IngressClassNamespacedParams featuregate.Feature = "IngressClassNamespacedParams"
<  IngressClassNamespacedParams: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
173c159
<  NonPreemptingPriority: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
---
>  NonPreemptingPriority: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26
187c173
<  PreferNominatedNode: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
---
>  PreferNominatedNode: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26
218,219d203
<  StorageObjectInUseProtection featuregate.Feature = "StorageObjectInUseProtection"
<  StorageObjectInUseProtection: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
222,223d205
<  TTLAfterFinished featuregate.Feature = "TTLAfterFinished"
<  TTLAfterFinished: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
230,231d211
<  VolumeSubpath featuregate.Feature = "VolumeSubpath"
<  VolumeSubpath: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
236,237d215
<  WindowsEndpointSliceProxying featuregate.Feature = "WindowsEndpointSliceProxying"
<  WindowsEndpointSliceProxying: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25
diff <(git show upstream/master:staging/src/k8s.io/apiserver/pkg/features/kube_features.go | egrep "featuregate.Feature =|Default:" | sed -E 's/\s+/ /g' | sort) \
     <(git show HEAD:staging/src/k8s.io/apiserver/pkg/features/kube_features.go | egrep "featuregate.Feature =|Default:" | sed -E 's/\s+/ /g' | sort)
0a1
>  // MyFeature featuregate.Feature = "MyFeature"

@liggitt
Copy link
Member

liggitt commented May 5, 2022

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, pohly

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

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 5, 2022
@k8s-ci-robot k8s-ci-robot merged commit 0bd2847 into kubernetes:master May 5, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 5, 2022
@liggitt liggitt mentioned this pull request Dec 22, 2023
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. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants