Skip to content

Commit

Permalink
IG-21104 - verify ctx cancelled to avoid sending on closed channel (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored Sep 7, 2022
1 parent c6dccca commit 1d80c06
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/dlx/resourcestarter.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ func (r *ResourceStarter) waitResourceReadiness(ctx context.Context,
resourceReadyChannel chan error) {

err := r.scaler.SetScaleCtx(ctx, []scaler_types.Resource{resource}, 1)

// callee decided to cancel, the resourceReadyChannel is already closed,
// so we can just return without sending anything
if errors.RootCause(ctx.Err()) == context.Canceled || ctx.Err() == context.Canceled {
r.logger.WarnWithCtx(ctx,
"Wait resource readiness canceled",
"resourceName", resource.Name)
return
}
resourceReadyChannel <- err
}

Expand Down

0 comments on commit 1d80c06

Please sign in to comment.