Avoid sync Ingress updates

This commit is contained in:
Manuel de Brito Fontes 2016-03-31 14:59:28 -03:00
parent 2632fe566b
commit 60e2e5f9ad
8 changed files with 42 additions and 23 deletions

View file

@ -68,6 +68,7 @@ type loadBalancerController struct {
recorder record.EventRecorder
syncQueue *taskQueue
ingQueue *taskQueue
// stopLock is used to enforce only a single call to Stop is active.
// Needed because we allow stopping through an http endpoint and
@ -98,12 +99,13 @@ func newLoadBalancerController(kubeClient *client.Client, resyncPeriod time.Dura
}
lbc.syncQueue = NewTaskQueue(lbc.sync)
lbc.ingQueue = NewTaskQueue(lbc.syncIngress)
ingEventHandler := framework.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
addIng := obj.(*extensions.Ingress)
lbc.recorder.Eventf(addIng, api.EventTypeNormal, "CREATE", fmt.Sprintf("%s/%s", addIng.Namespace, addIng.Name))
lbc.updateIngressStatus(addIng)
lbc.ingQueue.enqueue(obj)
lbc.syncQueue.enqueue(obj)
},
DeleteFunc: func(obj interface{}) {
@ -115,7 +117,7 @@ func newLoadBalancerController(kubeClient *client.Client, resyncPeriod time.Dura
if !reflect.DeepEqual(old, cur) {
upIng := cur.(*extensions.Ingress)
lbc.recorder.Eventf(upIng, api.EventTypeNormal, "UPDATE", fmt.Sprintf("%s/%s", upIng.Namespace, upIng.Name))
lbc.updateIngressStatus(upIng)
lbc.ingQueue.enqueue(cur)
lbc.syncQueue.enqueue(cur)
}
},
@ -237,8 +239,23 @@ func (lbc *loadBalancerController) sync(key string) {
})
}
func (lbc *loadBalancerController) updateIngressStatus(ing *extensions.Ingress) {
func (lbc *loadBalancerController) syncIngress(key string) {
if !lbc.controllersInSync() {
lbc.ingQueue.requeue(key, fmt.Errorf("deferring sync till endpoints controller has synced"))
return
}
obj, ingExists, err := lbc.ingLister.Store.GetByKey(key)
if err != nil {
lbc.ingQueue.requeue(key, err)
return
}
if ingExists {
ing := obj.(*extensions.Ingress)
ingClient := lbc.client.Extensions().Ingress(ing.Namespace)
currIng, err := ingClient.Get(ing.Name)
if err != nil {
glog.Errorf("unexpected error searching Ingress %v/%v: %v", ing.Namespace, ing.Name, err)
@ -258,6 +275,7 @@ func (lbc *loadBalancerController) updateIngressStatus(ing *extensions.Ingress)
lbc.recorder.Eventf(currIng, api.EventTypeNormal, "CREATE", "ip: %v", lbc.lbInfo.Address)
}
}
}
func (lbc *loadBalancerController) isStatusIPDefined(lbings []api.LoadBalancerIngress) bool {
@ -701,6 +719,7 @@ func (lbc *loadBalancerController) Run() {
go lbc.svcController.Run(lbc.stopCh)
go lbc.syncQueue.run(time.Second, lbc.stopCh)
go lbc.ingQueue.run(time.Second, lbc.stopCh)
<-lbc.stopCh
glog.Infof("shutting down NGINX loadbalancer controller")

View file

@ -15,7 +15,7 @@ spec:
name: nginx-ingress-lb
spec:
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.4
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe:

View file

@ -9,7 +9,7 @@ spec:
name: nginx-ingress-lb
spec:
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.4
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe:

View file

@ -15,7 +15,7 @@ spec:
name: nginx-ingress-lb
spec:
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.4
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe:

View file

@ -20,7 +20,7 @@ spec:
secret:
secretName: dhparam-example
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.4
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe:

View file

@ -15,7 +15,7 @@ spec:
name: nginx-ingress-lb
spec:
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.4
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe:

View file

@ -15,7 +15,7 @@ spec:
name: nginx-ingress-lb
spec:
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.4
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe:

View file

@ -15,7 +15,7 @@ spec:
name: nginx-ingress-lb
spec:
containers:
- image: aledbf/nginx-third-party:0.9
- image: gcr.io/google_containers/nginx-ingress-controller:0.5
name: nginx-ingress-lb
imagePullPolicy: Always
livenessProbe: