From bce3e4167af0642f5690f0b23150877d76ccc867 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 --- 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 a39e27516..79f0b3110 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -78,11 +78,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) {