Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple grpc dial options for agent -> server connection #153

Merged
merged 1 commit into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ type GrpcProxyAgentOptions struct {
serviceAccountTokenPath string
}

func (o *GrpcProxyAgentOptions) ClientSetConfig(dialOption grpc.DialOption) *agent.ClientSetConfig {
func (o *GrpcProxyAgentOptions) ClientSetConfig(dialOptions ...grpc.DialOption) *agent.ClientSetConfig {
return &agent.ClientSetConfig{
Address: fmt.Sprintf("%s:%d", o.proxyServerHost, o.proxyServerPort),
AgentID: o.agentID,
SyncInterval: o.syncInterval,
ProbeInterval: o.probeInterval,
DialOption: dialOption,
DialOptions: dialOptions,
ServiceAccountTokenPath: o.serviceAccountTokenPath,
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/agent/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ClientSet struct {
// proxy server.
probeInterval time.Duration // The interval by which the agent
// periodically checks if its connections to the proxy server is ready.
dialOption grpc.DialOption
dialOptions []grpc.DialOption
// file path contains service account token
serviceAccountTokenPath string
// channel to signal shutting down the client set. Primarily for test.
Expand Down Expand Up @@ -110,7 +110,7 @@ type ClientSetConfig struct {
AgentID string
SyncInterval time.Duration
ProbeInterval time.Duration
DialOption grpc.DialOption
DialOptions []grpc.DialOption
ServiceAccountTokenPath string
}

Expand All @@ -121,14 +121,14 @@ func (cc *ClientSetConfig) NewAgentClientSet(stopCh <-chan struct{}) *ClientSet
address: cc.Address,
syncInterval: cc.SyncInterval,
probeInterval: cc.ProbeInterval,
dialOption: cc.DialOption,
dialOptions: cc.DialOptions,
serviceAccountTokenPath: cc.ServiceAccountTokenPath,
stopCh: stopCh,
}
}

func (cs *ClientSet) newAgentClient() (*AgentClient, int, error) {
return newAgentClient(cs.address, cs.agentID, cs, cs.dialOption)
return newAgentClient(cs.address, cs.agentID, cs, cs.dialOptions...)
}

func (cs *ClientSet) resetBackoff() *wait.Backoff {
Expand Down
2 changes: 1 addition & 1 deletion tests/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func runAgentWithID(agentID, addr string, stopCh <-chan struct{}) *agent.ClientS
AgentID: agentID,
SyncInterval: 100 * time.Millisecond,
ProbeInterval: 100 * time.Millisecond,
DialOption: grpc.WithInsecure(),
DialOptions: []grpc.DialOption{grpc.WithInsecure()},
}
client := cc.NewAgentClientSet(stopCh)
client.Serve()
Expand Down