Merge pull request #579 from aledbf/avoid-removing-status
Detect if the ingress controller is running with multiple replicas
This commit is contained in:
commit
6ed6475e87
1 changed files with 16 additions and 0 deletions
|
@ -111,6 +111,11 @@ func (s statusSync) Shutdown() {
|
|||
return
|
||||
}
|
||||
|
||||
if s.isRunningMultiplePods() {
|
||||
glog.V(2).Infof("skipping Ingress status update (multiple pods running - another one will be elected as master)")
|
||||
return
|
||||
}
|
||||
|
||||
glog.Infof("removing address from ingress status (%v)", addrs)
|
||||
s.updateStatus([]api_v1.LoadBalancerIngress{})
|
||||
}
|
||||
|
@ -232,6 +237,17 @@ func (s *statusSync) runningAddresess() ([]string, error) {
|
|||
return addrs, nil
|
||||
}
|
||||
|
||||
func (s *statusSync) isRunningMultiplePods() bool {
|
||||
pods, err := s.Client.Core().Pods(s.pod.Namespace).List(meta_v1.ListOptions{
|
||||
LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),
|
||||
})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return len(pods.Items) > 1
|
||||
}
|
||||
|
||||
// sliceToStatus converts a slice of IP and/or hostnames to LoadBalancerIngress
|
||||
func sliceToStatus(endpoints []string) []api_v1.LoadBalancerIngress {
|
||||
lbi := []api_v1.LoadBalancerIngress{}
|
||||
|
|
Loading…
Reference in a new issue