mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-10-05 15:01:04 +02:00
stop processing service and endpoints updates if network service (#939)
controller has already shutdown fixes panic seen in #937
This commit is contained in:
parent
b7aad2e086
commit
b6acd0a152
@ -366,6 +366,9 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-stopCh:
|
case <-stopCh:
|
||||||
|
nsc.mu.Lock()
|
||||||
|
nsc.readyForUpdates = false
|
||||||
|
nsc.mu.Unlock()
|
||||||
glog.Info("Shutting down network services controller")
|
glog.Info("Shutting down network services controller")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -790,13 +793,13 @@ func (nsc *NetworkServicesController) OnEndpointsUpdate(ep *api.Endpoints) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(1).Infof("Received update to endpoint: %s/%s from watch API", ep.Namespace, ep.Name)
|
|
||||||
if !nsc.readyForUpdates {
|
|
||||||
glog.V(3).Infof("Skipping update to endpoint: %s/%s, controller still performing bootup full-sync", ep.Namespace, ep.Name)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nsc.mu.Lock()
|
nsc.mu.Lock()
|
||||||
defer nsc.mu.Unlock()
|
defer nsc.mu.Unlock()
|
||||||
|
glog.V(1).Infof("Received update to endpoint: %s/%s from watch API", ep.Namespace, ep.Name)
|
||||||
|
if !nsc.readyForUpdates {
|
||||||
|
glog.V(3).Infof("Skipping update to endpoint: %s/%s as controller is not ready to process service and endpoints updates", ep.Namespace, ep.Name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// build new service and endpoints map to reflect the change
|
// build new service and endpoints map to reflect the change
|
||||||
newServiceMap := nsc.buildServicesInfo()
|
newServiceMap := nsc.buildServicesInfo()
|
||||||
@ -814,14 +817,16 @@ func (nsc *NetworkServicesController) OnEndpointsUpdate(ep *api.Endpoints) {
|
|||||||
|
|
||||||
// OnServiceUpdate handle change in service update from the API server
|
// OnServiceUpdate handle change in service update from the API server
|
||||||
func (nsc *NetworkServicesController) OnServiceUpdate(svc *api.Service) {
|
func (nsc *NetworkServicesController) OnServiceUpdate(svc *api.Service) {
|
||||||
glog.V(1).Infof("Received update to service: %s/%s from watch API", svc.Namespace, svc.Name)
|
|
||||||
if !nsc.readyForUpdates {
|
|
||||||
glog.V(3).Infof("Skipping update to service: %s/%s, controller still performing bootup full-sync", svc.Namespace, svc.Name)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nsc.mu.Lock()
|
nsc.mu.Lock()
|
||||||
defer nsc.mu.Unlock()
|
defer nsc.mu.Unlock()
|
||||||
|
|
||||||
|
glog.V(1).Infof("Received update to service: %s/%s from watch API", svc.Namespace, svc.Name)
|
||||||
|
if !nsc.readyForUpdates {
|
||||||
|
glog.V(3).Infof("Skipping update to service: %s/%s as controller is not ready to process service and endpoints updates", svc.Namespace, svc.Name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// build new service and endpoints map to reflect the change
|
// build new service and endpoints map to reflect the change
|
||||||
newServiceMap := nsc.buildServicesInfo()
|
newServiceMap := nsc.buildServicesInfo()
|
||||||
newEndpointsMap := nsc.buildEndpointsInfo()
|
newEndpointsMap := nsc.buildEndpointsInfo()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user