Skip to content

Commit

Permalink
allow multiple sources to add/remove from discovery without clobberin…
Browse files Browse the repository at this point in the history
…g each other

Kubernetes-commit: 0740b11073d08262d4d6687ceedd8f0c71819ebd
  • Loading branch information
Alexander Zielenski authored and k8s-publishing-bot committed Mar 25, 2023
1 parent 508f83b commit eebba51
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 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.51.0
google.golang.org/protobuf v1.28.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.0.0-20230315055831-abe66f57fdb1
k8s.io/api v0.0.0-20230316181320-bad7d34a01c9
k8s.io/apimachinery v0.0.0-20230315054728-8d1258da8f38
k8s.io/apiserver v0.0.0-20230315073553-6fb7281a6b4e
k8s.io/client-go v0.0.0-20230315061845-84ae514115bd
k8s.io/code-generator v0.0.0-20230315053024-8fead9f64de8
k8s.io/component-base v0.0.0-20230315065615-6b9bb8ecc3d0
k8s.io/apiserver v0.0.0-20230322010019-45f55ded302a
k8s.io/client-go v0.0.0-20230317001143-1517ffb8d37c
k8s.io/code-generator v0.0.0-20230325021128-1e0c52da823a
k8s.io/component-base v0.0.0-20230325023505-4d24bb3c2a3c
k8s.io/klog/v2 v2.90.1
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a
k8s.io/utils v0.0.0-20230209194617-a36077c30491
Expand Down Expand Up @@ -120,16 +120,16 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
k8s.io/kms v0.0.0-20230315071534-1cd5a2e8b457 // indirect
k8s.io/kms v0.0.0-20230315071547-f5c193c64781 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.1 // indirect
)

