Skip to content

internal/cri/server/events: use testing/synctest - #13997

Merged
mxpv merged 1 commit into
containerd:mainfrom
thaJeztah:rm_fakeclock
Aug 20, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
thaJeztah:rm_fakeclock

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

stdlib can now handle this, without the need of the fakeclock utility.

Copilot AI lite review requested due to automatic review settings August 20, 2026 18:01
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Aug 20, 2026
Comment thread internal/cri/server/events/events.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/clock usage from internal/cri/server/events backoff implementation in favor of direct time usage.
  • Update internal/cri/server/events tests to use testing/synctest instead of k8s.io/utils/clock/testing.
  • Drop the vendored k8s.io/utils/clock/testing package 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]>
Copilot AI review requested due to automatic review settings August 20, 2026 19:16
@thaJeztah

Copy link
Copy Markdown
Member Author

(I put back the comments in the last push)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Equal arguments are reversed (expected vs actual). Swap them (or use assert.True) so failures report correctly.
				assert.Equal(t, actual.isInBackOff(key), true)

internal/cri/server/events/events_test.go:126

  • assert.Equal arguments are reversed (expected vs actual). Swap them (or use assert.False) so failures report correctly.
		assert.Equal(t, actual.isInBackOff(notExistKey), false)

internal/cri/server/events/events_test.go:151

  • assert.Equal arguments are reversed (expected vs actual). expect is 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.Equal arguments are reversed (expected vs actual). Put expQueue first so the assertion reports expected/actual correctly on failure.
			assert.Equal(t, actQueue, expQueue)

internal/cri/server/events/events_test.go:110

  • assert.Equal arguments 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)

@mxpv mxpv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Aug 20, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 20, 2026
@thaJeztah

Copy link
Copy Markdown
Member Author

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)

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well.. thx

@mikebrow

mikebrow commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

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..

Merged via the queue into containerd:main with commit 4e78194 Aug 20, 2026
89 of 90 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Aug 20, 2026
@thaJeztah
thaJeztah deleted the rm_fakeclock branch August 21, 2026 08:14
@thaJeztah

Copy link
Copy Markdown
Member Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants