Skip to content

Commit

Permalink
Fix notify drainer not enable tls (#971) (#972)
Browse files Browse the repository at this point in the history
* Fix notify drainer not enable tls
  • Loading branch information
july2993 authored May 29, 2020
1 parent 28702f7 commit 332f3e5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pump/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package pump

import (
"crypto/tls"
"fmt"
"io/ioutil"
"net"
Expand All @@ -35,6 +36,7 @@ import (
"go.uber.org/zap"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)

const (
Expand All @@ -50,6 +52,7 @@ type pumpNode struct {
*node.EtcdRegistry
status *node.Status
heartbeatInterval time.Duration
tls *tls.Config

// latestTS and latestTime is used for get approach ts
latestTS int64
Expand Down Expand Up @@ -115,6 +118,7 @@ func NewPumpNode(cfg *Config, getMaxCommitTs func() int64) (node.Node, error) {
}

node := &pumpNode{
tls: cfg.tls,
EtcdRegistry: etcdRegistry,
status: status,
heartbeatInterval: time.Duration(cfg.HeartbeatInterval) * time.Second,
Expand Down Expand Up @@ -167,10 +171,15 @@ func (p *pumpNode) Notify(ctx context.Context) error {
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("tcp", addr, timeout)
}),
grpc.WithInsecure(),
grpc.WithBlock(),
}

if p.tls != nil {
dialerOpts = append(dialerOpts, grpc.WithTransportCredentials(credentials.NewTLS(p.tls)))
} else {
dialerOpts = append(dialerOpts, grpc.WithInsecure())
}

for _, c := range drainers {
if c.State != node.Online {
continue
Expand Down

0 comments on commit 332f3e5

Please sign in to comment.