apiserver-network-proxy icon indicating copy to clipboard operation
apiserver-network-proxy copied to clipboard

if proxy-strategy has default, all agents are added to DefaultBackendManager

Open ipochi opened this issue 1 year ago • 4 comments
trafficstars

If proxy-server explicitly mentions default as one of the proxy-strategy along with others, then all agents are added to the DefaultBackendManager despite an agent having agent-identifers set corresponding to default-route or dest-host.

  • NewProxyServer creates a slice of BackendManagers from proxystrategies (whichever order they are listed, point being that default is explicitly added).

  • addBackend iterates through the list of BackendManagers from above and adds agents to the Backend list of each respective BackendManagers.

Note: it cycles through all BackendManagers for each agent that is added. So an agent that has agent-identifiers set and host=abc.com&host=pqr.com&default-route=false, it will be listed under DestHost , DefaultRoute and since proxy-strategy also mentions default regardless of the order, it will also add the agent to the Default backendmanager.

Start server locally with --proxy-strategies=destHost,defaultRoute,default

./bin/proxy-server --mode=http-connect --server-ca-cert=certs/frontend/issued/ca.crt --server-cert=certs/frontend/issued/proxy-frontend.crt --server-key=certs/frontend/private/proxy-frontend.key --cluster-ca-cert=certs/agent/issued/ca.crt --cluster-cert=certs/agent/issued/proxy-frontend.crt --cluster-key=certs/agent/private/proxy-frontend.key --server-count=1 -v 5 --proxy-strategies=destHost,defaultRoute,default

Start one agent with --agent-identifiers="host=httpbin.org&default-route=false

./bin/proxy-agent --ca-cert=certs/agent/issued/ca.crt --agent-cert=certs/agent/issued/proxy-agent.crt --agent-key=certs/agent/private/proxy-agent.key -v 5 --agent-identifiers="host=httpbin.org&default-route=false

Logs in server

I1207 04:13:36.507748   56309 server.go:669] "Connect request from agent" agentID="927aaa20-1d1c-4de6-a4e3-75b9f4df113e" serverID="b6cf38ad-d225-4488-8e02-864ac8567bd6"
I1207 04:13:36.507830   56309 server.go:214] "Add the agent to DestHostBackendManager" agent address="httpbin.org"
I1207 04:13:36.507872   56309 backend_manager.go:191] "Register backend for agent" connection=&{ServerStream:0x140005b41a0} agentID="httpbin.org"
I1207 04:13:36.507884   56309 server.go:228] "Add the agent to DefaultBackendManager" agentID="927aaa20-1d1c-4de6-a4e3-75b9f4df113e"
I1207 04:13:36.507890   56309 backend_manager.go:191] "Register backend for agent" connection=&{ServerStream:0x140005b41a0} agentID="927aaa20-1d1c-4de6-a4e3-75b9f4df113e"

Says the agent was added to both Default and DestHostBackendManager

If I remove default from proxy-strategy, then server adds the backend only to DestHostBackendManager

I1207 04:14:48.920883   56355 server.go:132] Starting health server for healthchecks.
I1207 04:14:53.983413   56355 server.go:669] "Connect request from agent" agentID="5c5cf08d-f83b-403a-8773-0e1d7ca93cfc" serverID="b5537b94-f1f0-4c08-bfa0-ad6908a51484"
I1207 04:14:53.983461   56355 server.go:214] "Add the agent to DestHostBackendManager" agent address="httpbin.org"
I1207 04:14:53.983481   56355 backend_manager.go:191] "Register backend for agent" connection=&{ServerStream:0x140005401a0} agentID="httpbin.org"

ipochi avatar Dec 18 '23 08:12 ipochi