kubernetes-sigs/kubebuilder

Generated controller suitetest template does not cancel context

abenn135 opened this issue · 1 comments

What broke? What's expected?

Hi!

While following the tutorial, I generated a new controller, then went to run foo_controller_test.go. However, I got the error "Timeout waiting for process kube-apiserver to stop" in the tear down phase.

After a bit of head-scratching and searching, I found #2379, which fixes the tutorial instructions, but not the generated code itself.

I'd propose fixing the generated suite_test.go file, which I think is generated from the template at

var _ = AfterSuite(func() {
By("tearing down the test environment")
err := testEnv.Stop()
Expect(err).NotTo(HaveOccurred())
})

All that needs to happen is to add cancel() to the AfterSuite lambda.

Happy to contribute the fix!

Reproducing this issue

No response

KubeBuilder (CLI) Version

Version: main.version{KubeBuilderVersion:"4.0.0", KubernetesVendor:"1.27.1", GitCommit:"6c08ed1db5804042509a360edd971ebdc4ae04d8", BuildDate:"2024-05-24T08:36:23Z", GoOs:"linux", GoArch:"amd64"}

PROJECT version

"3"

Plugin versions

- go.kubebuilder.io/v4

Other versions

  • go version go1.22.5 linux/amd64
  • sigs.k8s.io/controller-runtime v0.18.2
  • kubectl: Client Version: v1.30.2
  • Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
  • Server Version: v1.30.0

Extra Labels

No response

Hi @abenn135,

Thank you for raise this one and your willing to contribute !

Please, feel free to open a PR with your suggestion
See that you will need to: