From bfe3210cccb6ae13ec9fecd11a7e33f61c2eba38 Mon Sep 17 00:00:00 2001 From: Sunghoon Kang Date: Tue, 4 Jan 2022 00:50:23 +0900 Subject: [PATCH] Install APIGroup once for multiple DNS providers If we register multiple DNS providers while running the webhook server, it will cause an unexpected exit with 'WebService with duplicate root path detected' error. This issue happens because the root path of each DNS provider is equal since they share the group name. This commit installs APIGroup once for multiple DNS providers by extracting apiGroupInfo variable and InstallAPIGroup call from solver (DNS provider) loop in ChallengeServer constructor. Signed-off-by: Sunghoon Kang --- pkg/acme/webhook/apiserver/apiserver.go | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pkg/acme/webhook/apiserver/apiserver.go b/pkg/acme/webhook/apiserver/apiserver.go index 34ff5ca01..378a37621 100644 --- a/pkg/acme/webhook/apiserver/apiserver.go +++ b/pkg/acme/webhook/apiserver/apiserver.go @@ -123,18 +123,18 @@ func (c completedConfig) New() (*ChallengeServer, error) { return nil, err } - for _, solver := range solversByName(c.ExtraConfig.Solvers...) { - // TODO we're going to need a later k8s.io/apiserver so that we can get discovery to list a different group version for - // our endpoint which we'll use to back some custom storage which will consume the AdmissionReview type and give back the correct response - apiGroupInfo := genericapiserver.APIGroupInfo{ - VersionedResourcesStorageMap: map[string]map[string]rest.Storage{}, - // TODO unhardcode this. It was hardcoded before, but we need to re-evaluate - OptionsExternalVersion: &schema.GroupVersion{Version: "v1alpha1"}, - Scheme: Scheme, - ParameterCodec: metav1.ParameterCodec, - NegotiatedSerializer: Codecs, - } + // TODO we're going to need a later k8s.io/apiserver so that we can get discovery to list a different group version for + // our endpoint which we'll use to back some custom storage which will consume the AdmissionReview type and give back the correct response + apiGroupInfo := genericapiserver.APIGroupInfo{ + VersionedResourcesStorageMap: map[string]map[string]rest.Storage{}, + // TODO unhardcode this. It was hardcoded before, but we need to re-evaluate + OptionsExternalVersion: &schema.GroupVersion{Version: "v1alpha1"}, + Scheme: Scheme, + ParameterCodec: metav1.ParameterCodec, + NegotiatedSerializer: Codecs, + } + for _, solver := range solversByName(c.ExtraConfig.Solvers...) { challengeHandler := challengepayload.NewREST(solver) v1alpha1storage, ok := apiGroupInfo.VersionedResourcesStorageMap["v1alpha1"] if !ok { @@ -154,10 +154,9 @@ func (c completedConfig) New() (*ChallengeServer, error) { v1alpha1storage[gvr.Resource] = challengeHandler apiGroupInfo.VersionedResourcesStorageMap[gvr.Version] = v1alpha1storage - - if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { - return nil, err - } + } + if err := s.GenericAPIServer.InstallAPIGroup(&apiGroupInfo); err != nil { + return nil, err } for i := range c.ExtraConfig.Solvers {