Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Stefurishin <aleksandr.stefurishin@flant.com>
  • Loading branch information
astef committed Dec 28, 2024
1 parent a908a64 commit 713fff7
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions images/sds-local-volume-csi/src/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -147,18 +146,13 @@ func (d *Driver) Run(ctx context.Context) error {
d.ready = true
d.log.Info(fmt.Sprintf("grpc_addr %s http_addr %s starting server", grpcAddr, d.address))

var eg errgroup.Group
eg.Go(func() error {
go func() {
<-ctx.Done()
d.log.Info("server stopped")
d.readyMu.Lock()
d.ready = false
d.readyMu.Unlock()
d.srv.GracefulStop()
}()
return d.srv.Serve(grpcListener)
})

return eg.Wait()
go func() {
<-ctx.Done()
d.log.Info("server stopped")
d.readyMu.Lock()
d.ready = false
d.readyMu.Unlock()
d.srv.GracefulStop()
}()
return d.srv.Serve(grpcListener)
}

0 comments on commit 713fff7

Please sign in to comment.