func (sr *ServiceRegistryStorage) Delete(id string) (<-chan interface{}, error) {
	svc, err := sr.Get(id)
	if err != nil {
		return nil, err
	}
	if svc.(*api.Service).CreateExternalLoadBalancer {
		var balancer cloudprovider.TCPLoadBalancer
		var ok bool
		if sr.cloud != nil {
			balancer, ok = sr.cloud.TCPLoadBalancer()
		}
		if ok && balancer != nil {
			err = balancer.DeleteTCPLoadBalancer(id, "us-central1")
			if err != nil {
				return nil, err
			}
		}
	}
	return apiserver.MakeAsync(func() interface{} { return apiserver.Status{Success: true} }), sr.registry.DeleteService(id)
}
Beispiel #2
0
func (sr *ServiceRegistryStorage) Delete(id string) error {
	svc, err := sr.Get(id)
	if err != nil {
		return err
	}
	if svc.(*api.Service).CreateExternalLoadBalancer {
		var balancer cloudprovider.TCPLoadBalancer
		if sr.cloud != nil {
			balancer, err = sr.cloud.TCPLoadBalancer()
			if err != nil {
				return err
			}
		}
		if balancer != nil {
			err = balancer.DeleteTCPLoadBalancer(id, "us-central1")
			if err != nil {
				return err
			}
		}
	}
	return sr.registry.DeleteService(id)
}