Skip to content

Commit

Permalink
remove changes
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <[email protected]>
  • Loading branch information
nolouch committed Jul 2, 2024
1 parent 7ed3283 commit 5a383e2
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions client/resource_group/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,29 +282,6 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {

for {
select {
/* high priority */
case <-c.lowTokenNotifyChan:
c.executeOnAllGroups((*groupCostController).updateRunState)
c.executeOnAllGroups((*groupCostController).updateAvgRequestResourcePerSec)
if len(c.run.currentRequests) == 0 {
c.collectTokenBucketRequests(c.loopCtx, FromLowRU, lowToken /* select low tokens resource group */)
}
if c.run.inDegradedMode {
c.executeOnAllGroups((*groupCostController).applyDegradedMode)
}
case resp := <-c.tokenResponseChan:
if resp != nil {
c.executeOnAllGroups((*groupCostController).updateRunState)
c.handleTokenBucketResponse(resp)
}
c.run.currentRequests = nil
case gc := <-c.tokenBucketUpdateChan:
go gc.handleTokenBucketUpdateEvent(c.loopCtx)
case <-c.responseDeadlineCh:
c.run.inDegradedMode = true
c.executeOnAllGroups((*groupCostController).applyDegradedMode)
log.Warn("[resource group controller] enter degraded mode")

/* tickers */
case <-cleanupTicker.C:
c.cleanUpResourceGroup()
Expand Down Expand Up @@ -339,6 +316,25 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {
case <-c.loopCtx.Done():
resourceGroupStatusGauge.Reset()
return
case <-c.responseDeadlineCh:
c.run.inDegradedMode = true
c.executeOnAllGroups((*groupCostController).applyDegradedMode)
log.Warn("[resource group controller] enter degraded mode")
case resp := <-c.tokenResponseChan:
if resp != nil {
c.executeOnAllGroups((*groupCostController).updateRunState)
c.handleTokenBucketResponse(resp)
}
c.run.currentRequests = nil
case <-c.lowTokenNotifyChan:
c.executeOnAllGroups((*groupCostController).updateRunState)
c.executeOnAllGroups((*groupCostController).updateAvgRequestResourcePerSec)
if len(c.run.currentRequests) == 0 {
c.collectTokenBucketRequests(c.loopCtx, FromLowRU, lowToken /* select low tokens resource group */)
}
if c.run.inDegradedMode {
c.executeOnAllGroups((*groupCostController).applyDegradedMode)
}
case resp, ok := <-watchMetaChannel:
failpoint.Inject("disableWatch", func() {
if c.ruConfig.isSingleGroupByKeyspace {
Expand Down Expand Up @@ -409,6 +405,8 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {
}
log.Info("load resource controller config after config changed", zap.Reflect("config", config), zap.Reflect("ruConfig", c.ruConfig))
}
case gc := <-c.tokenBucketUpdateChan:
go gc.handleTokenBucketUpdateEvent(c.loopCtx)
}
}
}()
Expand Down

0 comments on commit 5a383e2

Please sign in to comment.