From 46fe4bb02b58cf82406571345d9b7abf4e1e2618 Mon Sep 17 00:00:00 2001 From: Imran Pochi Date: Thu, 11 Sep 2025 19:15:27 +0000 Subject: [PATCH] fix: avoid stale server count update Signed-off-by: Imran Pochi --- pkg/agent/clientset.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/agent/clientset.go b/pkg/agent/clientset.go index e620d0e66..886bf85b7 100644 --- a/pkg/agent/clientset.go +++ b/pkg/agent/clientset.go @@ -300,11 +300,14 @@ func (cs *ClientSet) connectOnce() (int, error) { if err != nil { return serverCount, err } - cs.lastReceivedServerCount = receivedServerCount if err := cs.AddClient(c.serverID, c); err != nil { c.Close() return serverCount, err } + // By moving the update to here, we only accept the server count from a server + // that we have successfully added to our active client set, implicitly ignoring + // stale data from duplicate connection attempts. + cs.lastReceivedServerCount = receivedServerCount klog.V(2).InfoS("sync added client connecting to proxy server", "serverID", c.serverID) labels := runpprof.Labels(