File tree Expand file tree Collapse file tree 6 files changed +15
-29
lines changed
Expand file tree Collapse file tree 6 files changed +15
-29
lines changed Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "context"
5+ "errors"
46 "fmt"
57 "os"
68
79 "github.com/cloudnative-pg/machinery/pkg/log"
810 "github.com/spf13/cobra"
11+ ctrl "sigs.k8s.io/controller-runtime"
912
1013 "github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/instance"
1114 "github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/operator"
@@ -30,8 +33,10 @@ func main() {
3033 rootCmd .AddCommand (operator .NewCmd ())
3134 rootCmd .AddCommand (restore .NewCmd ())
3235
33- if err := rootCmd .Execute (); err != nil {
34- fmt .Println (err )
35- os .Exit (1 )
36+ if err := rootCmd .ExecuteContext (ctrl .SetupSignalHandler ()); err != nil {
37+ if ! errors .Is (err , context .Canceled ) {
38+ fmt .Println (err )
39+ os .Exit (1 )
40+ }
3641 }
3742}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ require (
99 github.com/cloudnative-pg/barman-cloud v0.0.0-20241105055149-ae6c2408bd14
1010 github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241113134512-8608232c2813
1111 github.com/cloudnative-pg/cnpg-i v0.0.0-20241109002750-8abd359df734
12- github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241030141108-7e59fc9f4797
12+ github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241129144432-bd94f16685d3
1313 github.com/cloudnative-pg/machinery v0.0.0-20241105070525-042a028b767c
1414 github.com/docker/docker v27.3.1+incompatible
1515 github.com/onsi/ginkgo/v2 v2.21.0
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241113134512-8608232c2813 h
3232github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241113134512-8608232c2813 /go.mod h1:f4hObdRVoQtMmVtWqZ6VDZBrI6ok9Td/UMhojQ+EPmk =
3333github.com/cloudnative-pg/cnpg-i v0.0.0-20241109002750-8abd359df734 h1:4jq/FUrlAKxu0Kw9PL5lj5Njq8pAnmUpP/kXKOrJAaE =
3434github.com/cloudnative-pg/cnpg-i v0.0.0-20241109002750-8abd359df734 /go.mod h1:3U7miYasKr2rYCQzrn/IvbSQc0OpYF8ieZt2FKG4nv0 =
35- github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241030141108-7e59fc9f4797 h1:8iaPgTx16yzx8rrhOi99u+GWGp47kqveF9NShElsYKM =
36- github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241030141108-7e59fc9f4797 /go.mod h1:X6r1fRuUEIAv4+5SSBY2RmQ201K6GcptOXgnmaX/8tY =
35+ github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241129144432-bd94f16685d3 h1:hKTlmgyOq5ZS7t1eVa4SY1hH361gZ7VIb0an+BH9rJs =
36+ github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241129144432-bd94f16685d3 /go.mod h1:X6r1fRuUEIAv4+5SSBY2RmQ201K6GcptOXgnmaX/8tY =
3737github.com/cloudnative-pg/machinery v0.0.0-20241105070525-042a028b767c h1:t0RBU2gBiwJQ9XGeXlHPBYpsTscSKHgB5TfcWaiwanc =
3838github.com/cloudnative-pg/machinery v0.0.0-20241105070525-042a028b767c /go.mod h1:uBHGRIk5rt07mO4zjIC1uvGBWTH6PqIiD1PfpvPGZKU =
3939github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I =
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ package instance
22
33import (
44 "context"
5- "errors"
6- "os"
75 "path"
86
97 cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
@@ -67,7 +65,7 @@ func Start(ctx context.Context) error {
6765 })
6866 if err != nil {
6967 setupLog .Error (err , "unable to start manager" )
70- os . Exit ( 1 )
68+ return err
7169 }
7270
7371 barmanObjectKey := client.ObjectKey {
@@ -94,12 +92,7 @@ func Start(ctx context.Context) error {
9492 return err
9593 }
9694
97- if err := mgr .Start (ctrl .SetupSignalHandler ()); err != nil {
98- if errors .Is (err , context .Canceled ) {
99- return nil
100- }
101-
102- setupLog .Error (err , "problem running manager" )
95+ if err := mgr .Start (ctx ); err != nil {
10396 return err
10497 }
10598
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ package operator
1919import (
2020 "context"
2121 "crypto/tls"
22- "errors"
2322
2423 // +kubebuilder:scaffold:imports
2524 cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
@@ -156,11 +155,6 @@ func Start(ctx context.Context) error {
156155
157156 setupLog .Info ("starting manager" )
158157 if err := mgr .Start (ctx ); err != nil {
159- if errors .Is (err , context .Canceled ) {
160- return nil
161- }
162-
163- setupLog .Error (err , "problem running manager" )
164158 return err
165159 }
166160
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ package restore
22
33import (
44 "context"
5- "errors"
6- "os"
75
86 cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
97 "github.com/spf13/viper"
@@ -70,7 +68,7 @@ func Start(ctx context.Context) error {
7068 })
7169 if err != nil {
7270 setupLog .Error (err , "unable to start manager" )
73- os . Exit ( 1 )
71+ return err
7472 }
7573
7674 if err := mgr .Add (& CNPGI {
@@ -93,11 +91,7 @@ func Start(ctx context.Context) error {
9391 return err
9492 }
9593
96- if err := mgr .Start (ctrl .SetupSignalHandler ()); err != nil {
97- if errors .Is (err , context .Canceled ) {
98- return nil
99- }
100- setupLog .Error (err , "problem running manager" )
94+ if err := mgr .Start (ctx ); err != nil {
10195 return err
10296 }
10397
You can’t perform that action at this time.
0 commit comments