Skip to content

Commit

Permalink
Merge branch 'master' into remove-check
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot[bot] authored May 11, 2024
2 parents 2abe935 + 78cb081 commit a0918a3
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 62 deletions.
7 changes: 7 additions & 0 deletions client/resource_group/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ func WithWaitRetryTimes(times int) ResourceControlCreateOption {
}
}

// WithDegradedModeWaitDuration is the option to set the wait duration for degraded mode.
func WithDegradedModeWaitDuration(d time.Duration) ResourceControlCreateOption {
return func(controller *ResourceGroupsController) {
controller.ruConfig.DegradedModeWaitDuration = d
}
}

var _ ResourceGroupKVInterceptor = (*ResourceGroupsController)(nil)

// ResourceGroupsController implements ResourceGroupKVInterceptor.
Expand Down
25 changes: 15 additions & 10 deletions client/resource_group/controller/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ func (lim *Limiter) AvailableTokens(now time.Time) float64 {
return tokens
}

const reserveWarnLogInterval = 10 * time.Millisecond

// reserveN is a helper method for Reserve.
// maxFutureReserve specifies the maximum reservation wait duration allowed.
// reserveN returns Reservation, not *Reservation.
Expand Down Expand Up @@ -376,16 +378,19 @@ func (lim *Limiter) reserveN(now time.Time, n float64, maxFutureReserve time.Dur
lim.tokens = tokens
lim.maybeNotify()
} else {
log.Warn("[resource group controller] cannot reserve enough tokens",
zap.Duration("need-wait-duration", waitDuration),
zap.Duration("max-wait-duration", maxFutureReserve),
zap.Float64("current-ltb-tokens", lim.tokens),
zap.Float64("current-ltb-rate", float64(lim.limit)),
zap.Float64("request-tokens", n),
zap.Float64("notify-threshold", lim.notifyThreshold),
zap.Bool("is-low-process", lim.isLowProcess),
zap.Int64("burst", lim.burst),
zap.Int("remaining-notify-times", lim.remainingNotifyTimes))
// print log if the limiter cannot reserve for a while.
if time.Since(lim.last) > reserveWarnLogInterval {
log.Warn("[resource group controller] cannot reserve enough tokens",
zap.Duration("need-wait-duration", waitDuration),
zap.Duration("max-wait-duration", maxFutureReserve),
zap.Float64("current-ltb-tokens", lim.tokens),
zap.Float64("current-ltb-rate", float64(lim.limit)),
zap.Float64("request-tokens", n),
zap.Float64("notify-threshold", lim.notifyThreshold),
zap.Bool("is-low-process", lim.isLowProcess),
zap.Int64("burst", lim.burst),
zap.Int("remaining-notify-times", lim.remainingNotifyTimes))
}
lim.last = last
if lim.limit == 0 {
lim.notify()
Expand Down
Loading

0 comments on commit a0918a3

Please sign in to comment.