Skip to content

Commit

Permalink
fix aggregated discovery version sorting
Browse files Browse the repository at this point in the history
add test for level based priorities

Kubernetes-commit: 3c68fe6596922dc535b5af03f409611e57258f9d
  • Loading branch information
Alexander Zielenski authored and k8s-publishing-bot committed Nov 16, 2022
1 parent d2c9e18 commit f9c2bba
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 33 deletions.
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ require (
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.0.0-20221108053748-98c1aa6b3d0a
k8s.io/apimachinery v0.0.0-20221108055230-fd8a60496be5
k8s.io/apiserver v0.0.0-20221109094018-807ba65cc7a8
k8s.io/client-go v0.0.0-20221108173010-769443557e04
k8s.io/code-generator v0.0.0-20221108000200-7429fbb99432
k8s.io/component-base v0.0.0-20221109013135-4e8a9589a311
k8s.io/api v0.0.0-20221111134724-3590edaeeded
k8s.io/apimachinery v0.0.0-20221116134806-067949de242e
k8s.io/apiserver v0.0.0-20221111215908-6e05bfb03c8d
k8s.io/client-go v0.0.0-20221111215036-61cd728579d3
k8s.io/code-generator v0.0.0-20221107193021-11d5c4c49cbf
k8s.io/component-base v0.0.0-20221116140657-28d9ad4489e9
k8s.io/klog/v2 v2.80.1
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d
Expand Down Expand Up @@ -125,11 +125,11 @@ require (
)

replace (
k8s.io/api => k8s.io/api v0.0.0-20221108053748-98c1aa6b3d0a
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20221108055230-fd8a60496be5
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20221109094018-807ba65cc7a8
k8s.io/client-go => k8s.io/client-go v0.0.0-20221108173010-769443557e04
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20221108000200-7429fbb99432
k8s.io/component-base => k8s.io/component-base v0.0.0-20221109013135-4e8a9589a311
k8s.io/api => k8s.io/api v0.0.0-20221111134724-3590edaeeded
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20221116134806-067949de242e
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20221111215908-6e05bfb03c8d
k8s.io/client-go => k8s.io/client-go v0.0.0-20221111215036-61cd728579d3
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20221107193021-11d5c4c49cbf
k8s.io/component-base => k8s.io/component-base v0.0.0-20221116140657-28d9ad4489e9
k8s.io/kms => k8s.io/kms v0.0.0-20221028080743-a9ba1c11c0c6
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -869,18 +869,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20221108053748-98c1aa6b3d0a h1:GaCla9HtNyi63kysI/cyeA4bv6wRkIyuiUeXpaTF+dw=
k8s.io/api v0.0.0-20221108053748-98c1aa6b3d0a/go.mod h1:PSXY9/fSNyKgKHUU+O9scnZiW8m+V1znqk49oI6hAEY=
k8s.io/apimachinery v0.0.0-20221108055230-fd8a60496be5 h1:iFAMJ1evvrO6X7dS7EKujS6An+bp3u/dD6opu8rn0QA=
k8s.io/apimachinery v0.0.0-20221108055230-fd8a60496be5/go.mod h1:VXMmlsE7YRJ5vyAyWpkKIfFkEbDNpVs0ObpkuQf1WfM=
k8s.io/apiserver v0.0.0-20221109094018-807ba65cc7a8 h1:nb4/V/X+Isa/QCEEoMibzBiAsUunnY9TJl9XdKCSH44=
k8s.io/apiserver v0.0.0-20221109094018-807ba65cc7a8/go.mod h1:D07/28EX92tshRpWdcPpMb4TwlTZNGMh9DKrw5WQ+1E=
k8s.io/client-go v0.0.0-20221108173010-769443557e04 h1:ad7JkOkiLiyMKWHRkmbJgjCzySdkXxRxWeNosATW0mo=
k8s.io/client-go v0.0.0-20221108173010-769443557e04/go.mod h1:O6sEWJ2BPd8Dag831LA1lzC3WnE29nuwUJZZ4H2vlyo=
k8s.io/code-generator v0.0.0-20221108000200-7429fbb99432 h1:lWxXcC+YG3ZY5sCsk337h9RgzUK0sWoNWf8fs6KZm0I=
k8s.io/code-generator v0.0.0-20221108000200-7429fbb99432/go.mod h1:EzIGoP4u7NcVT4orMRQyvQcWqFCUVApa+V+28R7t/+M=
k8s.io/component-base v0.0.0-20221109013135-4e8a9589a311 h1:rUbuNcL4yd5fSmGBMgRYsaodvXqHiu9TwjcmqH2toRY=
k8s.io/component-base v0.0.0-20221109013135-4e8a9589a311/go.mod h1:5bp64lK0p+wJD2BFMin7Akfxiwvt58T4iDz2Q+6woBE=
k8s.io/api v0.0.0-20221111134724-3590edaeeded h1:zEajzE/qy2hPxVOHvnoEA1Llrfap/TN//rm7MsLzVxA=
k8s.io/api v0.0.0-20221111134724-3590edaeeded/go.mod h1:j2jT1HZpNN4eUpl6xrwjWC1amreYNCdsevVdZMhBz5o=
k8s.io/apimachinery v0.0.0-20221116134806-067949de242e h1:TVs+bZy3ij+o1TzjRJh2ddFxFW5mjRFRrm8Juo1ywJA=
k8s.io/apimachinery v0.0.0-20221116134806-067949de242e/go.mod h1:VXMmlsE7YRJ5vyAyWpkKIfFkEbDNpVs0ObpkuQf1WfM=
k8s.io/apiserver v0.0.0-20221111215908-6e05bfb03c8d h1:pLrHJxKs5nPy9N1+ji60SFwktjdkoOLLRx6I8mAlo8s=
k8s.io/apiserver v0.0.0-20221111215908-6e05bfb03c8d/go.mod h1:z9nU9Ku8OzfEjBUf9WL9tZNCJewl94fReBnWCCn0Axo=
k8s.io/client-go v0.0.0-20221111215036-61cd728579d3 h1:sdv5LXwMrLTx/fCpBOuSNCzTQH/iTyCJX8OvbfVeB2M=
k8s.io/client-go v0.0.0-20221111215036-61cd728579d3/go.mod h1:8KENq1nSKXFO1f9JEjrFEWWR/Xkx07EOpM5zL6cgwUU=
k8s.io/code-generator v0.0.0-20221107193021-11d5c4c49cbf h1:NrKwmGRbPk2zHAVcZarDPiYFAGVnkQ2DxOZ+KFs1OqE=
k8s.io/code-generator v0.0.0-20221107193021-11d5c4c49cbf/go.mod h1:EzIGoP4u7NcVT4orMRQyvQcWqFCUVApa+V+28R7t/+M=
k8s.io/component-base v0.0.0-20221116140657-28d9ad4489e9 h1:W7C4Zm/yhhcm3Ck9q8kk6iR50yjK6/nViGeFPAW95Is=
k8s.io/component-base v0.0.0-20221116140657-28d9ad4489e9/go.mod h1:TZu8KRSJNxWIBMrKMikLlNk4JN4T9G/boOZ9/yj2xdU=
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d h1:U9tB195lKdzwqicbJvyJeOXV7Klv+wNAWENRnXEGi08=
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
Expand Down
2 changes: 1 addition & 1 deletion pkg/apiserver/customresource_discovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
Resources: aggregatedApiResourcesForDiscovery,
})
// Default priority for CRDs
c.resourceManager.SetGroupPriority(version.Group, 1000)
c.resourceManager.SetGroupVersionPriority(metav1.GroupVersion(version), 1000, 100)
}
return nil
}
Expand Down
29 changes: 21 additions & 8 deletions pkg/apiserver/customresource_discovery_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,17 @@ func TestResourceManagerExistingCRD(t *testing.T) {

env.FakeResourceManager.Expect().
AddGroupVersion(coolFooCRD.Spec.Group, coolFooDiscovery)
env.FakeResourceManager.Expect().
SetGroupPriority(coolFooCRD.Spec.Group, 1000)
for _, v := range coolFooCRD.Spec.Versions {
env.FakeResourceManager.Expect().
SetGroupVersionPriority(metav1.GroupVersion{Group: coolFooCRD.Spec.Group, Version: v.Name}, 1000, 100)
}

env.FakeResourceManager.Expect().
AddGroupVersion(coolFooCRD.Spec.Group, coolFooDiscovery)
env.FakeResourceManager.Expect().
SetGroupPriority(coolFooCRD.Spec.Group, 1000)
for _, v := range coolFooCRD.Spec.Versions {
env.FakeResourceManager.Expect().
SetGroupVersionPriority(metav1.GroupVersion{Group: coolFooCRD.Spec.Group, Version: v.Name}, 1000, 100)
}

env.Start(ctx)
err = env.FakeResourceManager.WaitForActions(ctx, 1*time.Second)
Expand All @@ -295,7 +299,10 @@ func TestResourceManagerAddedCRD(t *testing.T) {
env := setup()
env.FakeResourceManager.Expect().
AddGroupVersion(coolFooCRD.Spec.Group, coolFooDiscovery)
env.FakeResourceManager.Expect().SetGroupPriority(coolFooCRD.Spec.Group, 1000)
for _, v := range coolFooCRD.Spec.Versions {
env.FakeResourceManager.Expect().
SetGroupVersionPriority(metav1.GroupVersion{Group: coolFooCRD.Spec.Group, Version: v.Name}, 1000, 100)
}

env.Start(ctx)

Expand Down Expand Up @@ -340,7 +347,9 @@ func TestMultipleCRDSameVersion(t *testing.T) {
require.NoError(t, err)
env.FakeResourceManager.Expect().
AddGroupVersion(coolFooCRD.Spec.Group, coolFooDiscovery)
env.FakeResourceManager.Expect().SetGroupPriority(coolFooCRD.Spec.Group, 1000)
for _, versionEntry := range coolFooCRD.Spec.Versions {
env.FakeResourceManager.Expect().SetGroupVersionPriority(metav1.GroupVersion{Group: coolFooCRD.Spec.Group, Version: versionEntry.Name}, 1000, 100)
}
err = env.FakeResourceManager.WaitForActions(ctx, 1*time.Second)
require.NoError(t, err)

Expand All @@ -358,7 +367,9 @@ func TestMultipleCRDSameVersion(t *testing.T) {

env.FakeResourceManager.Expect().
AddGroupVersion(coolFooCRD.Spec.Group, mergedDiscovery)
env.FakeResourceManager.Expect().SetGroupPriority(coolFooCRD.Spec.Group, 1000)
for _, versionEntry := range coolFooCRD.Spec.Versions {
env.FakeResourceManager.Expect().SetGroupVersionPriority(metav1.GroupVersion{Group: coolFooCRD.Spec.Group, Version: versionEntry.Name}, 1000, 100)
}
err = env.FakeResourceManager.WaitForActions(ctx, 1*time.Second)
require.NoError(t, err)
}
Expand Down Expand Up @@ -388,7 +399,9 @@ func TestDiscoveryControllerResourceManagerRemovedCRD(t *testing.T) {
// Resource Manager
env.FakeResourceManager.Expect().
AddGroupVersion(coolFooCRD.Spec.Group, coolFooDiscovery)
env.FakeResourceManager.Expect().SetGroupPriority(coolFooCRD.Spec.Group, 1000)
for _, versionEntry := range coolFooCRD.Spec.Versions {
env.FakeResourceManager.Expect().SetGroupVersionPriority(metav1.GroupVersion{Group: coolFooCRD.Spec.Group, Version: versionEntry.Name}, 1000, 100)
}
err = env.FakeResourceManager.WaitForActions(ctx, 1*time.Second)
require.NoError(t, err)

Expand Down

0 comments on commit f9c2bba

Please sign in to comment.