Skip to content

Commit

Permalink
Merge pull request #153 from Jefftree/multiple-grpc-options
Browse files Browse the repository at this point in the history
Support multiple grpc dial options for agent -> server connection
  • Loading branch information
k8s-ci-robot authored Oct 26, 2020
2 parents 806811f + ba87710 commit 408d5bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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

0 comments on commit 408d5bb

Please sign in to comment.