Skip to content

Commit

Permalink
fix: handle panic from type assertion (#11040)
Browse files Browse the repository at this point in the history
Signed-off-by: Julie Vogelmani <julie_vogelman@intuit.com>
  • Loading branch information
juliev0 committed May 8, 2023
1 parent 5294f35 commit d4549b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions workflow/controller/controller.go
Expand Up @@ -615,7 +615,10 @@ func (wfc *WorkflowController) deleteOffloadedNodesForWorkflow(uid string, versi
case 0:
log.WithField("uid", uid).Info("Workflow missing, probably deleted")
case 1:
un := workflows[0].(*unstructured.Unstructured)
un, ok := workflows[0].(*unstructured.Unstructured)
if !ok {
return fmt.Errorf("object %+v is not an unstructured", workflows[0])
}
wf, err = util.FromUnstructured(un)
if err != nil {
return err
Expand Down Expand Up @@ -827,7 +830,12 @@ func (wfc *WorkflowController) addWorkflowInformerHandlers(ctx context.Context)
wfc.wfInformer.AddEventHandler(
cache.FilteringResourceEventHandler{
FilterFunc: func(obj interface{}) bool {
return reconciliationNeeded(obj.(*unstructured.Unstructured))
un, ok := obj.(*unstructured.Unstructured)
if !ok {
log.Warnf("Workflow FilterFunc: '%v' is not an unstructured", obj)
return false
}
return reconciliationNeeded(un)
},
Handler: cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
Expand Down

0 comments on commit d4549b3

Please sign in to comment.