Skip to content

Commit 4d23895

Browse files
committed
envtest: disable controller metrics in tests
to mitigate spurious errors with: E0515 15:28:06.626887 1995892 listener.go:48] "controller-runtime/metrics: metrics server failed to listen. You may want to disable the metrics server or use another port if it is due to conflicts" err="error lis tening on :8080: listen tcp :8080: bind: address already in use" disable metrics completely. Moreover, check for error value from NewManager() before proceeding with the tests to avoid crashes. This makes envtest more robust but the up()/down() logic needs careful review to ensure there are no race conditions. Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
1 parent d90aeda commit 4d23895

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/envtest/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import (
5656
var (
5757
cfg *rest.Config
5858
k8sClient client.Client
59-
k8sManager ctrl.Manager
6059
testEnv *envtest.Environment
6160
ctx context.Context
6261
cancel context.CancelFunc
@@ -108,7 +107,8 @@ var _ = AfterEach(func() {
108107
})
109108

110109
func up() {
111-
k8sManager, _ = ctrl.NewManager(cfg, ctrl.Options{Scheme: scheme.Scheme})
110+
k8sManager, managerErr := ctrl.NewManager(cfg, ctrl.Options{Scheme: scheme.Scheme, MetricsBindAddress: "0"})
111+
Expect(managerErr).To(BeNil())
112112

113113
withWebhook := true
114114

0 commit comments

Comments
 (0)