From dd9dcba9258125473d7b3be2befd5490c1f9ae0f Mon Sep 17 00:00:00 2001 From: Phan Le Date: Thu, 12 Sep 2024 16:20:54 -0700 Subject: [PATCH] nit(refactor): remove the unnecessary for loop longhorn-9438 Signed-off-by: Phan Le (cherry picked from commit 00a5464f047c5db178433bda6746daff5333682b) --- pkg/disk/disk.go | 7 ++----- pkg/instance/instance.go | 7 ++----- pkg/proxy/proxy.go | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pkg/disk/disk.go b/pkg/disk/disk.go index aae4a0cca..95c218e1d 100644 --- a/pkg/disk/disk.go +++ b/pkg/disk/disk.go @@ -85,11 +85,8 @@ func NewServer(ctx context.Context, spdkEnabled bool, spdkServiceAddress string) } func (s *Server) startMonitoring() { - for { - <-s.ctx.Done() - logrus.Infof("%s: stopped monitoring due to the context done", types.DiskGrpcService) - break - } + <-s.ctx.Done() + logrus.Infof("%s: stopped monitoring due to the context done", types.DiskGrpcService) } func (s *Server) VersionGet(ctx context.Context, req *emptypb.Empty) (*rpc.DiskVersionResponse, error) { diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 069a4297f..a22d65647 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -87,11 +87,8 @@ func NewServer(ctx context.Context, logsDir, processManagerServiceAddress, spdkS } func (s *Server) startMonitoring() { - for { - <-s.ctx.Done() - logrus.Infof("%s: stopped monitoring due to the context done", types.InstanceGrpcService) - break - } + <-s.ctx.Done() + logrus.Infof("%s: stopped monitoring due to the context done", types.InstanceGrpcService) } func (s *Server) VersionGet(ctx context.Context, req *emptypb.Empty) (*rpc.VersionResponse, error) { diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 98989b8d8..4d3089fa3 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -79,11 +79,8 @@ func NewProxy(ctx context.Context, logsDir, diskServiceAddress, spdkServiceAddre } func (p *Proxy) startMonitoring() { - for { - <-p.ctx.Done() - logrus.Infof("%s: stopped monitoring due to the context done", types.ProxyGRPCService) - break - } + <-p.ctx.Done() + logrus.Infof("%s: stopped monitoring due to the context done", types.ProxyGRPCService) } func (p *Proxy) ServerVersionGet(ctx context.Context, req *rpc.ProxyEngineRequest) (resp *rpc.EngineVersionProxyResponse, err error) {