diff --git a/go.mod b/go.mod index 94d883acc..03940355d 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( k8s.io/kube-openapi v0.0.0-20240808142205-8e686545bdb8 knative.dev/hack v0.0.0-20250109131303-f8be0ccdff36 knative.dev/hack/schema v0.0.0-20250109131303-f8be0ccdff36 - knative.dev/pkg v0.0.0-20250109201817-83cd52ed87d9 + knative.dev/pkg v0.0.0-20250110150618-accfe3649188 ) require ( diff --git a/go.sum b/go.sum index 86598f104..d7fd78f51 100644 --- a/go.sum +++ b/go.sum @@ -701,8 +701,8 @@ knative.dev/hack v0.0.0-20250109131303-f8be0ccdff36 h1:iZ6CwYLo+y82MXlK7PoG/cnFE knative.dev/hack v0.0.0-20250109131303-f8be0ccdff36/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY= knative.dev/hack/schema v0.0.0-20250109131303-f8be0ccdff36 h1:j7/31r2d68tu3zVVxSSrEbuLqjGrgWzfzwY5+wXyISw= knative.dev/hack/schema v0.0.0-20250109131303-f8be0ccdff36/go.mod h1:jRH/sx6mwwuMVhvJgnzSaoYA1N4qaIkJa+zxEGtVA5I= -knative.dev/pkg v0.0.0-20250109201817-83cd52ed87d9 h1:b4S5OUBLwlbfC9Twr+4AfEcH7zK8CKUdjdyOTirfvoU= -knative.dev/pkg v0.0.0-20250109201817-83cd52ed87d9/go.mod h1:C1u0e6tMiEkqcKsurZn2wGTH6utcTbODFwJBPyZ56lA= +knative.dev/pkg v0.0.0-20250110150618-accfe3649188 h1:xM2blxCAN0VzKQPYqeq2jNBL7xN6Iyn1avs+Ib+ogaM= +knative.dev/pkg v0.0.0-20250110150618-accfe3649188/go.mod h1:C1u0e6tMiEkqcKsurZn2wGTH6utcTbODFwJBPyZ56lA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 152d837d6..bb5ab347a 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -228,7 +228,7 @@ type ControllerOptions struct { WorkQueueName string Logger *zap.SugaredLogger Reporter StatsReporter - RateLimiter workqueue.RateLimiter + RateLimiter workqueue.TypedRateLimiter[any] Concurrency int } @@ -236,7 +236,7 @@ type ControllerOptions struct { // provided Reconciler as it is enqueued. func NewContext(ctx context.Context, r Reconciler, options ControllerOptions) *Impl { if options.RateLimiter == nil { - options.RateLimiter = workqueue.DefaultControllerRateLimiter() + options.RateLimiter = workqueue.DefaultTypedControllerRateLimiter[any]() } if options.Reporter == nil { options.Reporter = MustNewStatsReporter(options.WorkQueueName, options.Logger) @@ -263,7 +263,7 @@ func NewContext(ctx context.Context, r Reconciler, options ControllerOptions) *I } // WorkQueue permits direct access to the work queue. -func (c *Impl) WorkQueue() workqueue.RateLimitingInterface { +func (c *Impl) WorkQueue() workqueue.TypedRateLimitingInterface[any] { return c.workQueue } diff --git a/vendor/knative.dev/pkg/controller/two_lane_queue.go b/vendor/knative.dev/pkg/controller/two_lane_queue.go index d3656285b..86299c297 100644 --- a/vendor/knative.dev/pkg/controller/two_lane_queue.go +++ b/vendor/knative.dev/pkg/controller/two_lane_queue.go @@ -23,12 +23,12 @@ import "k8s.io/client-go/util/workqueue" // -- slow queue (slowLane queue), whose contents are processed if fast queue has no items. // All the default methods operate on the fast queue, unless noted otherwise. type twoLaneQueue struct { - workqueue.RateLimitingInterface - slowLane workqueue.RateLimitingInterface + workqueue.TypedRateLimitingInterface[any] + slowLane workqueue.TypedRateLimitingInterface[any] // consumerQueue is necessary to ensure that we're not reconciling // the same object at the exact same time (e.g. if it had been enqueued // in both fast and slow and is the only object there). - consumerQueue workqueue.Interface + consumerQueue workqueue.TypedInterface[any] name string @@ -37,9 +37,9 @@ type twoLaneQueue struct { } // Creates a new twoLaneQueue. -func newTwoLaneWorkQueue(name string, rl workqueue.RateLimiter) *twoLaneQueue { +func newTwoLaneWorkQueue(name string, rl workqueue.TypedRateLimiter[any]) *twoLaneQueue { tlq := &twoLaneQueue{ - RateLimitingInterface: workqueue.NewNamedRateLimitingQueue( + TypedRateLimitingInterface: workqueue.NewNamedRateLimitingQueue( rl, name+"-fast", ), @@ -55,12 +55,12 @@ func newTwoLaneWorkQueue(name string, rl workqueue.RateLimiter) *twoLaneQueue { // Run consumer thread. go tlq.runConsumer() // Run producer threads. - go process(tlq.RateLimitingInterface, tlq.fastChan) + go process(tlq.TypedRateLimitingInterface, tlq.fastChan) go process(tlq.slowLane, tlq.slowChan) return tlq } -func process(q workqueue.Interface, ch chan interface{}) { +func process(q workqueue.TypedInterface[any], ch chan interface{}) { // Sender closes the channel defer close(ch) for { @@ -125,7 +125,7 @@ func (tlq *twoLaneQueue) runConsumer() { // Shutdown implements workqueue.Interface. // Shutdown shuts down both queues. func (tlq *twoLaneQueue) ShutDown() { - tlq.RateLimitingInterface.ShutDown() + tlq.TypedRateLimitingInterface.ShutDown() tlq.slowLane.ShutDown() } @@ -147,10 +147,10 @@ func (tlq *twoLaneQueue) Get() (interface{}, bool) { // Len returns the sum of lengths. // NB: actual _number_ of unique object might be less than this sum. func (tlq *twoLaneQueue) Len() int { - return tlq.RateLimitingInterface.Len() + tlq.slowLane.Len() + tlq.consumerQueue.Len() + return tlq.TypedRateLimitingInterface.Len() + tlq.slowLane.Len() + tlq.consumerQueue.Len() } // SlowLane gives direct access to the slow queue. -func (tlq *twoLaneQueue) SlowLane() workqueue.RateLimitingInterface { +func (tlq *twoLaneQueue) SlowLane() workqueue.TypedRateLimitingInterface[any] { return tlq.slowLane } diff --git a/vendor/knative.dev/pkg/hash/hash.go b/vendor/knative.dev/pkg/hash/hash.go index ae2969acd..e51b999e9 100644 --- a/vendor/knative.dev/pkg/hash/hash.go +++ b/vendor/knative.dev/pkg/hash/hash.go @@ -35,7 +35,7 @@ const ( // universe represents the possible range of angles [0, universe). // We want to have universe divide total range evenly to reduce bias. - universe = (1 << 11) + universe uint64 = (1 << 11) ) // computeAngle returns a uint64 number which represents @@ -51,13 +51,13 @@ func computeHash(n []byte, h hash.Hash64) uint64 { type hashData struct { // The set of all hashes for fast lookup and to name mapping - nameLookup map[int]string + nameLookup map[uint64]string // Sorted set of hashes for selection algorithm. - hashPool []int + hashPool []uint64 // start angle - start int + start uint64 // step angle - step int + step uint64 } func (hd *hashData) fromIndexSet(s sets.Set[int]) sets.Set[string] { @@ -85,13 +85,13 @@ func buildHashes(in sets.Set[string], target string) *hashData { buf.WriteString(startSalt) hasher := fnv.New64a() hd := &hashData{ - nameLookup: make(map[int]string, len(from)), - hashPool: make([]int, len(from)), - start: int(computeHash(buf.Bytes(), hasher) % universe), + nameLookup: make(map[uint64]string, len(from)), + hashPool: make([]uint64, len(from)), + start: computeHash(buf.Bytes(), hasher) % universe, } buf.Truncate(len(target)) // Discard the angle salt. buf.WriteString(stepSalt) - hd.step = int(computeHash(buf.Bytes(), hasher) % universe) + hd.step = computeHash(buf.Bytes(), hasher) % universe for i, f := range from { buf.Reset() // This retains the storage. @@ -99,7 +99,7 @@ func buildHashes(in sets.Set[string], target string) *hashData { buf.WriteString(f) buf.WriteString(target) h := computeHash(buf.Bytes(), hasher) - hs := int(h % universe) + hs := h % universe // Two values slotted to the same bucket. // On average should happen with 1/universe probability. _, ok := hd.nameLookup[hs] @@ -107,7 +107,7 @@ func buildHashes(in sets.Set[string], target string) *hashData { // Feed the hash as salt. buf.WriteString(strconv.FormatUint(h, 16 /*append hex strings for shortness*/)) h = computeHash(buf.Bytes(), hasher) - hs = int(h % universe) + hs = h % universe _, ok = hd.nameLookup[hs] } diff --git a/vendor/knative.dev/pkg/metrics/config.go b/vendor/knative.dev/pkg/metrics/config.go index 9ed17ef67..6cea1b33a 100644 --- a/vendor/knative.dev/pkg/metrics/config.go +++ b/vendor/knative.dev/pkg/metrics/config.go @@ -232,7 +232,7 @@ func prometheusPort() (int, error) { return defaultPrometheusPort, nil } - pp, err := strconv.ParseUint(ppStr, 10, 16) + pp, err := strconv.ParseInt(ppStr, 10, 16) if err != nil { return -1, fmt.Errorf("the environment variable %q could not be parsed as a port number: %w", prometheusPortEnvName, err) diff --git a/vendor/knative.dev/pkg/metrics/memstats.go b/vendor/knative.dev/pkg/metrics/memstats.go index d96a0f4bc..ca090bba1 100644 --- a/vendor/knative.dev/pkg/metrics/memstats.go +++ b/vendor/knative.dev/pkg/metrics/memstats.go @@ -19,6 +19,7 @@ package metrics import ( "context" "log" + "math" "runtime" "time" @@ -379,76 +380,76 @@ func (msp *MemStatsProvider) Start(ctx context.Context, period time.Duration) { ms := runtime.MemStats{} runtime.ReadMemStats(&ms) if msp.Alloc != nil { - Record(ctx, msp.Alloc.M(int64(ms.Alloc))) + Record(ctx, msp.Alloc.M(safeint64(ms.Alloc))) } if msp.TotalAlloc != nil { - Record(ctx, msp.TotalAlloc.M(int64(ms.TotalAlloc))) + Record(ctx, msp.TotalAlloc.M(safeint64(ms.TotalAlloc))) } if msp.Sys != nil { - Record(ctx, msp.Sys.M(int64(ms.Sys))) + Record(ctx, msp.Sys.M(safeint64(ms.Sys))) } if msp.Lookups != nil { - Record(ctx, msp.Lookups.M(int64(ms.Lookups))) + Record(ctx, msp.Lookups.M(safeint64(ms.Lookups))) } if msp.Mallocs != nil { - Record(ctx, msp.Mallocs.M(int64(ms.Mallocs))) + Record(ctx, msp.Mallocs.M(safeint64(ms.Mallocs))) } if msp.Frees != nil { - Record(ctx, msp.Frees.M(int64(ms.Frees))) + Record(ctx, msp.Frees.M(safeint64(ms.Frees))) } if msp.HeapAlloc != nil { - Record(ctx, msp.HeapAlloc.M(int64(ms.HeapAlloc))) + Record(ctx, msp.HeapAlloc.M(safeint64(ms.HeapAlloc))) } if msp.HeapSys != nil { - Record(ctx, msp.HeapSys.M(int64(ms.HeapSys))) + Record(ctx, msp.HeapSys.M(safeint64(ms.HeapSys))) } if msp.HeapIdle != nil { - Record(ctx, msp.HeapIdle.M(int64(ms.HeapIdle))) + Record(ctx, msp.HeapIdle.M(safeint64(ms.HeapIdle))) } if msp.HeapInuse != nil { - Record(ctx, msp.HeapInuse.M(int64(ms.HeapInuse))) + Record(ctx, msp.HeapInuse.M(safeint64(ms.HeapInuse))) } if msp.HeapReleased != nil { - Record(ctx, msp.HeapReleased.M(int64(ms.HeapReleased))) + Record(ctx, msp.HeapReleased.M(safeint64(ms.HeapReleased))) } if msp.HeapObjects != nil { - Record(ctx, msp.HeapObjects.M(int64(ms.HeapObjects))) + Record(ctx, msp.HeapObjects.M(safeint64(ms.HeapObjects))) } if msp.StackInuse != nil { - Record(ctx, msp.StackInuse.M(int64(ms.StackInuse))) + Record(ctx, msp.StackInuse.M(safeint64(ms.StackInuse))) } if msp.StackSys != nil { - Record(ctx, msp.StackSys.M(int64(ms.StackSys))) + Record(ctx, msp.StackSys.M(safeint64(ms.StackSys))) } if msp.MSpanInuse != nil { - Record(ctx, msp.MSpanInuse.M(int64(ms.MSpanInuse))) + Record(ctx, msp.MSpanInuse.M(safeint64(ms.MSpanInuse))) } if msp.MSpanSys != nil { - Record(ctx, msp.MSpanSys.M(int64(ms.MSpanSys))) + Record(ctx, msp.MSpanSys.M(safeint64(ms.MSpanSys))) } if msp.MCacheInuse != nil { - Record(ctx, msp.MCacheInuse.M(int64(ms.MCacheInuse))) + Record(ctx, msp.MCacheInuse.M(safeint64(ms.MCacheInuse))) } if msp.MCacheSys != nil { - Record(ctx, msp.MCacheSys.M(int64(ms.MCacheSys))) + Record(ctx, msp.MCacheSys.M(safeint64(ms.MCacheSys))) } if msp.BuckHashSys != nil { - Record(ctx, msp.BuckHashSys.M(int64(ms.BuckHashSys))) + Record(ctx, msp.BuckHashSys.M(safeint64(ms.BuckHashSys))) } if msp.GCSys != nil { - Record(ctx, msp.GCSys.M(int64(ms.GCSys))) + Record(ctx, msp.GCSys.M(safeint64(ms.GCSys))) } if msp.OtherSys != nil { - Record(ctx, msp.OtherSys.M(int64(ms.OtherSys))) + Record(ctx, msp.OtherSys.M(safeint64(ms.OtherSys))) } if msp.NextGC != nil { - Record(ctx, msp.NextGC.M(int64(ms.NextGC))) + Record(ctx, msp.NextGC.M(safeint64(ms.NextGC))) } if msp.LastGC != nil { - Record(ctx, msp.LastGC.M(int64(ms.LastGC))) + Record(ctx, msp.LastGC.M(safeint64(ms.LastGC))) } if msp.PauseTotalNs != nil { - Record(ctx, msp.PauseTotalNs.M(int64(ms.PauseTotalNs))) + Record(ctx, msp.PauseTotalNs.M(safeint64(ms.PauseTotalNs))) } if msp.NumGC != nil { Record(ctx, msp.NumGC.M(int64(ms.NumGC))) @@ -549,3 +550,11 @@ func (msp *MemStatsProvider) DefaultViews() (views []*view.View) { } return } + +func safeint64(val uint64) int64 { + if val > math.MaxInt64 { + return math.MaxInt64 + } + + return int64(val) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 54a5e3b65..7cd4936a8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -878,7 +878,7 @@ knative.dev/hack/schema/commands knative.dev/hack/schema/docs knative.dev/hack/schema/registry knative.dev/hack/schema/schema -# knative.dev/pkg v0.0.0-20250109201817-83cd52ed87d9 +# knative.dev/pkg v0.0.0-20250110150618-accfe3649188 ## explicit; go 1.22.7 knative.dev/pkg/apis knative.dev/pkg/apis/duck