Skip to content

Commit

Permalink
RHOAIENG-15772: tests(odh-nbc): wait for controller manager to stop b…
Browse files Browse the repository at this point in the history
…efore stopping envtest

Otherwise, there will be some errors printed in the output.
It was not breaking anything, but it was unpleasant to look at.

The notebook-controller does not seem to be suffering from this.
Probably because it does not use a webhook.

Example of the error message that's prevented by this

```
2024-11-17T20:19:57+01:00       ERROR   controller-runtime.certwatcher  error re-reading certificate    {"error": "open /var/folders/f1/3m518k5d34l72v_9nqyjzqm80000gn/T/envtest-serving-certs-737480808/tls.crt: no such file or directory"}
```
  • Loading branch information
jiridanek committed Nov 17, 2024
1 parent e7980b1 commit 9bd3741
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/odh-notebook-controller/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ import (
// +kubebuilder:docs-gen:collapse=Imports

var (
cfg *rest.Config
cli client.Client
envTest *envtest.Environment
cfg *rest.Config

Check failure on line 58 in components/odh-notebook-controller/controllers/suite_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint (components/odh-notebook-controller)

var `cfg` is unused (unused)
cli client.Client
envTest *envtest.Environment

ctx context.Context
cancel context.CancelFunc
managerStopped = make(chan struct{})

testNamespaces = []string{}
)

Expand All @@ -74,7 +77,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
ctx, cancel = context.WithCancel(context.TODO())
ctx, cancel = context.WithCancel(context.Background())

// Initialize logger
opts := zap.Options{
Expand Down Expand Up @@ -156,6 +159,7 @@ var _ = BeforeSuite(func() {
go func() {
defer GinkgoRecover()
err = mgr.Start(ctx)
managerStopped <- struct{}{}
Expect(err).ToNot(HaveOccurred(), "Failed to run manager")
}()

Expand Down Expand Up @@ -187,7 +191,10 @@ var _ = BeforeSuite(func() {
}, 60)

var _ = AfterSuite(func() {
By("Stopping the manager")
cancel()
<-managerStopped // Issue#429: waiting to avoid shutdown errors being logged

By("Tearing down the test environment")
// TODO: Stop cert controller-runtime.certwatcher before manager
err := envTest.Stop()
Expand Down

0 comments on commit 9bd3741

Please sign in to comment.