Repository navigation
internal/cri/server/events: use testing/synctest - #13997
Conversation
There was a problem hiding this comment.
Pull request overview
Replaces the CRI events backoff tests’ dependency on Kubernetes’ vendored fake clock utilities with Go’s standard-library testing/synctest, and removes the now-unused vendored clock-testing code.
Changes:
- Remove
k8s.io/utils/clockusage frominternal/cri/server/eventsbackoff implementation in favor of directtimeusage. - Update
internal/cri/server/eventstests to usetesting/synctestinstead ofk8s.io/utils/clock/testing. - Drop the vendored
k8s.io/utils/clock/testingpackage entries/files that are no longer referenced.
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vendor/modules.txt | Removes the vendored k8s.io/utils/clock/testing package entry. |
| vendor/k8s.io/utils/clock/testing/simple_interval_clock.go | Removes vendored clock-testing helper (no longer used). |
| vendor/k8s.io/utils/clock/testing/fake_clock.go | Removes vendored fake clock implementation (no longer used). |
| internal/cri/server/events/events.go | Removes injectable clock usage; uses time.Now() for backoff expiration. |
| internal/cri/server/events/events_test.go | Switches backoff unit test to testing/synctest and time.Sleep. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
stdlib can now handle this, without the need of the fakeclock utility. Signed-off-by: Sebastiaan van Stijn <[email protected]>
b7bc1f4 to
f7e8f30
Compare
|
(I put back the comments in the last push) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (5)
internal/cri/server/events/events_test.go:120
assert.Equalarguments are reversed (expected vs actual). Swap them (or useassert.True) so failures report correctly.
assert.Equal(t, actual.isInBackOff(key), true)
internal/cri/server/events/events_test.go:126
assert.Equalarguments are reversed (expected vs actual). Swap them (or useassert.False) so failures report correctly.
assert.Equal(t, actual.isInBackOff(notExistKey), false)
internal/cri/server/events/events_test.go:151
assert.Equalarguments are reversed (expected vs actual).expectis the expected value here; put it first so diffs in failure output are correct.
assert.Equal(t, actQueue, expect)
internal/cri/server/events/events_test.go:165
assert.Equalarguments are reversed (expected vs actual). PutexpQueuefirst so the assertion reports expected/actual correctly on failure.
assert.Equal(t, actQueue, expQueue)
internal/cri/server/events/events_test.go:110
assert.Equalarguments are reversed here (expected vs actual). This makes failure output confusing and is inconsistent with other uses in this file (e.g., internal/cri/server/events/events_test.go:54).
This issue also appears in the following locations of the same file:
- line 120
- line 126
- line 151
- line 165
assert.Equal(t, actual.queuePool, expectedQueues)
|
Thx! I wondered what containerd needed the k8s utils for (I found it in places before where it was not needed) and recalled "stdlib now has options for this!" One more place where k8s utils are used, and probably I can remove that as well (I may push a PR tomorrow) |
before we moved the cri streaming code out of kubernetes/kubelet into staging, and before we made the decision to ship a version of containerd syncing with kubernetes each kubernetes release cycle, because of the k8s feature of moving golang min to latest each k8s release cycle, we were going with removing one k8s internal vendor packages at a time.. |
Yup! On that matter; I may have a look at opening a PR in the cri-streaming repository as well (if I have time) |
stdlib can now handle this, without the need of the fakeclock utility.