Skip to content

Commit 8ac1cc8

Browse files
dc-yingphantom5125
authored andcommitted
[fix] DeletePartialMatch instead
1 parent 6432601 commit 8ac1cc8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ray-operator/controllers/ray/metrics/ray_cluster_metrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package metrics
22

33
import (
44
"context"
5+
"strconv"
56
"sync"
67
"time"
7-
"strconv"
88

99
"github.com/go-logr/logr"
1010
"github.com/prometheus/client_golang/prometheus"
@@ -22,7 +22,7 @@ type RayClusterMetricsObserver interface {
2222
}
2323

2424
// RayClusterMetricCleanupItem represents an item in the RayCluster metric cleanup queue
25-
type RayClusterMetricCleanupItem struct {
25+
type RayClusterMetricCleanupItem struct {
2626
Name string
2727
Namespace string
2828
DeleteAt time.Time
@@ -75,7 +75,7 @@ func NewRayClusterMetricsManager(ctx context.Context, client client.Client) *Ray
7575
cleanupQueue: make([]RayClusterMetricCleanupItem, 0),
7676
metricTTL: 5 * time.Minute, // Keep metrics for 5 minutes
7777
}
78-
78+
7979
// Start the cleanup goroutine
8080
go manager.startRayClusterCleanupLoop(ctx)
8181
return manager
@@ -151,7 +151,7 @@ func (r *RayClusterMetricsManager) cleanupExpiredRayClusterMetrics() {
151151
for _, item := range r.cleanupQueue {
152152
if now.After(item.DeleteAt) {
153153
// Remove expired metric
154-
r.rayClusterProvisionedDurationSeconds.DeleteLabelValues(item.Name, item.Namespace)
154+
r.rayClusterProvisionedDurationSeconds.DeletePartialMatch(prometheus.Labels{"name": item.Name, "namespace": item.Namespace})
155155
r.log.Info("Cleaned up expired RayCluster metric", "name", item.Name, "namespace", item.Namespace)
156156
} else {
157157
// Keep non-expired items

0 commit comments

Comments
 (0)