Skip to content

Commit

Permalink
Update backendconfig event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
skmatti authored and Satish Matti committed Mar 11, 2020
1 parent 3667931 commit 274e02e
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,40 @@ func NewLoadBalancerController(
// BackendConfig event handlers.
ctx.BackendConfigInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
beConfig := obj.(*backendconfigv1beta1.BackendConfig)
beConfig, ok := obj.(*backendconfigv1beta1.BackendConfig)
if !ok {
klog.Errorf("Cannot cast obj to BackendConfig (obj type is %T)", obj)
return
}
ings := operator.Ingresses(ctx.Ingresses().List()).ReferencesBackendConfig(beConfig, operator.Services(ctx.Services().List())).AsList()
lbc.ingQueue.Enqueue(convert(ings)...)
},
UpdateFunc: func(old, cur interface{}) {
if !reflect.DeepEqual(old, cur) {
beConfig := cur.(*backendconfigv1beta1.BackendConfig)
beConfig, ok := cur.(*backendconfigv1beta1.BackendConfig)
if !ok {
klog.Errorf("Cannot cast obj to BackendConfig (obj type is %T)", cur)
return
}
ings := operator.Ingresses(ctx.Ingresses().List()).ReferencesBackendConfig(beConfig, operator.Services(ctx.Services().List())).AsList()
lbc.ingQueue.Enqueue(convert(ings)...)
}
},
DeleteFunc: func(obj interface{}) {
beConfig := obj.(*backendconfigv1beta1.BackendConfig)
beConfig, ok := obj.(*backendconfigv1beta1.BackendConfig)
if !ok {
klog.V(3).Infof("Cannot cast obj to BackendConfig (obj type is %T), casting into DeletedFinalStateUnknown", obj)
var tombstone cache.DeletedFinalStateUnknown
tombstone, ok = obj.(cache.DeletedFinalStateUnknown)
if !ok {
klog.Errorf("Cannot cast obj to DeletedFinalStateUnknown (obj type is %T)", obj)
return
}
if beConfig, ok = tombstone.Obj.(*backendconfigv1beta1.BackendConfig); !ok {
klog.Errorf("Cannot cast DeletedFinalStateUnknown.obj to BackendConfig (obj type is %T)", tombstone.Obj)
return
}
}
ings := operator.Ingresses(ctx.Ingresses().List()).ReferencesBackendConfig(beConfig, operator.Services(ctx.Services().List())).AsList()
lbc.ingQueue.Enqueue(convert(ings)...)
},
Expand Down

0 comments on commit 274e02e

Please sign in to comment.