Commit 3e52ea80 authored by Zihong Zheng's avatar Zihong Zheng

Rename createLoadBalancerIfNeeded() to syncLoadBalancerIfNeeded() to reduce confusion

parent 66329fce
...@@ -248,7 +248,7 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s ...@@ -248,7 +248,7 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s
} }
// cache the service, we need the info for service deletion // cache the service, we need the info for service deletion
cachedService.state = service cachedService.state = service
err := s.createLoadBalancerIfNeeded(key, service) err := s.syncLoadBalancerIfNeeded(key, service)
if err != nil { if err != nil {
eventType := "CreatingLoadBalancerFailed" eventType := "CreatingLoadBalancerFailed"
message := "Error creating load balancer (will retry): " message := "Error creating load balancer (will retry): "
...@@ -269,10 +269,10 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s ...@@ -269,10 +269,10 @@ func (s *ServiceController) processServiceUpdate(cachedService *cachedService, s
return nil 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 // 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. // 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, // 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. // which may involve service interruption. Also, we would like user-friendly events.
......
...@@ -151,7 +151,7 @@ func TestCreateExternalLoadBalancer(t *testing.T) { ...@@ -151,7 +151,7 @@ func TestCreateExternalLoadBalancer(t *testing.T) {
for _, item := range table { for _, item := range table {
controller, cloud, client := newController() controller, cloud, client := newController()
err := controller.createLoadBalancerIfNeeded("foo/bar", item.service) err := controller.syncLoadBalancerIfNeeded("foo/bar", item.service)
if !item.expectErr && err != nil { if !item.expectErr && err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} else if item.expectErr && err == nil { } else if item.expectErr && err == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment