Skip to content

Commit 5cc2e8f

Browse files
akutzvincepri
authored andcommitted
Always shutdown etcd when stopping envtest
This patch fixes an issue that occurs when shutting down an envtest.Environment. If the API server fails to shutdown, then the etcd process is orphaned. This can result in dozens of running etcd processes when debugging failed tests. Please see this Slack discussion for more information: https://kubernetes.slack.com/archives/CAR30FCJZ/p1590779385006000.
1 parent 8402448 commit 5cc2e8f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/internal/testing/integration/control_plane.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/url"
66

77
"k8s.io/apimachinery/pkg/runtime/serializer"
8+
utilerrors "k8s.io/apimachinery/pkg/util/errors"
89
"k8s.io/client-go/kubernetes/scheme"
910
"k8s.io/client-go/rest"
1011

@@ -42,17 +43,20 @@ func (f *ControlPlane) Start() error {
4243

4344
// Stop will stop your control plane processes, and clean up their data.
4445
func (f *ControlPlane) Stop() error {
46+
var errList []error
47+
4548
if f.APIServer != nil {
4649
if err := f.APIServer.Stop(); err != nil {
47-
return err
50+
errList = append(errList, err)
4851
}
4952
}
5053
if f.Etcd != nil {
5154
if err := f.Etcd.Stop(); err != nil {
52-
return err
55+
errList = append(errList, err)
5356
}
5457
}
55-
return nil
58+
59+
return utilerrors.NewAggregate(errList)
5660
}
5761

5862
// APIURL returns the URL you should connect to to talk to your API.

0 commit comments

Comments
 (0)