Remove StatefulSetStartOrdinal feature gate to target stable in 1.31

This commit is contained in:
Peter Schuurman 2024-07-08 19:24:30 -07:00
parent 1904a56e30
commit 585971431b
18 changed files with 32 additions and 130 deletions

View File

@ -2832,7 +2832,7 @@
},
"ordinals": {
"$ref": "#/definitions/io.k8s.api.apps.v1.StatefulSetOrdinals",
"description": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta."
"description": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested."
},
"persistentVolumeClaimRetentionPolicy": {
"$ref": "#/definitions/io.k8s.api.apps.v1.StatefulSetPersistentVolumeClaimRetentionPolicy",

View File

@ -1090,7 +1090,7 @@
"$ref": "#/components/schemas/io.k8s.api.apps.v1.StatefulSetOrdinals"
}
],
"description": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta."
"description": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested."
},
"persistentVolumeClaimRetentionPolicy": {
"allOf": [

View File

@ -236,9 +236,7 @@ type StatefulSetSpec struct {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
Ordinals *StatefulSetOrdinals
}

View File

@ -698,8 +698,6 @@ func emptyInvariants(set *apps.StatefulSet, om *fakeObjectManager) error {
}
func TestStatefulSetControlWithStartOrdinal(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.StatefulSetStartOrdinal, true)
simpleSetFn := func() *apps.StatefulSet {
statefulSet := newStatefulSet(3)
statefulSet.Spec.Ordinals = &apps.StatefulSetOrdinals{Start: int32(2)}

View File

@ -90,10 +90,8 @@ func getOrdinal(pod *v1.Pod) int {
// getStartOrdinal gets the first possible ordinal (inclusive).
// Returns spec.ordinals.start if spec.ordinals is set, otherwise returns 0.
func getStartOrdinal(set *apps.StatefulSet) int {
if utilfeature.DefaultFeatureGate.Enabled(features.StatefulSetStartOrdinal) {
if set.Spec.Ordinals != nil {
return int(set.Spec.Ordinals.Start)
}
if set.Spec.Ordinals != nil {
return int(set.Spec.Ordinals.Start)
}
return 0
}

View File

@ -778,6 +778,7 @@ const (
// owner: @psch
// alpha: v1.26
// beta: v1.27
// stable: v1.31
//
// Enables a StatefulSet to start from an arbitrary non zero ordinal
StatefulSetStartOrdinal featuregate.Feature = "StatefulSetStartOrdinal"
@ -1171,7 +1172,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
StatefulSetAutoDeletePVC: {Default: true, PreRelease: featuregate.Beta},
StatefulSetStartOrdinal: {Default: true, PreRelease: featuregate.Beta},
StatefulSetStartOrdinal: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // GA in 1.31, remove in 1.33
StorageVersionMigrator: {Default: false, PreRelease: featuregate.Alpha},

View File

@ -7756,7 +7756,7 @@ func schema_k8sio_api_apps_v1_StatefulSetSpec(ref common.ReferenceCallback) comm
},
"ordinals": {
SchemaProps: spec.SchemaProps{
Description: "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta.",
Description: "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested.",
Ref: ref("k8s.io/api/apps/v1.StatefulSetOrdinals"),
},
},
@ -8901,7 +8901,7 @@ func schema_k8sio_api_apps_v1beta1_StatefulSetSpec(ref common.ReferenceCallback)
},
"ordinals": {
SchemaProps: spec.SchemaProps{
Description: "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta.",
Description: "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested.",
Ref: ref("k8s.io/api/apps/v1beta1.StatefulSetOrdinals"),
},
},
@ -10600,7 +10600,7 @@ func schema_k8sio_api_apps_v1beta2_StatefulSetSpec(ref common.ReferenceCallback)
},
"ordinals": {
SchemaProps: spec.SchemaProps{
Description: "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta.",
Description: "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested.",
Ref: ref("k8s.io/api/apps/v1beta2.StatefulSetOrdinals"),
},
},

View File

@ -363,12 +363,11 @@ func makeStatefulSetWithStatefulSetOrdinals(ordinals *apps.StatefulSetOrdinals)
// TestDropStatefulSetDisabledFields tests if the drop functionality is working fine or not
func TestDropStatefulSetDisabledFields(t *testing.T) {
testCases := []struct {
name string
enableMaxUnavailable bool
enableStatefulSetStartOrdinal bool
ss *apps.StatefulSet
oldSS *apps.StatefulSet
expectedSS *apps.StatefulSet
name string
enableMaxUnavailable bool
ss *apps.StatefulSet
oldSS *apps.StatefulSet
expectedSS *apps.StatefulSet
}{
{
name: "set minReadySeconds, no update",
@ -421,39 +420,23 @@ func TestDropStatefulSetDisabledFields(t *testing.T) {
ss: makeStatefulSetWithMaxUnavailable(getMaxUnavailable(1)),
oldSS: makeStatefulSetWithMaxUnavailable(getMaxUnavailable(3)),
expectedSS: makeStatefulSetWithMaxUnavailable(getMaxUnavailable(1)),
}, {
name: "StatefulSetStartOrdinal disabled, ordinals in use in new only",
enableStatefulSetStartOrdinal: false,
ss: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
oldSS: nil,
expectedSS: makeStatefulSetWithStatefulSetOrdinals(nil),
},
{
name: "StatefulSetStartOrdinal disabled, ordinals in use in both old and new",
enableStatefulSetStartOrdinal: false,
ss: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
oldSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(1)),
expectedSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
name: "set ordinals, ordinals in use in new only",
ss: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
oldSS: nil,
expectedSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
},
{
name: "StatefulSetStartOrdinal enabled, ordinals in use in new only",
enableStatefulSetStartOrdinal: true,
ss: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
oldSS: nil,
expectedSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
},
{
name: "StatefulSetStartOrdinal enabled, ordinals in use in both old and new",
enableStatefulSetStartOrdinal: true,
ss: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
oldSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(1)),
expectedSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
name: "set ordinals, ordinals in use in both old and new",
ss: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
oldSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(1)),
expectedSS: makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2)),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MaxUnavailableStatefulSet, tc.enableMaxUnavailable)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.StatefulSetStartOrdinal, tc.enableStatefulSetStartOrdinal)
old := tc.oldSS.DeepCopy()
dropStatefulSetDisabledFields(tc.ss, tc.oldSS)
@ -469,66 +452,3 @@ func TestDropStatefulSetDisabledFields(t *testing.T) {
})
}
}
func TestStatefulSetStartOrdinalEnablement(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.StatefulSetStartOrdinal, true)
ss := makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2))
expectedSS := makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2))
ss.Spec.Replicas = 1
ctx := genericapirequest.NewDefaultContext()
Strategy.PrepareForCreate(ctx, ss)
if diff := cmp.Diff(expectedSS.Spec.Ordinals, ss.Spec.Ordinals); diff != "" {
t.Fatalf("Strategy.PrepareForCreate(%v) unexpected .spec.ordinals change: (-want, +got):\n%v", ss, diff)
}
errs := Strategy.Validate(ctx, ss)
if len(errs) != 0 {
t.Errorf("Strategy.Validate(%v) returned error: %v", ss, errs)
}
if ss.Generation != 1 {
t.Errorf("Generation = %v, want = 1 for StatefulSet: %v", ss.Generation, ss)
}
// Validate that the ordinals field is retained when StatefulSetStartOridnal is disabled.
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.StatefulSetStartOrdinal, false)
ssWhenDisabled := makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2))
ssWhenDisabled.Spec.Replicas = 2
Strategy.PrepareForUpdate(ctx, ssWhenDisabled, ss)
if diff := cmp.Diff(expectedSS.Spec.Ordinals, ssWhenDisabled.Spec.Ordinals); diff != "" {
t.Fatalf("Strategy.PrepareForUpdate(%v) unexpected .spec.ordinals change: (-want, +got):\n%v", ssWhenDisabled, diff)
}
errs = Strategy.Validate(ctx, ssWhenDisabled)
if len(errs) != 0 {
t.Errorf("Strategy.Validate(%v) returned error: %v", ssWhenDisabled, errs)
}
if ssWhenDisabled.Generation != 2 {
t.Errorf("Generation = %v, want = 2 for StatefulSet: %v", ssWhenDisabled.Generation, ssWhenDisabled)
}
// Validate that the ordinal field is after re-enablement.
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.StatefulSetStartOrdinal, false)
ssWhenEnabled := makeStatefulSetWithStatefulSetOrdinals(createOrdinalsWithStart(2))
ssWhenEnabled.Spec.Replicas = 3
Strategy.PrepareForUpdate(ctx, ssWhenEnabled, ssWhenDisabled)
if diff := cmp.Diff(expectedSS.Spec.Ordinals, ssWhenEnabled.Spec.Ordinals); diff != "" {
t.Fatalf("Strategy.PrepareForUpdate(%v) unexpected .spec.ordinals change: (-want, +got):\n%v", ssWhenEnabled, diff)
}
errs = Strategy.Validate(ctx, ssWhenEnabled)
if len(errs) != 0 {
t.Errorf("Strategy.Validate(%v) returned error: %v", ssWhenEnabled, errs)
}
if ssWhenEnabled.Generation != 3 {
t.Errorf("Generation = %v, want = 3 for StatefulSet: %v", ssWhenEnabled.Generation, ssWhenEnabled)
}
}

