code: func (s *ServiceController) lockedUpdateLoadBalancerHosts(service *v1.Service, hosts []*v1.Node) error {
  	if !wantsLoadBalancer(service) {
  		return nil
  	}
  
  	// This operation doesn't normally take very long (and happens pretty often), so we only record the final event
  	err := s.balancer.UpdateLoadBalancer(context.TODO(), s.clusterName, service, hosts)
  	if err == nil {
  		// If there are no available nodes for LoadBalancer service, make a EventTypeWarning event for it.
  		if len(hosts) == 0 {
  			s.eventRecorder.Eventf(service, v1.EventTypeWarning, "UnAvailableLoadBalancer", "There are no available nodes for LoadBalancer service %s/%s", service.Namespace, service.Name)
  		} else {
  			s.eventRecorder.Event(service, v1.EventTypeNormal, "UpdatedLoadBalancer", "Updated load balancer with new hosts")
  		}
  		return nil
  	}
  
  	// It's only an actual error if the load balancer still exists.
  	if _, exists, err := s.balancer.GetLoadBalancer(context.TODO(), s.clusterName, service); err != nil {
  		klog.Errorf("External error while checking if load balancer %q exists: name, %v", s.balancer.GetLoadBalancerName(context.TODO(), s.clusterName, service), err)
  	} else if !exists {
  		return nil
  	}
  
  	s.eventRecorder.Eventf(service, v1.EventTypeWarning, "LoadBalancerUpdateFailed", "Error updating load balancer with new hosts %v: %v", nodeNames(hosts), err)
  	return err
  }
docs: // Updates the load balancer of a service, assuming we hold the mutex
  // associated with the service.