Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix data race of TestWatchResourceGroup #8605

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading