Skip to content

Commit ba3b5a2

Browse files
committed
Always assume server count >= 1
1 parent 826ea9e commit ba3b5a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/agent/lease_counter.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ func (lc *ServerLeaseCounter) Count(ctx context.Context) int {
6969
for _, lease := range leases.Items {
7070
if util.IsLeaseValid(lease) {
7171
count++
72-
} else {
7372
}
7473
}
7574

75+
// Ensure returned count is always at least 1.
76+
if count == 0 {
77+
klog.Warningf("no valid leases found, assuming server count of 1")
78+
count = 1
79+
}
80+
7681
if count != lc.fallbackCount {
7782
lc.fallbackCount = count
7883
}

0 commit comments

Comments
 (0)