diff --git a/pkg/node/manager/events.go b/pkg/node/manager/events.go index 7b92b77b82..2524c17e4d 100644 --- a/pkg/node/manager/events.go +++ b/pkg/node/manager/events.go @@ -97,12 +97,16 @@ func (e *NodeEventEmitter) EmitEvent(ctx context.Context, info models.NodeInfo, completedChan := make(chan struct{}) wg := sync.WaitGroup{} + newCtx, cancel := context.WithCancel(ctx) + defer cancel() + for _, hlr := range e.callbacks { wg.Add(1) - go func(handler NodeEventHandler) { + go func(handler NodeEventHandler, ctx context.Context) { + defer wg.Done() + handler.HandleNodeEvent(ctx, info, event) - wg.Done() - }(hlr) + }(hlr, newCtx) } // Wait for the waitgroup and then close the channel to signal completion. This allows