From 3e52ea8081abc13398de6283c31056cd6aecf6b4 Mon Sep 17 00:00:00 2001 From: Zihong Zheng Date: Wed, 3 Apr 2019 14:27:04 -0700 Subject: [PATCH] Rename createLoadBalancerIfNeeded() to syncLoadBalancerIfNeeded() to reduce confusion --- pkg/controller/service/service_controller.go | 6 +++--- pkg/controller/service/service_controller_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/controller/service/service_controller.go b/pkg/controller/service/service_controller.go index 667611bc5b1..4da3f8027be 100644 --- a/pkg/controller/service/service_controller.go +++ b/pkg/controller/service/service_controller.go @@ -248,7 +248,7 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s } // cache the service, we need the info for service deletion cachedService.state = service - err := s.createLoadBalancerIfNeeded(key, service) + err := s.syncLoadBalancerIfNeeded(key, service) if err != nil { eventType := "CreatingLoadBalancerFailed" message := "Error creating load balancer (will retry): " @@ -269,10 +269,10 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s return nil } -// createLoadBalancerIfNeeded ensures that service's status is synced up with loadbalancer +// syncLoadBalancerIfNeeded ensures that service's status is synced up with loadbalancer // i.e. creates loadbalancer for service if requested and deletes loadbalancer if the service // doesn't want a loadbalancer no more. Returns whatever error occurred. -func (s *ServiceController) createLoadBalancerIfNeeded(key string, service *v1.Service) error { +func (s *ServiceController) syncLoadBalancerIfNeeded(key string, service *v1.Service) error { // Note: It is safe to just call EnsureLoadBalancer. But, on some clouds that requires a delete & create, // which may involve service interruption. Also, we would like user-friendly events. diff --git a/pkg/controller/service/service_controller_test.go b/pkg/controller/service/service_controller_test.go index c1563b8f921..78d9e783bbd 100644 --- a/pkg/controller/service/service_controller_test.go +++ b/pkg/controller/service/service_controller_test.go @@ -151,7 +151,7 @@ func TestCreateExternalLoadBalancer(t *testing.T) { for _, item := range table { controller, cloud, client := newController() - err := controller.createLoadBalancerIfNeeded("foo/bar", item.service) + err := controller.syncLoadBalancerIfNeeded("foo/bar", item.service) if !item.expectErr && err != nil { t.Errorf("unexpected error: %v", err) } else if item.expectErr && err == nil {