Skip to content

Commit

Permalink
core/services/pipeline: hide deadline from monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Jun 4, 2024
1 parent d202837 commit 2cf506b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/services/pipeline/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,16 @@ func init() {
// results, even after context cancellation.
func overtimeContext(ctx context.Context) (context.Context, context.CancelFunc) {
if d, ok := ctx.Deadline(); ok {
// extend deadline
return context.WithDeadline(context.WithoutCancel(ctx), d.Add(overtime))
}
// remove cancellation
// We do not use context.WithDeadline/Timeout in order to prevent the monitor hook from logging noisily, since
// we expect and want these operations to use most of their allotted time.
// TODO replace with custom thresholds: https://smartcontract-it.atlassian.net/browse/BCF-3252
var cancel context.CancelFunc
ctx, cancel = context.WithCancel(context.WithoutCancel(ctx))
t := time.AfterFunc(time.Until(d.Add(overtime)), cancel)
stop := context.AfterFunc(ctx, func() { t.Stop() })
return ctx, func() { cancel(); stop() }
}
// do not propagate cancellation in any case
return context.WithoutCancel(ctx), func() {}
}

Expand Down

0 comments on commit 2cf506b

Please sign in to comment.