Skip to content

Commit faa1d1a

Browse files
committed
Review comments
1 parent 6c68f98 commit faa1d1a

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

pkg/agent/clientset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (cs *ClientSet) Serve() {
265265
"agentIdentifiers", cs.agentIdentifiers,
266266
"serverAddress", cs.address,
267267
)
268-
go runpprof.Do(context.Background(), labels, func(ctx context.Context) { cs.sync() })
268+
go runpprof.Do(context.Background(), labels, func(context.Context) { cs.sync() })
269269
}
270270

271271
func (cs *ClientSet) shutdown() {

pkg/agent/lease_counter.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,13 @@ func NewServerLeaseCounter(pc clock.PassiveClock, leaseLister coordinationv1list
6363
// fallback count is returned. This fallback count is updated upon successful
6464
// discovery of valid leases.
6565
func (lc *ServerLeaseCounter) Count() int {
66-
// Since the number of proxy servers is generally small (1-10), we opted against
67-
// using a LIST and WATCH pattern and instead list all leases on each call.
68-
// TODO: Switch to an informer-based system and use events rather than a polling loop.
69-
start := time.Now()
70-
defer func() {
71-
latency := time.Now().Sub(start)
72-
metrics.Metrics.ObserveLeaseListLatency(latency)
73-
}()
7466
leases, err := lc.leaseLister.List(lc.selector)
7567
if err != nil {
7668
klog.Errorf("Could not list leases to update server count, using fallback count (%v): %v", lc.fallbackCount, err)
7769

7870
return lc.fallbackCount
7971
}
8072

81-
metrics.Metrics.ObserveLeaseList(200, "")
82-
8373
count := 0
8474
for _, lease := range leases {
8575
if util.IsLeaseValid(lc.pc, *lease) {
@@ -104,6 +94,11 @@ func NewLeaseInformerWithMetrics(client kubernetes.Interface, namespace string,
10494
return cache.NewSharedIndexInformer(
10595
&cache.ListWatch{
10696
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
97+
start := time.Now()
98+
defer func() {
99+
latency := time.Now().Sub(start)
100+
metrics.Metrics.ObserveLeaseListLatency(latency)
101+
}()
107102
obj, err := client.CoordinationV1().Leases(namespace).List(context.TODO(), options)
108103
if err != nil {
109104
klog.Errorf("Could not list leases: %v", err)

pkg/server/leases/controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func NewController(k8sClient kubernetes.Interface, holderIdentity string, leaseD
6767
func (c *Controller) Run(ctx context.Context) {
6868
go c.gcController.Run(ctx)
6969
go c.acquireController.Run(ctx)
70-
7170
}
7271

7372
func (c *Controller) Stop() {

0 commit comments

Comments
 (0)