Skip to content

Commit

Permalink
prevent a panic when we have old CRDs installed in the cluster that a…
Browse files Browse the repository at this point in the history
…re labled Source but are not correctly installed. (#2823)
  • Loading branch information
n3wscott authored Mar 23, 2020
1 parent 34c999b commit f2224af
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/reconciler/source/crd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ func (r *Reconciler) reconcileController(ctx context.Context, crd *v1beta1.Custo

// Source Duck controller constructor
sdc := duck.NewController(crd.Name, *gvr, *gvk)
if sdc == nil {
logging.FromContext(ctx).Error("Source Duck Controller is nil.", zap.String("GVR", gvr.String()), zap.String("GVK", gvk.String()))
return nil
}

// Source Duck controller context
sdctx, cancel := context.WithCancel(r.ogctx)
// Source Duck controller instantiation
Expand All @@ -205,8 +210,10 @@ func (r *Reconciler) reconcileController(ctx context.Context, crd *v1beta1.Custo

logging.FromContext(ctx).Info("Starting Source Duck Controller", zap.String("GVR", gvr.String()), zap.String("GVK", gvk.String()))
go func(c *controller.Impl) {
if err := c.Run(controller.DefaultThreadsPerController, sdctx.Done()); err != nil {
logging.FromContext(ctx).Error("Unable to start Source Duck Controller", zap.String("GVR", gvr.String()), zap.String("GVK", gvk.String()))
if c != nil {
if err := c.Run(controller.DefaultThreadsPerController, sdctx.Done()); err != nil {
logging.FromContext(ctx).Error("Unable to start Source Duck Controller", zap.String("GVR", gvr.String()), zap.String("GVK", gvk.String()))
}
}
}(rc.controller)
return nil
Expand Down

0 comments on commit f2224af

Please sign in to comment.