Skip to content

Commit

Permalink
Fix RPC call to vl3-ipam
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <[email protected]>
  • Loading branch information
glazychev-art committed May 5, 2023
1 parent 54d3513 commit 0b08610
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,25 @@ func (c *Config) Process() error {
func startListenPrefixes(ctx context.Context, c *Config, tlsClientConfig *tls.Config, subscriptions []chan *ipam.PrefixResponse) {
var previousResponse *ipam.PrefixResponse
go func() {
for ; ctx.Err() == nil; time.Sleep(time.Millisecond * 200) {
cc, err := grpc.DialContext(ctx, grpcutils.URLToTarget(&c.PrefixServerURL), grpc.WithTransportCredentials(
credentials.NewTLS(
tlsClientConfig,
var cc *grpc.ClientConn
var err error
for ctx.Err() == nil {
// Close the previous clientConn
if cc != nil {
_ = cc.Close()
}
dialCtx, dialCtxCancel := context.WithTimeout(ctx, time.Millisecond*200)
cc, err = grpc.DialContext(dialCtx,
grpcutils.URLToTarget(&c.PrefixServerURL),
grpc.WithBlock(),
grpc.WithTransportCredentials(
credentials.NewTLS(
tlsClientConfig,
),
),
))
)
// It is safe to cancel dial ctx after DialContext if WithBlock() option is used
dialCtxCancel()
if err != nil {
logrus.Error(err.Error())
continue
Expand Down

0 comments on commit 0b08610

Please sign in to comment.