Skip to content

Commit

Permalink
changed KNP agent clientset to pick up the larger of the two server c…
Browse files Browse the repository at this point in the history
…ounts
  • Loading branch information
konryd committed Nov 15, 2024
1 parent 23b100b commit db2cd97
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pkg/agent/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,25 @@ func (cs *ClientSet) sync() {
}

func (cs *ClientSet) ServerCount() int {
var serverCount int
countFromLeases := 0
if cs.leaseCounter != nil {
serverCount = cs.leaseCounter.Count()
} else {
serverCount = cs.lastReceivedServerCount
countFromLeases = cs.leaseCounter.Count()
}
countFromResponses := cs.lastReceivedServerCount

serverCount := countFromLeases
countSource := "KNP server lease count"
if countFromResponses > serverCount {
serverCount = countFromResponses
countSource = "KNP server response headers"
}
if serverCount == 0 {
serverCount = 1
countSource = "fallback to 1"
}

if serverCount != cs.lastServerCount {
klog.Warningf("change detected in proxy server count (was: %d, now: %d)", cs.lastServerCount, serverCount)
klog.Warningf("change detected in proxy server count (was: %d, now: %d, source: %q)", cs.lastServerCount, serverCount, countSource)
cs.lastServerCount = serverCount
}

Expand Down

0 comments on commit db2cd97

Please sign in to comment.