From 7dae6e455839e424491822dd627231b2a1f2a8db Mon Sep 17 00:00:00 2001 From: adrianc Date: Wed, 24 Jul 2024 13:22:32 +0300 Subject: [PATCH] remove waiting for grpc server to be ready WithBlock() dial option is deprecated, recommendation is to let the caller handle failures with retry see[1] this change is needed to sort out lint issues in ci. [1] https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md#especially-bad-using-deprecated-dialoptions Signed-off-by: adrianc --- pkg/resources/server.go | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/pkg/resources/server.go b/pkg/resources/server.go index 4891f0941..6b3015a0e 100644 --- a/pkg/resources/server.go +++ b/pkg/resources/server.go @@ -49,9 +49,8 @@ type resourceServer struct { } const ( - rsWatchInterval = 5 * time.Second - serverStartTimeout = 5 * time.Second - unix = "unix" + rsWatchInterval = 5 * time.Second + unix = "unix" ) // NewResourceServer returns an instance of ResourceServer @@ -265,6 +264,7 @@ func (rs *resourceServer) Start() error { } pluginapi.RegisterDevicePluginServer(rs.grpcServer, rs) + // start serving from grpcServeer go func() { err := rs.grpcServer.Serve(lis) if err != nil { @@ -272,31 +272,6 @@ func (rs *resourceServer) Start() error { } }() - conn, err := grpc.NewClient( - unix+":"+rs.sockPath, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) - if err != nil { - glog.Errorf("error. unable to create grpc client for test connection with %s gRPC server: %v", resourceName, err) - return err - } - - // Wait for server to start by launching a blocking connection - connChan := make(chan interface{}, 1) - go func() { - conn.Connect() - connChan <- true - }() - - ctx, cancel := context.WithTimeout(context.TODO(), serverStartTimeout) - defer cancel() - select { - case <-ctx.Done(): - glog.Errorf("error. unable to establish test connection with %s gRPC server: %v", resourceName, err) - conn.Close() - return err - case <-connChan: - glog.Infof("%s device plugin endpoint started serving", resourceName) - } - rs.triggerUpdate() if !rs.pluginWatch {