mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: bump sigs.k8s.io/controller-runtime
Bumps the k8s-dependencies group with 1 update: [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime). Updates `sigs.k8s.io/controller-runtime` from 0.20.4 to 0.21.0 - [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.20.4...v0.21.0) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-runtime dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
d05ebd3456
commit
eb13efc9df
54
vendor/sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue/metrics.go
generated
vendored
54
vendor/sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue/metrics.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/utils/clock"
|
||||
"sigs.k8s.io/controller-runtime/pkg/internal/metrics"
|
||||
)
|
||||
|
||||
// This file is mostly a copy of unexported code from
|
||||
@ -14,8 +15,9 @@ import (
|
||||
// The only two differences are the addition of mapLock in defaultQueueMetrics and converging retryMetrics into queueMetrics.
|
||||
|
||||
type queueMetrics[T comparable] interface {
|
||||
add(item T)
|
||||
get(item T)
|
||||
add(item T, priority int)
|
||||
get(item T, priority int)
|
||||
updateDepthWithPriorityMetric(oldPriority, newPriority int)
|
||||
done(item T)
|
||||
updateUnfinishedWork()
|
||||
retry()
|
||||
@ -25,9 +27,9 @@ func newQueueMetrics[T comparable](mp workqueue.MetricsProvider, name string, cl
|
||||
if len(name) == 0 {
|
||||
return noMetrics[T]{}
|
||||
}
|
||||
return &defaultQueueMetrics[T]{
|
||||
|
||||
dqm := &defaultQueueMetrics[T]{
|
||||
clock: clock,
|
||||
depth: mp.NewDepthMetric(name),
|
||||
adds: mp.NewAddsMetric(name),
|
||||
latency: mp.NewLatencyMetric(name),
|
||||
workDuration: mp.NewWorkDurationMetric(name),
|
||||
@ -37,6 +39,13 @@ func newQueueMetrics[T comparable](mp workqueue.MetricsProvider, name string, cl
|
||||
processingStartTimes: map[T]time.Time{},
|
||||
retries: mp.NewRetriesMetric(name),
|
||||
}
|
||||
|
||||
if mpp, ok := mp.(metrics.MetricsProviderWithPriority); ok {
|
||||
dqm.depthWithPriority = mpp.NewDepthMetricWithPriority(name)
|
||||
} else {
|
||||
dqm.depth = mp.NewDepthMetric(name)
|
||||
}
|
||||
return dqm
|
||||
}
|
||||
|
||||
// defaultQueueMetrics expects the caller to lock before setting any metrics.
|
||||
@ -44,7 +53,8 @@ type defaultQueueMetrics[T comparable] struct {
|
||||
clock clock.Clock
|
||||
|
||||
// current depth of a workqueue
|
||||
depth workqueue.GaugeMetric
|
||||
depth workqueue.GaugeMetric
|
||||
depthWithPriority metrics.DepthMetricWithPriority
|
||||
// total number of adds handled by a workqueue
|
||||
adds workqueue.CounterMetric
|
||||
// how long an item stays in a workqueue
|
||||
@ -64,13 +74,17 @@ type defaultQueueMetrics[T comparable] struct {
|
||||
}
|
||||
|
||||
// add is called for ready items only
|
||||
func (m *defaultQueueMetrics[T]) add(item T) {
|
||||
func (m *defaultQueueMetrics[T]) add(item T, priority int) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
|
||||
m.adds.Inc()
|
||||
m.depth.Inc()
|
||||
if m.depthWithPriority != nil {
|
||||
m.depthWithPriority.Inc(priority)
|
||||
} else {
|
||||
m.depth.Inc()
|
||||
}
|
||||
|
||||
m.mapLock.Lock()
|
||||
defer m.mapLock.Unlock()
|
||||
@ -80,12 +94,16 @@ func (m *defaultQueueMetrics[T]) add(item T) {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultQueueMetrics[T]) get(item T) {
|
||||
func (m *defaultQueueMetrics[T]) get(item T, priority int) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
|
||||
m.depth.Dec()
|
||||
if m.depthWithPriority != nil {
|
||||
m.depthWithPriority.Dec(priority)
|
||||
} else {
|
||||
m.depth.Dec()
|
||||
}
|
||||
|
||||
m.mapLock.Lock()
|
||||
defer m.mapLock.Unlock()
|
||||
@ -97,6 +115,13 @@ func (m *defaultQueueMetrics[T]) get(item T) {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultQueueMetrics[T]) updateDepthWithPriorityMetric(oldPriority, newPriority int) {
|
||||
if m.depthWithPriority != nil {
|
||||
m.depthWithPriority.Dec(oldPriority)
|
||||
m.depthWithPriority.Inc(newPriority)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultQueueMetrics[T]) done(item T) {
|
||||
if m == nil {
|
||||
return
|
||||
@ -139,8 +164,9 @@ func (m *defaultQueueMetrics[T]) retry() {
|
||||
|
||||
type noMetrics[T any] struct{}
|
||||
|
||||
func (noMetrics[T]) add(item T) {}
|
||||
func (noMetrics[T]) get(item T) {}
|
||||
func (noMetrics[T]) done(item T) {}
|
||||
func (noMetrics[T]) updateUnfinishedWork() {}
|
||||
func (noMetrics[T]) retry() {}
|
||||
func (noMetrics[T]) add(item T, priority int) {}
|
||||
func (noMetrics[T]) get(item T, priority int) {}
|
||||
func (noMetrics[T]) updateDepthWithPriorityMetric(oldPriority, newPriority int) {}
|
||||
func (noMetrics[T]) done(item T) {}
|
||||
func (noMetrics[T]) updateUnfinishedWork() {}
|
||||
func (noMetrics[T]) retry() {}
|
||||
|
12
vendor/sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue/priorityqueue.go
generated
vendored
12
vendor/sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue/priorityqueue.go
generated
vendored
@ -156,7 +156,7 @@ func (w *priorityqueue[T]) AddWithOpts(o AddOpts, items ...T) {
|
||||
w.items[key] = item
|
||||
w.queue.ReplaceOrInsert(item)
|
||||
if item.ReadyAt == nil {
|
||||
w.metrics.add(key)
|
||||
w.metrics.add(key, item.Priority)
|
||||
}
|
||||
w.addedCounter++
|
||||
continue
|
||||
@ -166,12 +166,16 @@ func (w *priorityqueue[T]) AddWithOpts(o AddOpts, items ...T) {
|
||||
// will affect the order - Just delete and re-add.
|
||||
item, _ := w.queue.Delete(w.items[key])
|
||||
if o.Priority > item.Priority {
|
||||
// Update depth metric only if the item in the queue was already added to the depth metric.
|
||||
if item.ReadyAt == nil || w.becameReady.Has(key) {
|
||||
w.metrics.updateDepthWithPriorityMetric(item.Priority, o.Priority)
|
||||
}
|
||||
item.Priority = o.Priority
|
||||
}
|
||||
|
||||
if item.ReadyAt != nil && (readyAt == nil || readyAt.Before(*item.ReadyAt)) {
|
||||
if readyAt == nil && !w.becameReady.Has(key) {
|
||||
w.metrics.add(key)
|
||||
w.metrics.add(key, item.Priority)
|
||||
}
|
||||
item.ReadyAt = readyAt
|
||||
}
|
||||
@ -223,7 +227,7 @@ func (w *priorityqueue[T]) spin() {
|
||||
return false
|
||||
}
|
||||
if !w.becameReady.Has(item.Key) {
|
||||
w.metrics.add(item.Key)
|
||||
w.metrics.add(item.Key, item.Priority)
|
||||
w.becameReady.Insert(item.Key)
|
||||
}
|
||||
}
|
||||
@ -239,7 +243,7 @@ func (w *priorityqueue[T]) spin() {
|
||||
return true
|
||||
}
|
||||
|
||||
w.metrics.get(item.Key)
|
||||
w.metrics.get(item.Key, item.Priority)
|
||||
w.locked.Insert(item.Key)
|
||||
w.waiters.Add(-1)
|
||||
delete(w.items, item.Key)
|
||||
|
Reference in New Issue
Block a user