Skip to content

Commit 9d82148

Browse files
authored
Merge pull request kubernetes#128279 from Jefftree/compat-133
Bump DefaultKubeBinaryVersion to 1.33
2 parents 438bc5d + 59fcd7b commit 9d82148

File tree

11 files changed

+226
-60
lines changed

11 files changed

+226
-60
lines changed

staging/src/k8s.io/apiserver/pkg/server/options/server_run_options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import (
3434
func TestServerRunOptionsValidate(t *testing.T) {
3535
testRegistry := featuregate.NewComponentGlobalsRegistry()
3636
featureGate := utilfeature.DefaultFeatureGate.DeepCopy()
37-
effectiveVersion := utilversion.NewEffectiveVersion("1.30")
38-
effectiveVersion.SetEmulationVersion(version.MajorMinor(1, 32))
37+
effectiveVersion := utilversion.NewEffectiveVersion("1.35")
38+
effectiveVersion.SetEmulationVersion(version.MajorMinor(1, 31))
3939
testComponent := "test"
4040
utilruntime.Must(testRegistry.Register(testComponent, effectiveVersion, featureGate))
4141

@@ -197,7 +197,7 @@ func TestServerRunOptionsValidate(t *testing.T) {
197197
ComponentName: testComponent,
198198
ComponentGlobalsRegistry: testRegistry,
199199
},
200-
expectErr: "emulation version 1.32 is not between [1.29, 1.30.0]",
200+
expectErr: "emulation version 1.31 is not between [1.32, 1.35.0]",
201201
},
202202
{
203203
name: "Test when ServerRunOptions is valid",

staging/src/k8s.io/component-base/featuregate/registry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func TestVersionFlagOptions(t *testing.T) {
118118
func TestVersionFlagOptionsWithMapping(t *testing.T) {
119119
r := testRegistry(t)
120120
utilruntime.Must(r.SetEmulationVersionMapping(testComponent, DefaultKubeComponent,
121-
func(from *version.Version) *version.Version { return from.OffsetMinor(3) }))
121+
func(from *version.Version) *version.Version { return version.MajorMinor(1, from.Minor()+23) }))
122122
emuVers := strings.Join(r.unsafeVersionFlagOptions(true), "\n")
123123
expectedEmuVers := "test=2.8..2.8 (default=2.8)"
124124
if emuVers != expectedEmuVers {

staging/src/k8s.io/component-base/version/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ const (
6666
// DefaultKubeBinaryVersion is the hard coded k8 binary version based on the latest K8s release.
6767
// It is supposed to be consistent with gitMajor and gitMinor, except for local tests, where gitMajor and gitMinor are "".
6868
// Should update for each minor release!
69-
DefaultKubeBinaryVersion = "1.32"
69+
DefaultKubeBinaryVersion = "1.33"
7070
)

staging/src/k8s.io/component-base/version/version.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
apimachineryversion "k8s.io/apimachinery/pkg/version"
2626
)
2727

28+
var minimumKubeEmulationVersion *version.Version = version.MajorMinor(1, 31)
29+
2830
type EffectiveVersion interface {
2931
BinaryVersion() *version.Version
3032
EmulationVersion() *version.Version
@@ -121,8 +123,11 @@ func (m *effectiveVersion) Set(binaryVersion, emulationVersion, minCompatibility
121123

122124
func (m *effectiveVersion) SetEmulationVersion(emulationVersion *version.Version) {
123125
m.emulationVersion.Store(majorMinor(emulationVersion))
126+
// set the default minCompatibilityVersion to be emulationVersion - 1
127+
m.minCompatibilityVersion.Store(majorMinor(emulationVersion.SubtractMinor(1)))
124128
}
125129

130+
// SetMinCompatibilityVersion should be called after SetEmulationVersion
126131
func (m *effectiveVersion) SetMinCompatibilityVersion(minCompatibilityVersion *version.Version) {
127132
m.minCompatibilityVersion.Store(majorMinor(minCompatibilityVersion))
128133
}
@@ -134,15 +139,15 @@ func (m *effectiveVersion) Validate() []error {
134139
emulationVersion := m.emulationVersion.Load()
135140
minCompatibilityVersion := m.minCompatibilityVersion.Load()
136141

137-
// emulationVersion can only be 1.{binaryMinor-1}...1.{binaryMinor}.
142+
// emulationVersion can only be 1.{binaryMinor-3}...1.{binaryMinor}
138143
maxEmuVer := binaryVersion
139-
minEmuVer := binaryVersion.SubtractMinor(1)
144+
minEmuVer := binaryVersion.SubtractMinor(3)
140145
if emulationVersion.GreaterThan(maxEmuVer) || emulationVersion.LessThan(minEmuVer) {
141146
errs = append(errs, fmt.Errorf("emulation version %s is not between [%s, %s]", emulationVersion.String(), minEmuVer.String(), maxEmuVer.String()))
142147
}
143-
// minCompatibilityVersion can only be 1.{binaryMinor-1} for alpha.
144-
maxCompVer := binaryVersion.SubtractMinor(1)
145-
minCompVer := binaryVersion.SubtractMinor(1)
148+
// minCompatibilityVersion can only be 1.{binaryMinor-3} to 1.{binaryMinor}
149+
maxCompVer := emulationVersion
150+
minCompVer := binaryVersion.SubtractMinor(4)
146151
if minCompatibilityVersion.GreaterThan(maxCompVer) || minCompatibilityVersion.LessThan(minCompVer) {
147152
errs = append(errs, fmt.Errorf("minCompatibilityVersion version %s is not between [%s, %s]", minCompatibilityVersion.String(), minCompVer.String(), maxCompVer.String()))
148153
}
@@ -187,13 +192,15 @@ func DefaultKubeEffectiveVersion() MutableEffectiveVersion {
187192
return newEffectiveVersion(binaryVersion, false)
188193
}
189194

190-
// ValidateKubeEffectiveVersion validates the EmulationVersion is equal to the binary version at 1.31 for kube components.
191-
// emulationVersion is introduced in 1.31, so it is only allowed to be equal to the binary version at 1.31.
195+
// ValidateKubeEffectiveVersion validates the EmulationVersion is at least 1.31 and MinCompatibilityVersion
196+
// is at least 1.30 for kube components.
192197
func ValidateKubeEffectiveVersion(effectiveVersion EffectiveVersion) error {
193-
binaryVersion := version.MajorMinor(effectiveVersion.BinaryVersion().Major(), effectiveVersion.BinaryVersion().Minor())
194-
if binaryVersion.EqualTo(version.MajorMinor(1, 31)) && !effectiveVersion.EmulationVersion().EqualTo(binaryVersion) {
195-
return fmt.Errorf("emulation version needs to be equal to binary version(%s) in compatibility-version alpha, got %s",
196-
binaryVersion.String(), effectiveVersion.EmulationVersion().String())
198+
if !effectiveVersion.EmulationVersion().AtLeast(minimumKubeEmulationVersion) {
199+
return fmt.Errorf("emulation version needs to be greater or equal to 1.31, got %s", effectiveVersion.EmulationVersion().String())
200+
}
201+
if !effectiveVersion.MinCompatibilityVersion().AtLeast(minimumKubeEmulationVersion.SubtractMinor(1)) {
202+
return fmt.Errorf("minCompatibilityVersion version needs to be greater or equal to 1.30, got %s", effectiveVersion.MinCompatibilityVersion().String())
197203
}
204+
198205
return nil
199206
}

staging/src/k8s.io/component-base/version/version_test.go

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ func TestValidate(t *testing.T) {
4343
minCompatibilityVersion: "v1.31.0",
4444
},
4545
{
46-
name: "emulation version two minor lower than binary not ok",
46+
name: "emulation version two minor lower than binary ok",
4747
binaryVersion: "v1.33.2",
4848
emulationVersion: "v1.31.0",
49+
minCompatibilityVersion: "v1.31.0",
50+
expectErrors: false,
51+
},
52+
{
53+
name: "emulation version three minor lower than binary ok",
54+
binaryVersion: "v1.35.0",
55+
emulationVersion: "v1.32.0",
56+
minCompatibilityVersion: "v1.32.0",
57+
},
58+
{
59+
name: "emulation version four minor lower than binary not ok",
60+
binaryVersion: "v1.36.0",
61+
emulationVersion: "v1.32.0",
4962
minCompatibilityVersion: "v1.32.0",
5063
expectErrors: true,
5164
},
@@ -64,18 +77,25 @@ func TestValidate(t *testing.T) {
6477
expectErrors: true,
6578
},
6679
{
67-
name: "compatibility version same as binary not ok",
80+
name: "compatibility version same as binary ok",
6881
binaryVersion: "v1.32.2",
6982
emulationVersion: "v1.32.0",
7083
minCompatibilityVersion: "v1.32.0",
71-
expectErrors: true,
84+
expectErrors: false,
7285
},
7386
{
74-
name: "compatibility version two minor lower than binary not ok",
87+
name: "compatibility version two minor lower than binary ok",
7588
binaryVersion: "v1.32.2",
7689
emulationVersion: "v1.32.0",
7790
minCompatibilityVersion: "v1.30.0",
78-
expectErrors: true,
91+
expectErrors: false,
92+
},
93+
{
94+
name: "compatibility version three minor lower than binary ok",
95+
binaryVersion: "v1.34.2",
96+
emulationVersion: "v1.33.0",
97+
minCompatibilityVersion: "v1.31.0",
98+
expectErrors: false,
7999
},
80100
{
81101
name: "compatibility version one minor higher than binary not ok",
@@ -84,6 +104,13 @@ func TestValidate(t *testing.T) {
84104
minCompatibilityVersion: "v1.33.0",
85105
expectErrors: true,
86106
},
107+
{
108+
name: "emulation version lower than compatibility version not ok",
109+
binaryVersion: "v1.34.2",
110+
emulationVersion: "v1.32.0",
111+
minCompatibilityVersion: "v1.33.0",
112+
expectErrors: true,
113+
},
87114
}
88115

89116
for _, test := range tests {
@@ -105,3 +132,54 @@ func TestValidate(t *testing.T) {
105132
})
106133
}
107134
}
135+
136+
func TestValidateKubeEffectiveVersion(t *testing.T) {
137+
tests := []struct {
138+
name string
139+
emulationVersion string
140+
minCompatibilityVersion string
141+
expectErr bool
142+
}{
143+
{
144+
name: "valid versions",
145+
emulationVersion: "v1.31.0",
146+
minCompatibilityVersion: "v1.31.0",
147+
expectErr: false,
148+
},
149+
{
150+
name: "emulationVersion too low",
151+
emulationVersion: "v1.30.0",
152+
minCompatibilityVersion: "v1.31.0",
153+
expectErr: true,
154+
},
155+
{
156+
name: "minCompatibilityVersion too low",
157+
emulationVersion: "v1.31.0",
158+
minCompatibilityVersion: "v1.29.0",
159+
expectErr: true,
160+
},
161+
{
162+
name: "both versions too low",
163+
emulationVersion: "v1.30.0",
164+
minCompatibilityVersion: "v1.30.0",
165+
expectErr: true,
166+
},
167+
}
168+
169+
for _, test := range tests {
170+
t.Run(test.name, func(t *testing.T) {
171+
172+
effective := NewEffectiveVersion("1.32")
173+
effective.SetEmulationVersion(version.MustParseGeneric(test.emulationVersion))
174+
effective.SetMinCompatibilityVersion(version.MustParseGeneric(test.minCompatibilityVersion))
175+
176+
err := ValidateKubeEffectiveVersion(effective)
177+
if test.expectErr && err == nil {
178+
t.Error("expected error, but got nil")
179+
}
180+
if !test.expectErr && err != nil {
181+
t.Errorf("unexpected error: %v", err)
182+
}
183+
})
184+
}
185+
}

test/integration/apiserver/apiserver_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,20 +2975,6 @@ func TestEmulatedStorageVersion(t *testing.T) {
29752975
expectedStorageVersion schema.GroupVersion
29762976
}
29772977
cases := []testCase{
2978-
{
2979-
name: "vap first ga release",
2980-
emulatedVersion: "1.30",
2981-
gvr: schema.GroupVersionResource{
2982-
Group: "admissionregistration.k8s.io",
2983-
Version: "v1",
2984-
Resource: "validatingadmissionpolicies",
2985-
},
2986-
object: validVap,
2987-
expectedStorageVersion: schema.GroupVersion{
2988-
Group: "admissionregistration.k8s.io",
2989-
Version: "v1beta1",
2990-
},
2991-
},
29922978
{
29932979
name: "vap after ga release",
29942980
emulatedVersion: "1.31",

test/integration/controlplane/transformation/kms_transformation_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,6 @@ resources:
618618
endpoint: unix:///@encrypt-all-kms-provider.sock
619619
`
620620

621-
// KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE allows for APIs pending removal to not block tests
622-
t.Setenv("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE", "true")
623-
624621
t.Run("encrypt all resources", func(t *testing.T) {
625622
_ = mock.NewBase64Plugin(t, "@encrypt-all-kms-provider.sock")
626623
// To ensure we are checking all REST resources

test/integration/etcd/data.go

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,54 @@ limitations under the License.
1717
package etcd
1818

1919
import (
20+
"strings"
21+
2022
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2123
"k8s.io/apiextensions-apiserver/test/integration/fixtures"
2224
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2325
"k8s.io/apimachinery/pkg/runtime/schema"
26+
utilversion "k8s.io/component-base/version"
2427

2528
"k8s.io/kubernetes/test/utils/image"
2629
)
2730

28-
// GetEtcdStorageData returns etcd data for all persisted objects.
31+
// GetSupportedEmulatedVersions provides the list of supported emulated versions in the etcd data.
32+
// Tests aiming for full coverage of versions should test fixtures of all supported versions.
33+
func GetSupportedEmulatedVersions() []string {
34+
return []string{
35+
utilversion.DefaultKubeEffectiveVersion().BinaryVersion().SubtractMinor(2).String(),
36+
utilversion.DefaultKubeEffectiveVersion().BinaryVersion().SubtractMinor(1).String(),
37+
utilversion.DefaultKubeEffectiveVersion().BinaryVersion().String(),
38+
}
39+
}
40+
41+
// GetEtcdStorageData returns etcd data for all persisted objects at the latest release version.
2942
// It is exported so that it can be reused across multiple tests.
3043
// It returns a new map on every invocation to prevent different tests from mutating shared state.
3144
func GetEtcdStorageData() map[schema.GroupVersionResource]StorageData {
32-
return GetEtcdStorageDataForNamespace("etcdstoragepathtestnamespace")
45+
return GetEtcdStorageDataServedAt(utilversion.DefaultKubeBinaryVersion, false)
3346
}
3447

35-
// GetEtcdStorageDataForNamespace returns etcd data for all persisted objects.
48+
// GetEtcdStorageDataServedAt returns etcd data for all persisted objects at a particular release version.
49+
// It is exported so that it can be reused across multiple tests.
50+
// It returns a new map on every invocation to prevent different tests from mutating shared state.
51+
func GetEtcdStorageDataServedAt(version string, removeAlphas bool) map[schema.GroupVersionResource]StorageData {
52+
return GetEtcdStorageDataForNamespaceServedAt("etcdstoragepathtestnamespace", version, removeAlphas)
53+
}
54+
55+
// GetEtcdStorageDataForNamespace returns etcd data for all persisted objects at the latest release version.
3656
// It is exported so that it can be reused across multiple tests.
3757
// It returns a new map on every invocation to prevent different tests from mutating shared state.
3858
// Namespaced objects keys are computed for the specified namespace.
3959
func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionResource]StorageData {
60+
return GetEtcdStorageDataForNamespaceServedAt(namespace, utilversion.DefaultKubeBinaryVersion, false)
61+
}
62+
63+
// GetEtcdStorageDataForNamespaceServedAt returns etcd data for all persisted objects at a particular release version.
64+
// It is exported so that it can be reused across multiple tests.
65+
// It returns a new map on every invocation to prevent different tests from mutating shared state.
66+
// Namespaced objects keys are computed for the specified namespace.
67+
func GetEtcdStorageDataForNamespaceServedAt(namespace string, version string, removeAlphas bool) map[schema.GroupVersionResource]StorageData {
4068
image := image.GetE2EImage(image.BusyBox)
4169
etcdStorageData := map[schema.GroupVersionResource]StorageData{
4270
// k8s.io/kubernetes/pkg/api/v1
@@ -465,22 +493,46 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
465493
},
466494
// --
467495

468-
}
496+
// k8s.io/kubernetes/pkg/apis/storage/v1
497+
gvr("storage.k8s.io", "v1", "csinodes"): {
498+
Stub: `{"metadata": {"name": "csini2"}, "spec": {"drivers": [{"name": "test-driver", "nodeID": "localhost", "topologyKeys": ["company.com/zone1", "company.com/zone2"]}]}}`,
499+
ExpectedEtcdPath: "/registry/csinodes/csini2",
500+
},
501+
// --
469502

470-
// add csinodes
471-
// k8s.io/kubernetes/pkg/apis/storage/v1
472-
etcdStorageData[gvr("storage.k8s.io", "v1", "csinodes")] = StorageData{
473-
Stub: `{"metadata": {"name": "csini2"}, "spec": {"drivers": [{"name": "test-driver", "nodeID": "localhost", "topologyKeys": ["company.com/zone1", "company.com/zone2"]}]}}`,
474-
ExpectedEtcdPath: "/registry/csinodes/csini2",
503+
// k8s.io/kubernetes/pkg/apis/storage/v1
504+
gvr("storage.k8s.io", "v1", "csidrivers"): {
505+
Stub: `{"metadata": {"name": "csid2"}, "spec": {"attachRequired": true, "podInfoOnMount": true}}`,
506+
ExpectedEtcdPath: "/registry/csidrivers/csid2",
507+
},
508+
// --
475509
}
476510

477-
// add csidrivers
478-
// k8s.io/kubernetes/pkg/apis/storage/v1
479-
etcdStorageData[gvr("storage.k8s.io", "v1", "csidrivers")] = StorageData{
480-
Stub: `{"metadata": {"name": "csid2"}, "spec": {"attachRequired": true, "podInfoOnMount": true}}`,
481-
ExpectedEtcdPath: "/registry/csidrivers/csid2",
511+
// Delete types no longer served or not yet added at a particular emulated version.
512+
// When adding a brand new type non-alpha type in the latest release, please ensure that
513+
// it is removed in previous emulated versions otherwise emulated version tests will fail.
514+
// TODO: derive this programatically from gvk --> instance --> APILifecycle info
515+
switch version {
516+
case "1.33":
517+
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "flowschemas"))
518+
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "prioritylevelconfigurations"))
519+
case "1.32":
520+
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "flowschemas"))
521+
delete(etcdStorageData, gvr("flowcontrol.apiserver.k8s.io", "v1beta3", "prioritylevelconfigurations"))
522+
case "1.31":
523+
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "deviceclasses"))
524+
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "resourceclaims"))
525+
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "resourceclaimtemplates"))
526+
delete(etcdStorageData, gvr("resource.k8s.io", "v1beta1", "resourceslices"))
482527
}
483528

529+
if removeAlphas {
530+
for key := range etcdStorageData {
531+
if strings.Contains(key.Version, "alpha") {
532+
delete(etcdStorageData, key)
533+
}
534+
}
535+
}
484536
return etcdStorageData
485537
}
486538

0 commit comments

Comments
 (0)