Skip to content

Commit

Permalink
Fix Envoy service status watching
Browse files Browse the repository at this point in the history
We all missed in #2583 that not all informers handle Unstructured objects; wrap the service status informer in the dynamicHandler to ensure that no Unstructured objects make it through.

Service status watching was broken before this, as it didn't handle Unstructured.

Signed-off-by: Nick Young <[email protected]>
  • Loading branch information
Nick Young committed Jun 19, 2020
1 parent 8067ec9 commit 3db40fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,16 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {

// step 12. register an informer to watch envoy's service if we haven't been given static details.
if ctx.IngressStatusAddress == "" {
ssw := &k8s.ServiceStatusLoadBalancerWatcher{
ServiceName: ctx.EnvoyServiceName,
LBStatus: lbsw.lbStatus,
dynamicServiceHandler := &k8s.DynamicClientHandler{
Next: &k8s.ServiceStatusLoadBalancerWatcher{
ServiceName: ctx.EnvoyServiceName,
LBStatus: lbsw.lbStatus,
},
Converter: converter,
Logger: log.WithField("context", "serviceStatusLoadBalancerWatcher"),
}
factory := clients.NewInformerFactoryForNamespace(ctx.EnvoyServiceNamespace)
informerSyncList.InformOnResources(factory, ssw, k8s.ServicesResources()...)
informerSyncList.InformOnResources(factory, dynamicServiceHandler, k8s.ServicesResources()...)
g.Add(startInformer(factory, log.WithField("context", "serviceStatusLoadBalancerWatcher")))
log.WithField("envoy-service-name", ctx.EnvoyServiceName).
WithField("envoy-service-namespace", ctx.EnvoyServiceNamespace).
Expand Down
3 changes: 2 additions & 1 deletion internal/k8s/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type InformerSyncList struct {
}

// InformOnResources creates informers for each of the given resources and registers their sync callbacks.
func (sl *InformerSyncList) InformOnResources(f InformerFactory, handler cache.ResourceEventHandler, resources ...schema.GroupVersionResource) {
func (sl *InformerSyncList) InformOnResources(f InformerFactory, handler *DynamicClientHandler, resources ...schema.GroupVersionResource) {

for _, r := range resources {
informer := f.ForResource(r).Informer()
informer.AddEventHandler(handler)
Expand Down

0 comments on commit 3db40fd

Please sign in to comment.