Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"You won't need to touch these" in reference to AfterSuite in the cronjob-tutorial is misleading #3511

Closed
bobdoah opened this issue Jul 27, 2023 · 5 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@bobdoah
Copy link

bobdoah commented Jul 27, 2023

What broke? What's expected?

In the cronjob tutorial documentation it says:

Kubebuilder also generates boilerplate functions for cleaning up envtest and actually running your test files in your controllers/ directory. You won’t need to touch these.

and includes the following code sample:

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

but when you generated the code, what it actually looks like is:

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

the cancel() call needs to be added, or the kube-apiserver will not stop correctly.

The documentation misled me into thinking I didn't need to make a change. It was only on comparison with the kubebuilder book source I realised my mistake.

Reproducing this issue

No response

KubeBuilder (CLI) Version

Version: main.version{KubeBuilderVersion:"3.11.1", KubernetesVendor:"1.27.1", GitCommit:"1dc8ed95f7cc55fef3151f749d3d541bec3423c9", BuildDate:"2023-07-03T13:10:56Z", GoOs:"darwin", GoArch:"amd64"}

PROJECT version

3

Plugin versions

- go.kubebuilder.io/v4

Other versions

No response

Extra Labels

No response

@bobdoah bobdoah added the kind/bug Categorizes issue or PR as related to a bug. label Jul 27, 2023
@RakshitKumar04
Copy link

RakshitKumar04 commented Jul 28, 2023

/assign @RakshitKumar04

@RakshitKumar04
Copy link

Hey, @bobdoah should I make this change in every file containing this code?

@bobdoah
Copy link
Author

bobdoah commented Jul 31, 2023 via email

@RakshitKumar04
Copy link

@bobdoah So, should I reflect these changes in internal\controller suits_test.go and controllers suits_test.go

@camilamacedo86
Copy link
Member

camilamacedo86 commented Aug 26, 2023

hi @bobdoah @RakshitKumar04,

See: #3566 .
I was checking it out. However, seem that the cancel is applied/required only if we are creating a context with ctx, cancel = context.WithCancel(context.TODO()) . Therefore, if we do what is suggested here;

@bobdoah So, should I reflect these changes in internal\controller suits_test.go and controllers suits_test.go

it will fail you can check the CI tests.

In this I am closing this one. however, if you see that needs to be re-open please feel free. Also, fell free to push a PR with the changes.

Note that the docs are built from the default scaffolds and they are automatic updated by running make generate after your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
3 participants