From badf436ac4451590e5e84e537f2234e3632ea3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Thu, 25 Nov 2021 12:44:50 +0100 Subject: [PATCH] Eliminate MaintainObservations function in P&F --- .../src/k8s.io/apiserver/pkg/server/config.go | 1 - .../filters/priority-and-fairness_test.go | 6 ------ .../pkg/util/flowcontrol/apf_controller.go | 17 ----------------- .../pkg/util/flowcontrol/apf_filter.go | 3 --- .../pkg/util/flowcontrol/controller_test.go | 3 --- .../util/flowcontrol/fairqueuing/interface.go | 4 ---- .../fairqueuing/queueset/queueset.go | 6 ------ .../fairqueuing/testing/no-restraint.go | 3 --- 8 files changed, 43 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/server/config.go b/staging/src/k8s.io/apiserver/pkg/server/config.go index 570cd1f7840..4d3a97fe3cb 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/config.go @@ -715,7 +715,6 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G if s.isPostStartHookRegistered(priorityAndFairnessConfigConsumerHookName) { } else if c.FlowControl != nil { err := s.AddPostStartHook(priorityAndFairnessConfigConsumerHookName, func(context PostStartHookContext) error { - go c.FlowControl.MaintainObservations(context.StopCh) go c.FlowControl.Run(context.StopCh) return nil }) diff --git a/staging/src/k8s.io/apiserver/pkg/server/filters/priority-and-fairness_test.go b/staging/src/k8s.io/apiserver/pkg/server/filters/priority-and-fairness_test.go index e02df2ab0f0..ec22673846b 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/filters/priority-and-fairness_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/filters/priority-and-fairness_test.go @@ -82,9 +82,6 @@ type fakeApfFilter struct { utilflowcontrol.WatchTracker } -func (t fakeApfFilter) MaintainObservations(stopCh <-chan struct{}) { -} - func (t fakeApfFilter) Handle(ctx context.Context, requestDigest utilflowcontrol.RequestDigest, noteFn func(fs *flowcontrol.FlowSchema, pl *flowcontrol.PriorityLevelConfiguration, flowDistinguisher string), @@ -394,9 +391,6 @@ func (f *fakeWatchApfFilter) Handle(ctx context.Context, f.inflight-- } -func (f *fakeWatchApfFilter) MaintainObservations(stopCh <-chan struct{}) { -} - func (f *fakeWatchApfFilter) Run(stopCh <-chan struct{}) error { return nil } diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_controller.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_controller.go index fa18875e9de..937590a9212 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_controller.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_controller.go @@ -291,23 +291,6 @@ func newTestableController(config TestableConfig) *configController { return cfgCtlr } -// MaintainObservations keeps the observers from -// metrics.PriorityLevelConcurrencyPairVec from falling -// too far behind -func (cfgCtlr *configController) MaintainObservations(stopCh <-chan struct{}) { - wait.Until(cfgCtlr.updateObservations, 10*time.Second, stopCh) -} - -func (cfgCtlr *configController) updateObservations() { - cfgCtlr.lock.RLock() - defer cfgCtlr.lock.RUnlock() - for _, plc := range cfgCtlr.priorityLevelStates { - if plc.queues != nil { - plc.queues.UpdateObservations() - } - } -} - func (cfgCtlr *configController) Run(stopCh <-chan struct{}) error { defer utilruntime.HandleCrash() diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_filter.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_filter.go index 554eb383d87..71f147867f7 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_filter.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/apf_filter.go @@ -66,9 +66,6 @@ type Interface interface { execFn func(), ) - // MaintainObservations is a helper for maintaining statistics. - MaintainObservations(stopCh <-chan struct{}) - // Run monitors config objects from the main apiservers and causes // any needed changes to local behavior. This method ceases // activity and returns after the given channel is closed. diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/controller_test.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/controller_test.go index 13737c1a628..3473275c9ea 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/controller_test.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/controller_test.go @@ -113,9 +113,6 @@ func (cqs *ctlrTestQueueSet) BeginConfigChange(qc fq.QueuingConfig) (fq.QueueSet return ctlrTestQueueSetCompleter{cqs.cts, cqs, qc}, nil } -func (cqs *ctlrTestQueueSet) UpdateObservations() { -} - func (cqs *ctlrTestQueueSet) Dump(bool) debug.QueueSetDump { return debug.QueueSetDump{} } diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/interface.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/interface.go index 165bfb9f385..4a6d91fa91a 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/interface.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/interface.go @@ -86,10 +86,6 @@ type QueueSet interface { // exactly once. StartRequest(ctx context.Context, width *request.WorkEstimate, hashValue uint64, flowDistinguisher, fsName string, descr1, descr2 interface{}, queueNoteFn QueueNoteFn) (req Request, idle bool) - // UpdateObservations makes sure any time-based statistics have - // caught up with the current clock reading - UpdateObservations() - // Dump saves and returns the instant internal state of the queue-set. // Note that dumping process will stop the queue-set from proceeding // any requests. diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go index 171382a7c4a..9334fdf9ef6 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/queueset.go @@ -988,12 +988,6 @@ func removeQueueAndUpdateIndexes(queues []*queue, index int) []*queue { return keptQueues } -func (qs *queueSet) UpdateObservations() { - qs.reqsGaugePair.RequestsWaiting.Add(0) - qs.reqsGaugePair.RequestsExecuting.Add(0) - qs.execSeatsGauge.Add(0) -} - func (qs *queueSet) Dump(includeRequestDetails bool) debug.QueueSetDump { qs.lock.Lock() defer qs.lock.Unlock() diff --git a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/no-restraint.go b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/no-restraint.go index b002141fdb6..476b9e86298 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/no-restraint.go +++ b/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing/no-restraint.go @@ -60,9 +60,6 @@ func (noRestraint) StartRequest(ctx context.Context, workEstimate *fcrequest.Wor return noRestraintRequest{}, false } -func (noRestraint) UpdateObservations() { -} - func (noRestraint) Dump(bool) debug.QueueSetDump { return debug.QueueSetDump{} }