File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
pkg/internal/testing/controlplane Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,18 @@ type ControlPlane struct {
47
47
}
48
48
49
49
// Start will start your control plane processes. To stop them, call Stop().
50
- func (f * ControlPlane ) Start () error {
50
+ func (f * ControlPlane ) Start () ( retErr error ) {
51
51
if f .Etcd == nil {
52
52
f .Etcd = & Etcd {}
53
53
}
54
54
if err := f .Etcd .Start (); err != nil {
55
55
return err
56
56
}
57
+ defer func () {
58
+ if retErr != nil {
59
+ _ = f .Etcd .Stop ()
60
+ }
61
+ }()
57
62
58
63
if f .APIServer == nil {
59
64
f .APIServer = & APIServer {}
@@ -62,6 +67,11 @@ func (f *ControlPlane) Start() error {
62
67
if err := f .APIServer .Start (); err != nil {
63
68
return err
64
69
}
70
+ defer func () {
71
+ if retErr != nil {
72
+ _ = f .APIServer .Stop ()
73
+ }
74
+ }()
65
75
66
76
// provision the default user -- can be removed when the related
67
77
// methods are removed. The default user has admin permissions to
@@ -88,6 +98,7 @@ func (f *ControlPlane) Stop() error {
88
98
errList = append (errList , err )
89
99
}
90
100
}
101
+
91
102
if f .Etcd != nil {
92
103
if err := f .Etcd .Stop (); err != nil {
93
104
errList = append (errList , err )
You can’t perform that action at this time.
0 commit comments