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

explain cause of context cancelation #1326

Open
pohly opened this issue Jan 4, 2024 · 2 comments
Open

explain cause of context cancelation #1326

pohly opened this issue Jan 4, 2024 · 2 comments

Comments

@pohly
Copy link
Contributor

pohly commented Jan 4, 2024

The default "context canceled" is often not useful in a Ginkgo E2E suite. Was the context canceled because of some local, test-specific timeout? Was it explicitly canceled? Did the overall suite time out? What the heck are the timeouts in this particular job that is failing?

This can be addressed via context.WithCancelCause: whenever Ginkgo creates a context (whether it's for a timeout or cancelation), use context.WithCancelCause and provide a cause that contains the information that answers the questions above.

@pohly
Copy link
Contributor Author

pohly commented Jan 4, 2024

It is a bit annoying that Go doesn't properly support "cause" in all variants of the context.With* calls. As it stands now (Go 1.21), one has to re-implement context.WithTimeout to get a cause both when the timeout occurs and for early cancelation.

test/utils/ktesting/contexthelper.go from kubernetes/kubernetes#122481 is some code that I wrote for this, feel free to copy whatever you find useful.

@onsi
Copy link
Owner

onsi commented Jan 17, 2024

arlight this is on master now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants