Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 47 additions & 22 deletions pkg/agent/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,67 @@ const (

// ClientSet consists of clients connected to each instance of an HA proxy server.
type ClientSet struct {
mu sync.Mutex //protects the clients.
clients map[string]*Client // map between serverID and the client
// connects to this server.

agentID string // ID of this agent
address string // proxy server address. Assuming HA proxy server

leaseCounter ServerCounter // counts number of proxy server leases
lastReceivedServerCount int // last server count received from a proxy server
lastServerCount int // last server count value from either lease system or proxy server, former takes priority

// unless it is an HA server. Initialized when the ClientSet creates
// the first client. When syncForever is set, it will be the most recently seen.
syncInterval time.Duration // The interval by which the agent
// periodically checks that it has connections to all instances of the
// proxy server.
probeInterval time.Duration // The interval by which the agent
// mu guards access to the clients map
mu sync.Mutex

// clients is a map between serverID and the client
// connected to this server.
clients map[string]*Client

// agentID is "our ID" - the ID of this agent.
agentID string

// Address is the proxy server address. Assuming HA proxy server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO to improve this. Its the address we use to contact the ANP Server. Normally this would be a LB address in front of the ANP Servers.

address string

// leaseCounter counts number of proxy server leases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: This only used if the relevant feature is enabled.

leaseCounter ServerCounter

// lastReceivedServerCount is the last serverCount value received when connecting to a proxy server
lastReceivedServerCount int

// lastServerCount is the most-recently observed serverCount value from either lease system or proxy server,
// former takes priority unless it is an HA server.
// Initialized when the ClientSet creates the first client.
// When syncForever is set, it will be the most recently seen.
lastServerCount int

// syncInterval is the interval at which the agent periodically checks
// that it has connections to all instances of the proxy server.
syncInterval time.Duration

// The maximum interval for the syncInterval to back off to when unable to connect to the proxy server
syncIntervalCap time.Duration

// syncForever is true if we should continue syncing (support dynamic server count).
syncForever bool

// probeInterval is the interval at which the agent
// periodically checks if its connections to the proxy server is ready.
syncIntervalCap time.Duration // The maximum interval
// for the syncInterval to back off to when unable to connect to the proxy server
probeInterval time.Duration

dialOptions []grpc.DialOption
// file path contains service account token

// serviceAccountTokenPath is the file path to our kubernetes service account token
serviceAccountTokenPath string

// channel to signal that the agent is pending termination.
drainCh <-chan struct{}

// channel to signal shutting down the client set. Primarily for test.
stopCh <-chan struct{}

agentIdentifiers string // The identifiers of the agent, which will be used
// agentIdentifiers is the identifiers of the agent, which will be used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is a comma delineated list.

// by the server when choosing agent
agentIdentifiers string

warnOnChannelLimit bool
xfrChannelSize int

syncForever bool // Continue syncing (support dynamic server count).
// serverCountSource controls how we compute the server count.
// The proxy server sends the serverCount header to each connecting agent,
// and the agent figures out from these observations how many
// agent-to-proxy-server connections it should maintain.
serverCountSource string
}

Expand Down
Loading