File tree Expand file tree Collapse file tree 6 files changed +15
-15
lines changed Expand file tree Collapse file tree 6 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "context"
5
+ "errors"
4
6
"fmt"
5
7
"os"
6
8
7
9
"github.com/cloudnative-pg/machinery/pkg/log"
8
10
"github.com/spf13/cobra"
11
+ ctrl "sigs.k8s.io/controller-runtime"
9
12
10
13
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/instance"
11
14
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cmd/operator"
@@ -30,8 +33,10 @@ func main() {
30
33
rootCmd .AddCommand (operator .NewCmd ())
31
34
rootCmd .AddCommand (restore .NewCmd ())
32
35
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
+ }
36
41
}
37
42
}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ require (
9
9
github.com/cloudnative-pg/barman-cloud v0.0.0-20241105055149-ae6c2408bd14
10
10
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241113134512-8608232c2813
11
11
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
13
13
github.com/cloudnative-pg/machinery v0.0.0-20241105070525-042a028b767c
14
14
github.com/docker/docker v27.3.1+incompatible
15
15
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
32
32
github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241113134512-8608232c2813 /go.mod h1:f4hObdRVoQtMmVtWqZ6VDZBrI6ok9Td/UMhojQ+EPmk =
33
33
github.com/cloudnative-pg/cnpg-i v0.0.0-20241109002750-8abd359df734 h1:4jq/FUrlAKxu0Kw9PL5lj5Njq8pAnmUpP/kXKOrJAaE =
34
34
github.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 =
37
37
github.com/cloudnative-pg/machinery v0.0.0-20241105070525-042a028b767c h1:t0RBU2gBiwJQ9XGeXlHPBYpsTscSKHgB5TfcWaiwanc =
38
38
github.com/cloudnative-pg/machinery v0.0.0-20241105070525-042a028b767c /go.mod h1:uBHGRIk5rt07mO4zjIC1uvGBWTH6PqIiD1PfpvPGZKU =
39
39
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I =
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package instance
2
2
3
3
import (
4
4
"context"
5
- "os"
6
5
"path"
7
6
8
7
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
@@ -66,7 +65,7 @@ func Start(ctx context.Context) error {
66
65
})
67
66
if err != nil {
68
67
setupLog .Error (err , "unable to start manager" )
69
- os . Exit ( 1 )
68
+ return err
70
69
}
71
70
72
71
barmanObjectKey := client.ObjectKey {
@@ -93,8 +92,7 @@ func Start(ctx context.Context) error {
93
92
return err
94
93
}
95
94
96
- if err := mgr .Start (ctrl .SetupSignalHandler ()); err != nil {
97
- setupLog .Error (err , "problem running manager" )
95
+ if err := mgr .Start (ctx ); err != nil {
98
96
return err
99
97
}
100
98
Original file line number Diff line number Diff line change @@ -155,7 +155,6 @@ func Start(ctx context.Context) error {
155
155
156
156
setupLog .Info ("starting manager" )
157
157
if err := mgr .Start (ctx ); err != nil {
158
- setupLog .Error (err , "problem running manager" )
159
158
return err
160
159
}
161
160
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package restore
2
2
3
3
import (
4
4
"context"
5
- "os"
6
5
7
6
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
8
7
"github.com/spf13/viper"
@@ -69,7 +68,7 @@ func Start(ctx context.Context) error {
69
68
})
70
69
if err != nil {
71
70
setupLog .Error (err , "unable to start manager" )
72
- os . Exit ( 1 )
71
+ return err
73
72
}
74
73
75
74
if err := mgr .Add (& CNPGI {
@@ -92,8 +91,7 @@ func Start(ctx context.Context) error {
92
91
return err
93
92
}
94
93
95
- if err := mgr .Start (ctrl .SetupSignalHandler ()); err != nil {
96
- setupLog .Error (err , "problem running manager" )
94
+ if err := mgr .Start (ctx ); err != nil {
97
95
return err
98
96
}
99
97
You can’t perform that action at this time.
0 commit comments