Skip to content

Commit

Permalink
remove some timeouts from logGathererArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettj12 committed Aug 1, 2023
1 parent 2a420ef commit f7bd5e6
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions internals/overlord/logstate/gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,8 @@ type logGatherer struct {
// logGathererArgs allows overriding the newLogClient method and time values
// in testing.
type logGathererArgs struct {
tickPeriod time.Duration

// timeout values for teardown
timeoutCurrentFlush time.Duration
timeoutPullers time.Duration
timeoutMainLoop time.Duration
timeoutFinalFlush time.Duration

tickPeriod time.Duration
timeoutFinalFlush time.Duration
// method to get a new client
newClient func(*plan.LogTarget) (logClient, error)
}
Expand Down Expand Up @@ -118,15 +112,6 @@ func fillDefaultArgs(args logGathererArgs) logGathererArgs {
if args.tickPeriod == 0 {
args.tickPeriod = tickPeriod
}
if args.timeoutCurrentFlush == 0 {
args.timeoutCurrentFlush = timeoutCurrentFlush
}
if args.timeoutPullers == 0 {
args.timeoutPullers = timeoutPullers
}
if args.timeoutMainLoop == 0 {
args.timeoutMainLoop = timeoutMainLoop
}
if args.timeoutFinalFlush == 0 {
args.timeoutFinalFlush = timeoutFinalFlush
}
Expand Down Expand Up @@ -215,18 +200,18 @@ mainLoop:
// - Flush out any final logs buffered in the client.
func (g *logGatherer) stop() {
// Wait up to timeoutCurrentFlush for the current flush to complete (if any)
time.AfterFunc(g.timeoutCurrentFlush, g.clientCancel)
time.AfterFunc(timeoutCurrentFlush, g.clientCancel)

// Wait up to timeoutPullers for the pullers to pull the final logs from the
// iterator and send to the main loop.
time.AfterFunc(g.timeoutPullers, g.pullers.KillAll)
time.AfterFunc(timeoutPullers, g.pullers.KillAll)

// Kill the main loop once either:
// - all the pullers are done
// - timeoutMainLoop has passed
select {
case <-g.pullers.Done():
case <-time.After(g.timeoutMainLoop):
case <-time.After(timeoutMainLoop):
}

_ = g.tomb.Killf("gatherer stopped")
Expand Down

0 comments on commit f7bd5e6

Please sign in to comment.