diff --git a/federation/pkg/federation-controller/service/servicecontroller.go b/federation/pkg/federation-controller/service/servicecontroller.go index 657d43b5155..5a097bb14b4 100644 --- a/federation/pkg/federation-controller/service/servicecontroller.go +++ b/federation/pkg/federation-controller/service/servicecontroller.go @@ -227,6 +227,9 @@ func (s *ServiceController) enqueueService(obj interface{}) { // It's an error to call Run() more than once for a given ServiceController // object. func (s *ServiceController) Run(workers int, stopCh <-chan struct{}) error { + if err := s.init(); err != nil { + return err + } defer runtime.HandleCrash() go s.serviceController.Run(stopCh) go s.clusterController.Run(stopCh) @@ -242,6 +245,18 @@ func (s *ServiceController) Run(workers int, stopCh <-chan struct{}) error { return nil } +func (s *ServiceController) init() error { + if s.dns == nil { + return fmt.Errorf("ServiceController should not be run without a dnsprovider.") + } + zones, ok := s.dns.Zones() + if !ok { + return fmt.Errorf("the dns provider does not support zone enumeration, which is required for creating dns records.") + } + s.dnsZones = zones + return nil +} + // fedServiceWorker runs a worker thread that just dequeues items, processes them, and marks them done. // It enforces that the syncService is never invoked concurrently with the same key. func (s *ServiceController) fedServiceWorker() { @@ -317,6 +332,8 @@ func (s *ServiceController) deleteFederationService(cachedService *cachedService err := s.deleteClusterService(clusterName, cachedService, cluster.clientset) if err != nil { hasErr = true + } else if err := s.ensureDnsRecords(clusterName, cachedService); err != nil { + hasErr = true } } if hasErr {