Don't sort IngressStatus from each Goroutine(update for each ingress)

Currently ingress controller try to update status for each ingress
resource in a parallel by using Goroutine, and inside this Goroutine we
are trying to sort same IngressStatus reference which is shared between
all Goroutine, this will break the original refrence if some Goroutine
tried to sort exact same time.
So we should have done sorting before passing reference to each
Goroutine to prevent from breaking original reference

fixes: #3269
This commit is contained in:
Yuki Nishiwaki 2018-10-19 10:57:01 +08:00
parent 5039e770bd
commit 4845daeb35

View file

@ -326,6 +326,7 @@ func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
defer p.Close() defer p.Close()
batch := p.Batch() batch := p.Batch()
sort.SliceStable(newIngressPoint, lessLoadBalancerIngress(newIngressPoint))
for _, ing := range ings { for _, ing := range ings {
batch.Queue(runUpdate(ing, newIngressPoint, s.Client)) batch.Queue(runUpdate(ing, newIngressPoint, s.Client))
@ -342,8 +343,6 @@ func runUpdate(ing *extensions.Ingress, status []apiv1.LoadBalancerIngress,
return nil, nil return nil, nil
} }
sort.SliceStable(status, lessLoadBalancerIngress(status))
curIPs := ing.Status.LoadBalancer.Ingress curIPs := ing.Status.LoadBalancer.Ingress
sort.SliceStable(curIPs, lessLoadBalancerIngress(curIPs)) sort.SliceStable(curIPs, lessLoadBalancerIngress(curIPs))