Skip to content

Commit

Permalink
Merge pull request #52 from caesarxuchao/minor-fixes
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
k8s-ci-robot committed Jan 30, 2020
2 parents f1baef7 + c163923 commit 8503646
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
30 changes: 15 additions & 15 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ type GrpcProxyAgentOptions struct {
proxyServerPort int

agentID string
syncInterval int
probeInterval int
reconnectInterval int
syncInterval time.Duration
probeInterval time.Duration
reconnectInterval time.Duration
}

func (o *GrpcProxyAgentOptions) ClientSetConfig(dialOption grpc.DialOption) *agentclient.ClientSetConfig {
return &agentclient.ClientSetConfig{
Address: fmt.Sprintf("%s:%d", o.proxyServerHost, o.proxyServerPort),
AgentID: o.agentID,
SyncInterval: time.Duration(o.syncInterval) * time.Second,
ProbeInterval: time.Duration(o.probeInterval) * time.Second,
ReconnectInterval: time.Duration(o.reconnectInterval) * time.Second,
SyncInterval: o.syncInterval,
ProbeInterval: o.probeInterval,
ReconnectInterval: o.reconnectInterval,
DialOption: dialOption,
}
}
Expand All @@ -89,9 +89,9 @@ func (o *GrpcProxyAgentOptions) Flags() *pflag.FlagSet {
flags.StringVar(&o.proxyServerHost, "proxy-server-host", o.proxyServerHost, "The hostname to use to connect to the proxy-server.")
flags.IntVar(&o.proxyServerPort, "proxy-server-port", o.proxyServerPort, "The port the proxy server is listening on.")
flags.StringVar(&o.agentID, "agent-id", o.agentID, "The unique ID of this agent. Default to a generated uuid if not set.")
flags.IntVar(&o.syncInterval, "sync-interval", o.syncInterval, "The seconds by which the agent periodically checks that it has connections to all instances of the proxy server.")
flags.IntVar(&o.probeInterval, "probe-interval", o.probeInterval, "The seconds by which the agent periodically checks if its connections to the proxy server are ready.")
flags.IntVar(&o.reconnectInterval, "reconnect-interval", o.reconnectInterval, "The seconds by which the agent tries to reconnect.")
flags.DurationVar(&o.syncInterval, "sync-interval", o.syncInterval, "The interval by which the agent periodically checks that it has connections to all instances of the proxy server.")
flags.DurationVar(&o.probeInterval, "probe-interval", o.probeInterval, "The interval by which the agent periodically checks if its connections to the proxy server are ready.")
flags.DurationVar(&o.reconnectInterval, "reconnect-interval", o.reconnectInterval, "The interval by which the agent tries to reconnect.")
return flags
}

Expand All @@ -102,9 +102,9 @@ func (o *GrpcProxyAgentOptions) Print() {
klog.Warningf("ProxyServerHost set to \"%s\".\n", o.proxyServerHost)
klog.Warningf("ProxyServerPort set to %d.\n", o.proxyServerPort)
klog.Warningf("AgentID set to %s.\n", o.agentID)
klog.Warningf("SyncInterval set to %d seconds.\n", o.syncInterval)
klog.Warningf("ProbeInterval set to %d.\n", o.probeInterval)
klog.Warningf("ReconnectInterval set to %d.\n", o.reconnectInterval)
klog.Warningf("SyncInterval set to %v.\n", o.syncInterval)
klog.Warningf("ProbeInterval set to %v.\n", o.probeInterval)
klog.Warningf("ReconnectInterval set to %v.\n", o.reconnectInterval)
}

func (o *GrpcProxyAgentOptions) Validate() error {
Expand Down Expand Up @@ -143,9 +143,9 @@ func newGrpcProxyAgentOptions() *GrpcProxyAgentOptions {
proxyServerHost: "127.0.0.1",
proxyServerPort: 8091,
agentID: uuid.New().String(),
syncInterval: 5,
probeInterval: 5,
reconnectInterval: 5,
syncInterval: 5 * time.Second,
probeInterval: 5 * time.Second,
reconnectInterval: 5 * time.Second,
}
return &o
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ type ProxyRunOptions struct {
// Port we listen for admin connections on.
adminPort uint

// ID of this server.
// ID of this proxy server.
serverID string
// Number of proxy server instances, should be 1 unless it is a HA server.
// Number of proxy server instances, should be 1 unless it is a HA proxy server.
serverCount uint
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/agentclient/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
type ClientSet struct {
mu sync.Mutex //protects the clients.
clients map[string]*AgentClient // map between serverID and the client
// connects to this server.
// connects to this proxy server.

agentID string // ID of this agent
address string // proxy server address. Assuming HA proxy server
Expand Down
5 changes: 3 additions & 2 deletions pkg/agent/agentclient/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ type RedialableAgentClient struct {
stream agent.AgentService_ConnectClient

agentID string
serverID string
serverCount int
serverID string // the id of the proxy server this client connects to.
serverCount int // the number of the proxy server instances.

// connect opts
address string
Expand Down Expand Up @@ -240,6 +240,7 @@ func retryLimit(serverCount int) (retries int) {
return 3 + 21
default:
// we don't expect HA server with more than 5 instances.
klog.Warningf("unexpected to handle %d proxy servers, the limit is 5.", serverCount)
return 3 + 21
}
}
Expand Down

0 comments on commit 8503646

Please sign in to comment.