Skip to content

Commit 5b1b0f8

Browse files
authored
pg-sidecar-service: minor error handling fixes, new build (#1122)
This fixes some uses of logrus.Fatal inside a function that returns an error to its caller. But, this also has the side-effect of rebuilding the package. We haven't shipped pg-sidecar-service in a while. Because of the bug fixed in #1111 we think that many installations likely have a small problem where not all of pg-sidecar-service's dependencies are installed. Shipping a new version will fix since the update dependencies will get installed on upgrade. Signed-off-by: Steven Danna <[email protected]>
1 parent 70dfc30 commit 5b1b0f8

File tree

2 files changed

+6
-11
lines changed
  • components/pg-sidecar-service

2 files changed

+6
-11
lines changed

components/pg-sidecar-service/cmd/pg-sidecar-service/commands/serve.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package commands
22

33
import (
44
"context"
5-
"os"
65

76
"github.com/pkg/errors"
87
log "github.com/sirupsen/logrus"
@@ -29,7 +28,7 @@ var serveCmd = &cobra.Command{
2928
*/
3029

3130
if err = server.StartGRPC(context.Background(), conf); err != nil {
32-
os.Exit(1)
31+
log.Fatal(err)
3332
}
3433
},
3534
}

components/pg-sidecar-service/pkg/server/server.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os/signal"
99
"syscall"
1010

11+
"github.com/pkg/errors"
1112
"github.com/sirupsen/logrus"
1213
"google.golang.org/grpc/codes"
1314
"google.golang.org/grpc/reflection"
@@ -27,20 +28,17 @@ import (
2728
func StartGRPC(ctx context.Context, cfg *Config) error {
2829
tlsOpts, err := cfg.ReadCerts()
2930
if err != nil {
30-
logrus.WithError(err).Fatal("failed to load SSL key/cert files")
31-
return err
31+
return errors.Wrap(err, "failed to load SSL key/cert files")
3232
}
3333

3434
platformConfig, err := platform.ConfigFromEnvironment()
3535
if err != nil {
36-
logrus.WithError(err).Fatal("failed to load platform config")
37-
return err
36+
return errors.Wrap(err, "failed to load platform config")
3837
}
3938

4039
listener, err := net.Listen("tcp", cfg.ListenAddress())
4140
if err != nil {
42-
logrus.WithError(err).Fatalf("failed to listen on address %s", cfg.ListenAddress())
43-
return err
41+
return errors.Wrapf(err, "failed to listen on address %s", cfg.ListenAddress())
4442
}
4543

4644
connFactory := secureconn.NewFactory(*tlsOpts, secureconn.WithVersionInfo(
@@ -75,9 +73,7 @@ func StartGRPC(ctx context.Context, cfg *Config) error {
7573
os.Exit(0)
7674
}()
7775

78-
grpcServer.Serve(listener)
79-
80-
return nil
76+
return grpcServer.Serve(listener)
8177
}
8278

8379
// PGSidecarServerOpt is a functional option for configuring the PGSidecarServer

0 commit comments

Comments
 (0)