-
Notifications
You must be signed in to change notification settings - Fork 305
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
Use testing.TB.Context() instead of context.Background() #4754
Conversation
Hi @Horiodino. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
/ok-to-test |
9be1959
to
d7cd901
Compare
pkg/controller/admissionchecks/multikueue/multikueuecluster_test.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update it here as well?
kueue/pkg/util/testing/context.go
Line 32 in 76352d7
return ctrl.LoggerInto(context.Background(), logger), logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For follow up we need to update integration and e2e tests as well.
E2E test? It's using Ginkgo |
Yeah. I think we can get context from |
Oh, I thought you were referring to using t.Context(). My bad! |
Yeah |
Signed-off-by: Horiodino <[email protected]> Using ctx.Background() cant parse nil. Signed-off-by: Horiodino <[email protected]> Remove unused context return value from getClientBuilder function Signed-off-by: Horiodino <[email protected]> Use ginkgo.GinkgoTB().Context() instead of context.Background() Signed-off-by: Horiodino <[email protected]>
@Horiodino try upgrading Ginkgo to v2.23.3. It looks like they fixed this bug. |
@@ -103,7 +105,7 @@ func main() { | |||
log.Info("Start runner", "outputDir", outputDir, "crdsPath", crdsPath) | |||
errCh := make(chan error, 3) | |||
wg := &sync.WaitGroup{} | |||
ctx, ctxCancel := context.WithCancel(ctrl.LoggerInto(context.Background(), log)) | |||
ctx, ctxCancel := context.WithCancel(ctrl.LoggerInto(ginkgo.GinkgoT().Context(), log)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here?
GinkgoTB().Context() is picking up a different instance of Context()—one that’s valid at compile time but panics at runtime due to the interface embedding. if you run
ginkgo version |
Signed-off-by: Horiodino <[email protected]>
It's very strange - locally, v2.23.3 works fine with ginkgo.GinkgoTB(). But okay, ginkgo.GinkgoT() is good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Awesome! Thank you so much!
LGTM label has been added. Git tree hash: 3e5c2c38a5c675b3ce77eb4e34d08230eda9c675
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Horiodino, mbobrovskyi, mimowo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Go 1.24, testing.TB.Context(t) is supported, allowing us to replace all instances of context.Background() in tests
Which issue(s) this PR fixes:
Fixes #4655 (comment)
Special notes for your reviewer:
Does this PR introduce a user-facing change?