View File

@ -744,9 +744,7 @@ message StatefulSetSpec {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
optional StatefulSetOrdinals ordinals = 11;
}

View File

@ -262,9 +262,7 @@ type StatefulSetSpec struct {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
Ordinals *StatefulSetOrdinals `json:"ordinals,omitempty" protobuf:"bytes,11,opt,name=ordinals"`
}

View File

@ -355,7 +355,7 @@ var map_StatefulSetSpec = map[string]string{
"revisionHistoryLimit": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.",
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
"persistentVolumeClaimRetentionPolicy": "persistentVolumeClaimRetentionPolicy describes the lifecycle of persistent volume claims created from volumeClaimTemplates. By default, all persistent volume claims are created as needed and retained until manually deleted. This policy allows the lifecycle to be altered, for example by deleting persistent volume claims when their stateful set is deleted, or when their pod is scaled down. This requires the StatefulSetAutoDeletePVC feature gate to be enabled, which is beta.",
"ordinals": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta.",
"ordinals": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested.",
}
func (StatefulSetSpec) SwaggerDoc() map[string]string {

View File

@ -493,9 +493,7 @@ message StatefulSetSpec {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
optional StatefulSetOrdinals ordinals = 11;
}

View File

@ -297,9 +297,7 @@ type StatefulSetSpec struct {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
Ordinals *StatefulSetOrdinals `json:"ordinals,omitempty" protobuf:"bytes,11,opt,name=ordinals"`
}

View File

@ -259,7 +259,7 @@ var map_StatefulSetSpec = map[string]string{
"revisionHistoryLimit": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.",
"minReadySeconds": "minReadySeconds is the minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
"persistentVolumeClaimRetentionPolicy": "PersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates. This requires the StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha.",
"ordinals": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta.",
"ordinals": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested.",
}
func (StatefulSetSpec) SwaggerDoc() map[string]string {

View File

@ -785,9 +785,7 @@ message StatefulSetSpec {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
optional StatefulSetOrdinals ordinals = 11;
}

View File

@ -307,9 +307,7 @@ type StatefulSetSpec struct {
// ordinals controls the numbering of replica indices in a StatefulSet. The
// default ordinals behavior assigns a "0" index to the first replica and
// increments the index by one for each additional replica requested. Using
// the ordinals field requires the StatefulSetStartOrdinal feature gate to be
// enabled, which is beta.
// increments the index by one for each additional replica requested.
// +optional
Ordinals *StatefulSetOrdinals `json:"ordinals,omitempty" protobuf:"bytes,11,opt,name=ordinals"`
}

View File

@ -383,7 +383,7 @@ var map_StatefulSetSpec = map[string]string{
"revisionHistoryLimit": "revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet's revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.",
"minReadySeconds": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
"persistentVolumeClaimRetentionPolicy": "PersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates. This requires the StatefulSetAutoDeletePVC feature gate to be enabled, which is alpha.",
"ordinals": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested. Using the ordinals field requires the StatefulSetStartOrdinal feature gate to be enabled, which is beta.",
"ordinals": "ordinals controls the numbering of replica indices in a StatefulSet. The default ordinals behavior assigns a \"0\" index to the first replica and increments the index by one for each additional replica requested.",
}
func (StatefulSetSpec) SwaggerDoc() map[string]string {

View File

@ -694,7 +694,6 @@ func TestStatefulSetStartOrdinal(t *testing.T) {
},
}
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.StatefulSetStartOrdinal, true)
tCtx, closeFn, rm, informers, c := scSetup(t)
defer closeFn()
cancel := runControllerAndInformers(tCtx, rm, informers)