Skip to content

Commit

Permalink
Merge pull request #579 from aledbf/avoid-removing-status
Browse files Browse the repository at this point in the history
Detect if the ingress controller is running with multiple replicas
  • Loading branch information
aledbf authored Apr 9, 2017
2 parents 7f6aaf0 + 5bd729a commit 6ed6475
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/pkg/ingress/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}
Expand Down Expand Up @@ -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{}
Expand Down

0 comments on commit 6ed6475

Please sign in to comment.