From dcd69685fd9a71c23eaad4342844d2f5b0c7472d Mon Sep 17 00:00:00 2001 From: Aleksandra Malinowska Date: Tue, 21 Aug 2018 11:27:12 +0200 Subject: [PATCH] Fix fetching resource limits on GKE --- .../gke/autoscaling_gke_client_v1beta1.go | 1 + cluster-autoscaler/cloudprovider/gke/gke_manager.go | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/gke/autoscaling_gke_client_v1beta1.go b/cluster-autoscaler/cloudprovider/gke/autoscaling_gke_client_v1beta1.go index 815fda295df8..d4e0195fdafb 100644 --- a/cluster-autoscaler/cloudprovider/gke/autoscaling_gke_client_v1beta1.go +++ b/cluster-autoscaler/cloudprovider/gke/autoscaling_gke_client_v1beta1.go @@ -107,6 +107,7 @@ func (m *autoscalingGkeClientV1beta1) FetchResourceLimits() (*cloudprovider.Reso return nil, err } if cluster.Autoscaling == nil { + glog.Warningf("FetchResourceLimits called without autoscaling limits set") return nil, nil } diff --git a/cluster-autoscaler/cloudprovider/gke/gke_manager.go b/cluster-autoscaler/cloudprovider/gke/gke_manager.go index e855d11d8d52..d7fb95d12158 100644 --- a/cluster-autoscaler/cloudprovider/gke/gke_manager.go +++ b/cluster-autoscaler/cloudprovider/gke/gke_manager.go @@ -509,9 +509,13 @@ func (m *gkeManagerImpl) fetchResourceLimiter() error { if err != nil { return err } - - glog.V(2).Infof("Refreshed resource limits: %s", resourceLimiter.String()) - m.cache.SetResourceLimiter(resourceLimiter) + if resourceLimiter != nil { + glog.V(2).Infof("Refreshed resource limits: %s", resourceLimiter.String()) + m.cache.SetResourceLimiter(resourceLimiter) + } else { + oldLimits, _ := m.cache.GetResourceLimiter() + glog.Errorf("Resource limits should always be defined in NAP mode, but they appear to be empty. Using possibly outdated limits: %v", oldLimits.String()) + } } return nil }