explain cause of context cancelation
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.
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 https://github.com/kubernetes/kubernetes/pull/122481 is some code that I wrote for this, feel free to copy whatever you find useful.
arlight this is on master now