From 9be91e42c76d89f7d9b2241b7f59335a38ed2dda Mon Sep 17 00:00:00 2001 From: Shyam Jeedigunta Date: Mon, 11 Sep 2017 14:27:29 +0200 Subject: [PATCH] Extract config common across CIDR allocators --- pkg/controller/node/ipam/cidr_allocator.go | 12 ++++++++++++ pkg/controller/node/ipam/range_allocator.go | 13 ++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pkg/controller/node/ipam/cidr_allocator.go b/pkg/controller/node/ipam/cidr_allocator.go index ce1d20b9e10..9acfeadb031 100644 --- a/pkg/controller/node/ipam/cidr_allocator.go +++ b/pkg/controller/node/ipam/cidr_allocator.go @@ -54,9 +54,21 @@ const ( // IPAMFromCloudAllocatorType uses the ipam controller sync'ing the node // CIDR range allocations from the cloud to the cluster. IPAMFromCloudAllocatorType = "IPAMFromCloud" +) +// TODO: figure out the good setting for those constants. +const ( // The amount of time the nodecontroller polls on the list nodes endpoint. apiserverStartupGracePeriod = 10 * time.Minute + + // The no. of NodeSpec updates NC can process concurrently. + cidrUpdateWorkers = 10 + + // The max no. of NodeSpec updates that can be enqueued. + cidrUpdateQueueSize = 5000 + + // cidrUpdateRetries is the no. of times a NodeSpec update will be retried before dropping it. + cidrUpdateRetries = 10 ) // CIDRAllocator is an interface implemented by things that know how diff --git a/pkg/controller/node/ipam/range_allocator.go b/pkg/controller/node/ipam/range_allocator.go index 24a7b77ae48..338d2020e0a 100644 --- a/pkg/controller/node/ipam/range_allocator.go +++ b/pkg/controller/node/ipam/range_allocator.go @@ -39,15 +39,6 @@ import ( "k8s.io/kubernetes/pkg/controller/node/util" ) -// TODO: figure out the good setting for those constants. -const ( - // controls how many NodeSpec updates NC can process concurrently. - cidrUpdateWorkers = 10 - cidrUpdateQueueSize = 5000 - // podCIDRUpdateRetry controls the number of retries of writing Node.Spec.PodCIDR update. - podCIDRUpdateRetry = 5 -) - type rangeAllocator struct { client clientset.Interface cidrs *cidrset.CidrSet @@ -227,7 +218,7 @@ func (r *rangeAllocator) updateCIDRAllocation(data nodeAndCIDR) error { var err error var node *v1.Node defer r.removeNodeFromProcessing(data.nodeName) - for rep := 0; rep < podCIDRUpdateRetry; rep++ { + for rep := 0; rep < cidrUpdateRetries; rep++ { // TODO: change it to using PATCH instead of full Node updates. node, err = r.client.Core().Nodes().Get(data.nodeName, metav1.GetOptions{}) if err != nil { @@ -247,7 +238,7 @@ func (r *rangeAllocator) updateCIDRAllocation(data nodeAndCIDR) error { } node.Spec.PodCIDR = data.cidr.String() if _, err := r.client.Core().Nodes().Update(node); err != nil { - glog.Errorf("Failed while updating Node.Spec.PodCIDR (%d retries left): %v", podCIDRUpdateRetry-rep-1, err) + glog.Errorf("Failed while updating Node.Spec.PodCIDR (%d retries left): %v", cidrUpdateRetries-rep-1, err) } else { break }