From 4bee62cfd78e1e82111e1f37a484751784d8a9dc Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Wed, 2 Dec 2020 21:07:31 -0500 Subject: [PATCH 1/4] cloud-controller-manager: routes controller should not depend on --allocate-node-cidrs Signed-off-by: Andrew Sy Kim --- staging/src/k8s.io/cloud-provider/app/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/cloud-provider/app/core.go b/staging/src/k8s.io/cloud-provider/app/core.go index d7a1ccc5c9c..fbebc0b1390 100644 --- a/staging/src/k8s.io/cloud-provider/app/core.go +++ b/staging/src/k8s.io/cloud-provider/app/core.go @@ -104,8 +104,8 @@ func startServiceController(ctx *config.CompletedConfig, cloud cloudprovider.Int } func startRouteController(ctx *config.CompletedConfig, cloud cloudprovider.Interface, stopCh <-chan struct{}) (http.Handler, bool, error) { - if !ctx.ComponentConfig.KubeCloudShared.AllocateNodeCIDRs || !ctx.ComponentConfig.KubeCloudShared.ConfigureCloudRoutes { - klog.Infof("Will not configure cloud provider routes for allocate-node-cidrs: %v, configure-cloud-routes: %v.", ctx.ComponentConfig.KubeCloudShared.AllocateNodeCIDRs, ctx.ComponentConfig.KubeCloudShared.ConfigureCloudRoutes) + if !ctx.ComponentConfig.KubeCloudShared.ConfigureCloudRoutes { + klog.Infof("Will not configure cloud provider routes, --configure-cloud-routes: %v", ctx.ComponentConfig.KubeCloudShared.ConfigureCloudRoutes) return nil, false, nil } From 794122dd3ef49149d8084f604cf2d563c04e2999 Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Wed, 2 Dec 2020 21:08:06 -0500 Subject: [PATCH 2/4] cloud-controller-manager: improve warning message for --configure-cloud-routes Signed-off-by: Andrew Sy Kim --- staging/src/k8s.io/cloud-provider/app/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/src/k8s.io/cloud-provider/app/core.go b/staging/src/k8s.io/cloud-provider/app/core.go index fbebc0b1390..92dbc8555fe 100644 --- a/staging/src/k8s.io/cloud-provider/app/core.go +++ b/staging/src/k8s.io/cloud-provider/app/core.go @@ -112,7 +112,7 @@ func startRouteController(ctx *config.CompletedConfig, cloud cloudprovider.Inter // If CIDRs should be allocated for pods and set on the CloudProvider, then start the route controller routes, ok := cloud.Routes() if !ok { - klog.Warning("configure-cloud-routes is set, but cloud provider does not support routes. Will not configure cloud provider routes.") + klog.Warning("--configure-cloud-routes is set, but cloud provider does not support routes. Will not configure cloud provider routes.") return nil, false, nil } From 00f9aef0ab1b4672a4e18e96091dbbfca6c1d9f4 Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Thu, 3 Dec 2020 14:01:44 -0500 Subject: [PATCH 3/4] cloud-provider: allow disable interfaces from fake cloud provider Signed-off-by: Andrew Sy Kim --- staging/src/k8s.io/cloud-provider/fake/fake.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/cloud-provider/fake/fake.go b/staging/src/k8s.io/cloud-provider/fake/fake.go index fa085ea5ec1..7748dbfd7e5 100644 --- a/staging/src/k8s.io/cloud-provider/fake/fake.go +++ b/staging/src/k8s.io/cloud-provider/fake/fake.go @@ -56,6 +56,12 @@ var _ cloudprovider.Clusters = (*Cloud)(nil) // Cloud is a test-double implementation of Interface, LoadBalancer, Instances, and Routes. It is useful for testing. type Cloud struct { + DisableInstances bool + DisableRoutes bool + DisableLoadBalancers bool + DisableZones bool + DisableClusters bool + Exists bool Err error @@ -126,7 +132,7 @@ func (f *Cloud) Master(ctx context.Context, name string) (string, error) { // Clusters returns a clusters interface. Also returns true if the interface is supported, false otherwise. func (f *Cloud) Clusters() (cloudprovider.Clusters, bool) { - return f, true + return f, !f.DisableClusters } // ProviderName returns the cloud provider ID. @@ -145,14 +151,14 @@ func (f *Cloud) HasClusterID() bool { // LoadBalancer returns a fake implementation of LoadBalancer. // Actually it just returns f itself. func (f *Cloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) { - return f, true + return f, !f.DisableLoadBalancers } // Instances returns a fake implementation of Instances. // // Actually it just returns f itself. func (f *Cloud) Instances() (cloudprovider.Instances, bool) { - return f, true + return f, !f.DisableInstances } // InstancesV2 returns a fake implementation of InstancesV2. @@ -167,12 +173,12 @@ func (f *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) { // Zones returns a zones interface. Also returns true if the interface is supported, false otherwise. func (f *Cloud) Zones() (cloudprovider.Zones, bool) { - return f, true + return f, !f.DisableZones } // Routes returns a routes interface along with whether the interface is supported. func (f *Cloud) Routes() (cloudprovider.Routes, bool) { - return f, true + return f, !f.DisableRoutes } // GetLoadBalancer is a stub implementation of LoadBalancer.GetLoadBalancer. From 0c90d8ddd9ba6b8f5729223239bc86552f25b2a5 Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Thu, 3 Dec 2020 14:02:45 -0500 Subject: [PATCH 4/4] test/integration: disable fake cloud routes controllers in cloud-controller-manager secure serving tests Signed-off-by: Andrew Sy Kim --- test/integration/serving/serving_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/integration/serving/serving_test.go b/test/integration/serving/serving_test.go index de9ad11fd7b..95b914b058b 100644 --- a/test/integration/serving/serving_test.go +++ b/test/integration/serving/serving_test.go @@ -327,5 +327,7 @@ func intPtr(x int) *int { } func fakeCloudProviderFactory(io.Reader) (cloudprovider.Interface, error) { - return &fake.Cloud{}, nil + return &fake.Cloud{ + DisableRoutes: true, // disable routes for server tests, otherwise --cluster-cidr is required + }, nil }