add dns provider initialzation

This commit is contained in:
mfanjie 2016-06-12 17:52:24 +08:00
parent 6e5faf59b2
commit 29cc7c009c

View File

@ -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 {