Skip to content

Commit

Permalink
*: fix data race of TestWatchResourceGroup (#8605)
Browse files Browse the repository at this point in the history
close #8599

Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] authored Sep 10, 2024
1 parent 8949567 commit 8871760
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/mcs/resourcemanager/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
ru = 0
}
availableRUCounter.WithLabelValues(group.Name, group.Name).Set(ru)
resourceGroupConfigGauge.WithLabelValues(group.Name, priorityLabel).Set(float64(group.Priority))
resourceGroupConfigGauge.WithLabelValues(group.Name, ruPerSecLabel).Set(float64(group.RUSettings.RU.Settings.FillRate))
resourceGroupConfigGauge.WithLabelValues(group.Name, ruCapacityLabel).Set(float64(group.RUSettings.RU.Settings.BurstLimit))
resourceGroupConfigGauge.WithLabelValues(group.Name, priorityLabel).Set(group.getPriority())
resourceGroupConfigGauge.WithLabelValues(group.Name, ruPerSecLabel).Set(group.getFillRate())
resourceGroupConfigGauge.WithLabelValues(group.Name, ruCapacityLabel).Set(group.getBurstLimit())
}
case <-recordMaxTicker.C:
// Record the sum of RRU and WRU every second.
Expand Down
18 changes: 18 additions & 0 deletions pkg/mcs/resourcemanager/server/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ func (rg *ResourceGroup) getRUToken() float64 {
return rg.RUSettings.RU.Tokens
}

func (rg *ResourceGroup) getPriority() float64 {
rg.RLock()
defer rg.RUnlock()
return float64(rg.Priority)
}

func (rg *ResourceGroup) getFillRate() float64 {
rg.RLock()
defer rg.RUnlock()
return float64(rg.RUSettings.RU.Settings.FillRate)
}

func (rg *ResourceGroup) getBurstLimit() float64 {
rg.RLock()
defer rg.RUnlock()
return float64(rg.RUSettings.RU.Settings.BurstLimit)
}

// PatchSettings patches the resource group settings.
// Only used to patch the resource group when updating.
// Note: the tokens is the delta value to patch.
Expand Down

0 comments on commit 8871760

Please sign in to comment.