| 1 | /* |
| 2 | Copyright 2020 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package agentscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ |
| 18 | |
| 19 | import ( |
| 20 | "contextscip-go gomod github.com/golang/go/src go1.23.6 context/" |
| 21 | "mathscip-go gomod github.com/golang/go/src go1.23.6 math/" |
| 22 | runpprofscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/ "runtime/pprofscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/" |
| 23 | "syncscip-go gomod github.com/golang/go/src go1.23.6 sync/" |
| 24 | "timescip-go gomod github.com/golang/go/src go1.23.6 time/" |
| 25 | |
| 26 | "google.golang.org/grpcscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc`/" |
| 27 | "google.golang.org/grpc/connectivityscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc/connectivity`/" |
| 28 | "k8s.io/apimachinery/pkg/util/waitscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/" |
| 29 | "k8s.io/klog/v2scip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/" |
| 30 | "sigs.k8s.io/apiserver-network-proxy/pkg/agent/metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/" |
| 31 | ) |
| 32 | |
| 33 | const ( |
| 34 | fromResponsesscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromResponses. = "KNP server response headers" |
| 35 | fromLeasesscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromLeases. = "KNP lease count" |
| 36 | fromFallbackscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromFallback. = "fallback to 1" |
| 37 | ) |
| 38 | |
| 39 | // ClientSet consists of clients connected to each instance of an HA proxy server. |
| 40 | type ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet# struct { |
| 41 | // mu guards access to the clients map |
| 42 | muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu. syncscip-go gomod github.com/golang/go/src go1.23.6 sync/.Mutexscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex# |
| 43 | |
| 44 | // clients is a map between serverID and the client |
| 45 | // connected to this server. |
| 46 | clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients. map[string]*Clientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client# |
| 47 | |
| 48 | // agentID is "our ID" - the ID of this agent. |
| 49 | agentIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentID. string |
| 50 | |
| 51 | // Address is the proxy server address. Assuming HA proxy server |
| 52 | addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#address. string |
| 53 | |
| 54 | // leaseCounter counts number of proxy server leases |
| 55 | leaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#leaseCounter. ServerCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ServerCounter# |
| 56 | |
| 57 | // lastReceivedServerCount is the last serverCount value received when connecting to a proxy server |
| 58 | lastReceivedServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastReceivedServerCount. int |
| 59 | |
| 60 | // lastServerCount is the most-recently observed serverCount value from either lease system or proxy server, |
| 61 | // former takes priority unless it is an HA server. |
| 62 | // Initialized when the ClientSet creates the first client. |
| 63 | // When syncForever is set, it will be the most recently seen. |
| 64 | lastServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastServerCount. int |
| 65 | |
| 66 | // syncInterval is the interval at which the agent periodically checks |
| 67 | // that it has connections to all instances of the proxy server. |
| 68 | syncIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncInterval. timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 69 | |
| 70 | // The maximum interval for the syncInterval to back off to when unable to connect to the proxy server |
| 71 | syncIntervalCapscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncIntervalCap. timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 72 | |
| 73 | // syncForever is true if we should continue syncing (support dynamic server count). |
| 74 | syncForeverscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncForever. bool |
| 75 | |
| 76 | // probeInterval is the interval at which the agent |
| 77 | // periodically checks if its connections to the proxy server is ready. |
| 78 | probeIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#probeInterval. timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 79 | |
| 80 | dialOptionsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#dialOptions. []grpcscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc`/.DialOptionscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc`/DialOption# |
| 81 | |
| 82 | // serviceAccountTokenPath is the file path to our kubernetes service account token |
| 83 | serviceAccountTokenPathscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#serviceAccountTokenPath. string |
| 84 | |
| 85 | // channel to signal that the agent is pending termination. |
| 86 | drainChscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#drainCh. <-chan struct{} |
| 87 | |
| 88 | // channel to signal shutting down the client set. Primarily for test. |
| 89 | stopChscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#stopCh. <-chan struct{} |
| 90 | |
| 91 | // agentIdentifiers is the identifiers of the agent, which will be used |
| 92 | // by the server when choosing agent |
| 93 | agentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentIdentifiers. string |
| 94 | |
| 95 | warnOnChannelLimitscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#warnOnChannelLimit. bool |
| 96 | xfrChannelSizescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#xfrChannelSize. int |
| 97 | |
| 98 | // serverCountSource controls how we compute the server count. |
| 99 | // The proxy server sends the serverCount header to each connecting agent, |
| 100 | // and the agent figures out from these observations how many |
| 101 | // agent-to-proxy-server connections it should maintain. |
| 102 | serverCountSourcescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#serverCountSource. string |
| 103 | } |
| 104 | |
| 105 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) ClientsCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#ClientsCount().() int { |
| 106 | cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Lockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Lock().() |
| 107 | defer cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Unlockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Unlock().() |
| 108 | return len(cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.) |
| 109 | } |
| 110 | |
| 111 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) HealthyClientsCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#HealthyClientsCount().() int { |
| 112 | cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Lockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Lock().() |
| 113 | defer cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Unlockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Unlock().() |
| 114 | var count int |
| 115 | for _, c := range cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients. { |
| 116 | if c.connscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#conn..GetStatescip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc`/ClientConn#GetState().() == connectivityscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc/connectivity`/.Readyscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc/connectivity`/Ready. { |
| 117 | count++ |
| 118 | } |
| 119 | } |
| 120 | return count |
| 121 | |
| 122 | } |
| 123 | |
| 124 | // HasID returns true if the ClientSet has a client to the specified serverID. |
| 125 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) HasIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#HasID().(serverID string) bool { |
| 126 | cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Lockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Lock().() |
| 127 | defer cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Unlockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Unlock().() |
| 128 | _, exists := cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.[serverID] |
| 129 | return exists |
| 130 | } |
| 131 | |
| 132 | type DuplicateServerErrorscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError# struct { |
| 133 | ServerIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#ServerID. string |
| 134 | } |
| 135 | |
| 136 | func (dse *DuplicateServerErrorscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#) Errorscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#Error().() string { |
| 137 | return "duplicate server: " + dse.ServerIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#ServerID. |
| 138 | } |
| 139 | |
| 140 | // AddClient adds the specified client to our set of clients. |
| 141 | // If we already have a connection with the same serverID, we will return *DuplicateServerError. |
| 142 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) AddClientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#AddClient().(serverID string, c *Clientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#) error { |
| 143 | cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Lockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Lock().() |
| 144 | defer cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Unlockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Unlock().() |
| 145 | |
| 146 | _, exists := cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.[serverID] |
| 147 | if exists { |
| 148 | return &DuplicateServerErrorscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#{ServerIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#ServerID.: serverID} |
| 149 | } |
| 150 | cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.[serverID] = c |
| 151 | metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/.Metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/Metrics..SetServerConnectionsCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/AgentMetrics#SetServerConnectionsCount().(len(cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.)) |
| 152 | return nil |
| 153 | } |
| 154 | |
| 155 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) RemoveClientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#RemoveClient().(serverID string) { |
| 156 | cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Lockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Lock().() |
| 157 | defer cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Unlockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Unlock().() |
| 158 | if cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.[serverID] == nil { |
| 159 | return |
| 160 | } |
| 161 | cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.[serverID].Closescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#Close().() |
| 162 | delete(cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients., serverID) |
| 163 | metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/.Metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/Metrics..SetServerConnectionsCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/AgentMetrics#SetServerConnectionsCount().(len(cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.)) |
| 164 | } |
| 165 | |
| 166 | type ClientSetConfigscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig# struct { |
| 167 | Addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#Address. string |
| 168 | AgentIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#AgentID. string |
| 169 | AgentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#AgentIdentifiers. string |
| 170 | SyncIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#SyncInterval. timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 171 | ProbeIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ProbeInterval. timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 172 | SyncIntervalCapscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#SyncIntervalCap. timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 173 | DialOptionsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#DialOptions. []grpcscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc`/.DialOptionscip-go gomod google.golang.org/grpc v1.71.0 `google.golang.org/grpc`/DialOption# |
| 174 | ServiceAccountTokenPathscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ServiceAccountTokenPath. string |
| 175 | WarnOnChannelLimitscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#WarnOnChannelLimit. bool |
| 176 | SyncForeverscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#SyncForever. bool |
| 177 | XfrChannelSizescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#XfrChannelSize. int |
| 178 | ServerLeaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ServerLeaseCounter. ServerCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ServerCounter# |
| 179 | ServerCountSourcescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ServerCountSource. string |
| 180 | } |
| 181 | |
| 182 | func (cc *ClientSetConfigscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#) NewAgentClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#NewAgentClientSet().(drainCh, stopCh <-chan struct{}) *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet# { |
| 183 | return &ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#{ |
| 184 | clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients.: make(map[string]*Clientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#), |
| 185 | agentIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentID.: cc.AgentIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#AgentID., |
| 186 | agentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentIdentifiers.: cc.AgentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#AgentIdentifiers., |
| 187 | addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#address.: cc.Addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#Address., |
| 188 | syncIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncInterval.: cc.SyncIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#SyncInterval., |
| 189 | probeIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#probeInterval.: cc.ProbeIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ProbeInterval., |
| 190 | syncIntervalCapscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncIntervalCap.: cc.SyncIntervalCapscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#SyncIntervalCap., |
| 191 | dialOptionsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#dialOptions.: cc.DialOptionsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#DialOptions., |
| 192 | serviceAccountTokenPathscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#serviceAccountTokenPath.: cc.ServiceAccountTokenPathscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ServiceAccountTokenPath., |
| 193 | warnOnChannelLimitscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#warnOnChannelLimit.: cc.WarnOnChannelLimitscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#WarnOnChannelLimit., |
| 194 | syncForeverscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncForever.: cc.SyncForeverscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#SyncForever., |
| 195 | drainChscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#drainCh.: drainCh, |
| 196 | xfrChannelSizescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#xfrChannelSize.: cc.XfrChannelSizescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#XfrChannelSize., |
| 197 | stopChscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#stopCh.: stopCh, |
| 198 | leaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#leaseCounter.: cc.ServerLeaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ServerLeaseCounter., |
| 199 | serverCountSourcescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#serverCountSource.: cc.ServerCountSourcescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSetConfig#ServerCountSource., |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) newAgentClientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#newAgentClient().() (*Clientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#, int, error) { |
| 204 | return newAgentClientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/newAgentClient().(cs.addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#address., cs.agentIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentID., cs.agentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentIdentifiers., cs, cs.dialOptionsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#dialOptions....) |
| 205 | } |
| 206 | |
| 207 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) resetBackoffscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#resetBackoff().() *waitscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/.Backoffscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff# { |
| 208 | return &waitscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/.Backoffscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#{ |
| 209 | Stepsscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Steps.: mathscip-go gomod github.com/golang/go/src go1.23.6 math/.MaxInt32scip-go gomod github.com/golang/go/src go1.23.6 math/MaxInt32., |
| 210 | Jitterscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Jitter.: 0.1, |
| 211 | Factorscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Factor.: 1.5, |
| 212 | Durationscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Duration.: cs.syncIntervalscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncInterval., |
| 213 | Capscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Cap.: cs.syncIntervalCapscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncIntervalCap., |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | // sync makes sure that #clients >= #proxy servers |
| 218 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) syncscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#sync().() { |
| 219 | defer cs.shutdownscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#shutdown().() |
| 220 | backoff := cs.resetBackoffscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#resetBackoff().() |
| 221 | var duration timescip-go gomod github.com/golang/go/src go1.23.6 time/.Durationscip-go gomod github.com/golang/go/src go1.23.6 time/Duration# |
| 222 | for { |
| 223 | if serverCount, err := cs.connectOncescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#connectOnce().(); err != nil { |
| 224 | if dse, ok := err.(*DuplicateServerErrorscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#); ok { |
| 225 | clientsCount := cs.ClientsCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#ClientsCount().() |
| 226 | klogscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/.Vscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/V().(4).InfoSscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/Verbose#InfoS().("duplicate server", "serverID", dse.ServerIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/DuplicateServerError#ServerID., "serverCount", serverCount, "clientsCount", clientsCount) |
| 227 | if serverCount != 0 && clientsCount >= serverCount { |
| 228 | duration = backoff.Stepscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Step().() |
| 229 | } else { |
| 230 | backoff = cs.resetBackoffscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#resetBackoff().() |
| 231 | duration = waitscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/.Jitterscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Jitter().(backoff.Durationscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Duration., backoff.Jitterscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Jitter.) |
| 232 | } |
| 233 | } else { |
| 234 | klogscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/.ErrorSscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/ErrorS().(err, "cannot connect once") |
| 235 | duration = backoff.Stepscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Step().() |
| 236 | } |
| 237 | } else { |
| 238 | backoff = cs.resetBackoffscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#resetBackoff().() |
| 239 | duration = waitscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/.Jitterscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Jitter().(backoff.Durationscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Duration., backoff.Jitterscip-go gomod k8s.io/apimachinery v0.32.3 `k8s.io/apimachinery/pkg/util/wait`/Backoff#Jitter.) |
| 240 | } |
| 241 | timescip-go gomod github.com/golang/go/src go1.23.6 time/.Sleepscip-go gomod github.com/golang/go/src go1.23.6 time/Sleep().(duration) |
| 242 | select { |
| 243 | case <-cs.stopChscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#stopCh.: |
| 244 | return |
| 245 | default: |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) ServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#ServerCount().() int { |
| 251 | |
| 252 | var serverCount int |
| 253 | var countSourceLabel string |
| 254 | |
| 255 | switch cs.serverCountSourcescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#serverCountSource. { |
| 256 | case "", "default": |
| 257 | if cs.leaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#leaseCounter. != nil { |
| 258 | serverCount = cs.leaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#leaseCounter..Countscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ServerCounter#Count.() |
| 259 | countSourceLabel = fromLeasesscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromLeases. |
| 260 | } else { |
| 261 | serverCount = cs.lastReceivedServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastReceivedServerCount. |
| 262 | countSourceLabel = fromResponsesscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromResponses. |
| 263 | } |
| 264 | case "max": |
| 265 | countFromLeases := 0 |
| 266 | if cs.leaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#leaseCounter. != nil { |
| 267 | countFromLeases = cs.leaseCounterscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#leaseCounter..Countscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ServerCounter#Count.() |
| 268 | } |
| 269 | countFromResponses := cs.lastReceivedServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastReceivedServerCount. |
| 270 | |
| 271 | serverCount = countFromLeases |
| 272 | countSourceLabel = fromLeasesscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromLeases. |
| 273 | if countFromResponses > serverCount { |
| 274 | serverCount = countFromResponses |
| 275 | countSourceLabel = fromResponsesscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromResponses. |
| 276 | } |
| 277 | if serverCount == 0 { |
| 278 | serverCount = 1 |
| 279 | countSourceLabel = fromFallbackscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/fromFallback. |
| 280 | } |
| 281 | |
| 282 | } |
| 283 | |
| 284 | if serverCount != cs.lastServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastServerCount. { |
| 285 | klogscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/.Warningfscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/Warningf().("change detected in proxy server count (was: %d, now: %d, source: %q)", cs.lastServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastServerCount., serverCount, countSourceLabel) |
| 286 | cs.lastServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastServerCount. = serverCount |
| 287 | } |
| 288 | |
| 289 | metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/.Metricsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/Metrics..SetServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent/metrics`/AgentMetrics#SetServerCount().(serverCount) |
| 290 | return serverCount |
| 291 | } |
| 292 | |
| 293 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) connectOncescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#connectOnce().() (int, error) { |
| 294 | serverCount := cs.ServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#ServerCount().() |
| 295 | |
| 296 | if !cs.syncForeverscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#syncForever. && serverCount != 0 && cs.ClientsCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#ClientsCount().() >= serverCount { |
| 297 | return serverCount, nil |
| 298 | } |
| 299 | c, receivedServerCount, err := cs.newAgentClientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#newAgentClient().() |
| 300 | if err != nil { |
| 301 | return serverCount, err |
| 302 | } |
| 303 | cs.lastReceivedServerCountscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#lastReceivedServerCount. = receivedServerCount |
| 304 | if err := cs.AddClientscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#AddClient().(c.serverIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#serverID., c); err != nil { |
| 305 | c.Closescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#Close().() |
| 306 | return serverCount, err |
| 307 | } |
| 308 | klogscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/.Vscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/V().(2).InfoSscip-go gomod k8s.io/klog/v2 v2.130.1 `k8s.io/klog/v2`/Verbose#InfoS().("sync added client connecting to proxy server", "serverID", c.serverIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#serverID.) |
| 309 | |
| 310 | labels := runpprofscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/.Labelsscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/Labels().( |
| 311 | "agentIdentifiers", cs.agentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentIdentifiers., |
| 312 | "serverAddress", cs.addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#address., |
| 313 | "serverID", c.serverIDscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#serverID., |
| 314 | ) |
| 315 | go runpprofscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/.Doscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/Do().(contextscip-go gomod github.com/golang/go/src go1.23.6 context/.Backgroundscip-go gomod github.com/golang/go/src go1.23.6 context/Background().(), labels, func(contextscip-go gomod github.com/golang/go/src go1.23.6 context/.Contextscip-go gomod github.com/golang/go/src go1.23.6 context/Context#) { c.Servescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#Serve().() }) |
| 316 | return serverCount, nil |
| 317 | } |
| 318 | |
| 319 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) Servescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#Serve().() { |
| 320 | labels := runpprofscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/.Labelsscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/Labels().( |
| 321 | "agentIdentifiers", cs.agentIdentifiersscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#agentIdentifiers., |
| 322 | "serverAddress", cs.addressscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#address., |
| 323 | ) |
| 324 | go runpprofscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/.Doscip-go gomod github.com/golang/go/src go1.23.6 `runtime/pprof`/Do().(contextscip-go gomod github.com/golang/go/src go1.23.6 context/.Backgroundscip-go gomod github.com/golang/go/src go1.23.6 context/Background().(), labels, func(contextscip-go gomod github.com/golang/go/src go1.23.6 context/.Contextscip-go gomod github.com/golang/go/src go1.23.6 context/Context#) { cs.syncscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#sync().() }) |
| 325 | } |
| 326 | |
| 327 | func (cs *ClientSetscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#) shutdownscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#shutdown().() { |
| 328 | cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Lockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Lock().() |
| 329 | defer cs.muscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#mu..Unlockscip-go gomod github.com/golang/go/src go1.23.6 sync/Mutex#Unlock().() |
| 330 | for serverID, client := range cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients. { |
| 331 | client.Closescip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/Client#Close().() |
| 332 | delete(cs.clientsscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/agent`/ClientSet#clients., serverID) |
| 333 | } |
| 334 | } |