replace (
k8s.io/api => k8s.io/api v0.0.0-20230315055831-abe66f57fdb1
k8s.io/api => k8s.io/api v0.0.0-20230316181320-bad7d34a01c9
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230315054728-8d1258da8f38
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20230315073553-6fb7281a6b4e
k8s.io/client-go => k8s.io/client-go v0.0.0-20230315061845-84ae514115bd
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20230315053024-8fead9f64de8
k8s.io/component-base => k8s.io/component-base v0.0.0-20230315065615-6b9bb8ecc3d0
k8s.io/kms => k8s.io/kms v0.0.0-20230315071534-1cd5a2e8b457
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20230322010019-45f55ded302a
k8s.io/client-go => k8s.io/client-go v0.0.0-20230317001143-1517ffb8d37c
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20230325021128-1e0c52da823a
k8s.io/component-base => k8s.io/component-base v0.0.0-20230325023505-4d24bb3c2a3c
k8s.io/kms => k8s.io/kms v0.0.0-20230315071547-f5c193c64781
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -745,25 +745,25 @@ 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-20230315055831-abe66f57fdb1 h1:XQ9kk+GySLR6UE0w0oqxpzP5QrcsELjK2R7rD7hnWsI=
k8s.io/api v0.0.0-20230315055831-abe66f57fdb1/go.mod h1:aZ6MBt4NMLXSxkSKFkoDaP4hTutnZIvH5dCSpOis9g4=
k8s.io/api v0.0.0-20230316181320-bad7d34a01c9 h1:RX71Fts5hM4MOPrwU2mAILmdHSQipOntTKs8SVRvZNA=
k8s.io/api v0.0.0-20230316181320-bad7d34a01c9/go.mod h1:aZ6MBt4NMLXSxkSKFkoDaP4hTutnZIvH5dCSpOis9g4=
k8s.io/apimachinery v0.0.0-20230315054728-8d1258da8f38 h1:n1qDRCTPAXwyXYg7eSpWDO9FdW79lwAQ9dAr1vETpn4=
k8s.io/apimachinery v0.0.0-20230315054728-8d1258da8f38/go.mod h1:5ikh59fK3AJ287GUvpUsryoMFtH9zj/ARfWCo3AyXTM=
k8s.io/apiserver v0.0.0-20230315073553-6fb7281a6b4e h1:kTLHqdkqQxINH2oGafdnEyCkNk3ZJsvvRoH0JrLwccA=
k8s.io/apiserver v0.0.0-20230315073553-6fb7281a6b4e/go.mod h1:zAYatvCnOC4rwLBV2btewYbbRGpUwo61/7Qd6ltMDOo=
k8s.io/client-go v0.0.0-20230315061845-84ae514115bd h1:dilBefJQ4PnyI4xt/dH3EUQfGx5+tjwQMWL92ICsKoQ=
k8s.io/client-go v0.0.0-20230315061845-84ae514115bd/go.mod h1:Np+Pk6S0Rgul2HDFTuxJLmr5pdZNE9rDxwdzBoxpOF4=
k8s.io/code-generator v0.0.0-20230315053024-8fead9f64de8 h1:abwWEXGDfIhE8v3zs0nSO11/ec+uYCftqHkArBqozaU=
k8s.io/code-generator v0.0.0-20230315053024-8fead9f64de8/go.mod h1:iWtpm0ZMG6Gc4daWfITDSIu+WFhFJArYDhj242zcbnY=
k8s.io/component-base v0.0.0-20230315065615-6b9bb8ecc3d0 h1:IjneP02MOB07PIP9+PQjKrOIZEZ5T7umR+GIZkU4h0U=
k8s.io/component-base v0.0.0-20230315065615-6b9bb8ecc3d0/go.mod h1:kTuptveA6tUMLMKnaq4AbIAAk7IcdhwkbljAV3JZRpM=
k8s.io/apiserver v0.0.0-20230322010019-45f55ded302a h1:6g+5Sg3q/SP8bvXC/gcRU4aU3WTc/SP6r/jbSmoqAP8=
k8s.io/apiserver v0.0.0-20230322010019-45f55ded302a/go.mod h1:nbNcTaE0Dk2eJ+SbWfyZHKtwYB/t8yvJdIHG8x7WWpY=
k8s.io/client-go v0.0.0-20230317001143-1517ffb8d37c h1:29TaJLdOV+6YadAIsdLLH5ImjgMWTuEm3a/COrgIGoI=
k8s.io/client-go v0.0.0-20230317001143-1517ffb8d37c/go.mod h1:+yf0C0ynOsv3GhBRexl/5CJzyS/uxZJ1Gtn6N5GuVmc=
k8s.io/code-generator v0.0.0-20230325021128-1e0c52da823a h1:MjyOi/5LEw178f67AzjInA72s5kLNJfb4LsWAx7Qin8=
k8s.io/code-generator v0.0.0-20230325021128-1e0c52da823a/go.mod h1:iWtpm0ZMG6Gc4daWfITDSIu+WFhFJArYDhj242zcbnY=
k8s.io/component-base v0.0.0-20230325023505-4d24bb3c2a3c h1:Sqi30xPpSoyhAgVj6IxQiRGeC+VdzSDU2ZasbS0TV1A=
k8s.io/component-base v0.0.0-20230325023505-4d24bb3c2a3c/go.mod h1:kTuptveA6tUMLMKnaq4AbIAAk7IcdhwkbljAV3JZRpM=
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=
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kms v0.0.0-20230315071534-1cd5a2e8b457 h1:o7CT9gfjXIcokhNJm1yawSi7V8f19JIr+CjrvdpYfHU=
k8s.io/kms v0.0.0-20230315071534-1cd5a2e8b457/go.mod h1:BpyIA33GjwNSzo+S61DG/HWYw2XVgP9bDjyqaxNOODc=
k8s.io/kms v0.0.0-20230315071547-f5c193c64781 h1:LH9Z43UgXQkuRc1ImiT3F3LoOfj9Xz0r1BP94+uYpys=
k8s.io/kms v0.0.0-20230315071547-f5c193c64781/go.mod h1:9rk1ftD6YM/h1KCjaoIZ8lv1CYvaCcuo57ZIWqiHHGI=
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg=
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY=
k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY=
Expand Down
7 changes: 6 additions & 1 deletion pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/version"
"k8s.io/apiserver/pkg/endpoints/discovery"
"k8s.io/apiserver/pkg/endpoints/discovery/aggregated"
"k8s.io/apiserver/pkg/features"
genericregistry "k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/registry/rest"
Expand Down Expand Up @@ -210,7 +211,11 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
s.GenericAPIServer.Handler.NonGoRestfulMux.HandlePrefix("/apis/", crdHandler)
s.GenericAPIServer.RegisterDestroyFunc(crdHandler.destroy)

discoveryController := NewDiscoveryController(s.Informers.Apiextensions().V1().CustomResourceDefinitions(), versionDiscoveryHandler, groupDiscoveryHandler, genericServer.AggregatedDiscoveryGroupManager)
aggregatedDiscoveryManager := genericServer.AggregatedDiscoveryGroupManager
if aggregatedDiscoveryManager != nil {
aggregatedDiscoveryManager = aggregatedDiscoveryManager.WithSource(aggregated.CRDSource)
}
discoveryController := NewDiscoveryController(s.Informers.Apiextensions().V1().CustomResourceDefinitions(), versionDiscoveryHandler, groupDiscoveryHandler, aggregatedDiscoveryManager)
namingController := status.NewNamingConditionController(s.Informers.Apiextensions().V1().CustomResourceDefinitions(), crdClient.ApiextensionsV1())
nonStructuralSchemaController := nonstructuralschema.NewConditionController(s.Informers.Apiextensions().V1().CustomResourceDefinitions(), crdClient.ApiextensionsV1())
apiApprovalController := apiapproval.NewKubernetesAPIApprovalPolicyConformantConditionController(s.Informers.Apiextensions().V1().CustomResourceDefinitions(), crdClient.ApiextensionsV1())
Expand Down
1 change: 1 addition & 0 deletions pkg/apiserver/customresource_discovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (c *DiscoveryController) sync(version schema.GroupVersion) error {
})
if c.resourceManager != nil {
c.resourceManager.AddGroupVersion(version.Group, apidiscoveryv2beta1.APIVersionDiscovery{
Freshness: apidiscoveryv2beta1.DiscoveryFreshnessCurrent,
Version: version.Version,
Resources: aggregatedApiResourcesForDiscovery,
})
Expand Down
6 changes: 4 additions & 2 deletions pkg/apiserver/customresource_discovery_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ var coolBarCRD = &v1.CustomResourceDefinition{
}

var coolFooDiscovery apidiscoveryv2beta1.APIVersionDiscovery = apidiscoveryv2beta1.APIVersionDiscovery{
Version: "v1",
Version: "v1",
Freshness: apidiscoveryv2beta1.DiscoveryFreshnessCurrent,
Resources: []apidiscoveryv2beta1.APIResourceDiscovery{
{
Resource: "coolfoos",
Expand Down Expand Up @@ -157,7 +158,8 @@ var coolFooDiscovery apidiscoveryv2beta1.APIVersionDiscovery = apidiscoveryv2bet
}

var mergedDiscovery apidiscoveryv2beta1.APIVersionDiscovery = apidiscoveryv2beta1.APIVersionDiscovery{
Version: "v1",
Version: "v1",
Freshness: apidiscoveryv2beta1.DiscoveryFreshnessCurrent,
Resources: []apidiscoveryv2beta1.APIResourceDiscovery{
{
Resource: "coolbars",
Expand Down

0 comments on commit eebba51

Please sign in to comment.