Skip to content

first success path test for NRI integration tests#2071

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
SergeyKanzhelev:nri-integration-tests-smoke
May 19, 2026
Merged

first success path test for NRI integration tests#2071
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
SergeyKanzhelev:nri-integration-tests-smoke

Conversation

@SergeyKanzhelev

Copy link
Copy Markdown
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

This is the initial framework from #2069

Related to: #2046

The critest now allow to validate the NRI callbacks sequence and node lifecycle in relation with the CRI API.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 7, 2026
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 7, 2026
@SergeyKanzhelev

Copy link
Copy Markdown
Member Author

@haircommander this is the framework with a single smoke test

@SergeyKanzhelev

Copy link
Copy Markdown
Member Author

to simplify the review here are snippets from CI execution:

CRI-O: https://github.com/kubernetes-sigs/cri-tools/actions/runs/25518494319/job/74895989859?pr=2071

[k8s.io] NRI runtime should invoke NRI RunPodSandbox hook on pod creation should receive RunPodSandbox event when a pod is created via CRI [Serial]
sigs.k8s.io/cri-tools/pkg/validate/nri_linux.go:71

  Captured StdOut/StdErr Output >>
  time="2026-05-07T19:53:13Z" level=info msg="Created plugin 00-cri-test-nri (critest-NWQVggOOJB.test, handles RunPodSandbox,StopPodSandbox,RemovePodSandbox,CreateContainer,StartContainer,StopContainer,RemoveContainer)"
  time="2026-05-07T19:53:13Z" level=info msg="Registering plugin 00-cri-test-nri using NRI version 0.0.0-unknown..."
  time="2026-05-07T19:53:13Z" level=info msg="Configuring plugin 00-cri-test-nri for runtime cri-o/1.36.0 (NRI version )..."
  time="2026-05-07T19:53:13Z" level=warning msg="failed to infer runtime NRI version: failed to find latest version for \"1.36.0\""
  time="2026-05-07T19:53:13Z" level=info msg="Started plugin 00-cri-test-nri..."
  time="2026-05-07T19:53:14Z" level=info msg="Stopping plugin 00-cri-test-nri..."
  << Captured StdOut/StdErr Output

  Timeline >>
  STEP: creating a pod sandbox @ 05/07/26 19:53:13.568
  STEP: waiting for RunPodSandbox NRI event @ 05/07/26 19:53:13.664
  STEP: stop PodSandbox @ 05/07/26 19:53:13.664
  STEP: remove PodSandbox @ 05/07/26 19:53:14.038
  << Timeline
------------------------------
• [1.609 seconds]

Containerd:

[k8s.io] NRI runtime should invoke NRI RunPodSandbox hook on pod creation should receive RunPodSandbox event when a pod is created via CRI [Serial]
sigs.k8s.io/cri-tools/pkg/validate/nri_linux.go:71

  Captured StdOut/StdErr Output >>
  time="2026-05-07T19:54:28Z" level=info msg="Created plugin 00-cri-test-nri (critest-AoLvdKBkym.test, handles RunPodSandbox,StopPodSandbox,RemovePodSandbox,CreateContainer,StartContainer,StopContainer,RemoveContainer)"
  time="2026-05-07T19:54:28Z" level=info msg="Registering plugin 00-cri-test-nri using NRI version 0.0.0-unknown..."
  time="2026-05-07T19:54:28Z" level=info msg="Configuring plugin 00-cri-test-nri for runtime containerd/2976f38 (NRI version v0.12.0)..."
  time="2026-05-07T19:54:28Z" level=info msg="Started plugin 00-cri-test-nri..."
  time="2026-05-07T19:54:29Z" level=info msg="Stopping plugin 00-cri-test-nri..."
  << Captured StdOut/StdErr Output

  Timeline >>
  STEP: creating a pod sandbox @ 05/07/26 19:54:28.801
  STEP: waiting for RunPodSandbox NRI event @ 05/07/26 19:54:28.88
  STEP: stop PodSandbox @ 05/07/26 19:54:28.88
  STEP: remove PodSandbox @ 05/07/26 19:54:29.005
  << Timeline
------------------------------
• [1.273 seconds]

@SergeyKanzhelev
SergeyKanzhelev force-pushed the nri-integration-tests-smoke branch 2 times, most recently from 8c1493d to 7107aca Compare May 17, 2026 04:26
@SergeyKanzhelev SergeyKanzhelev changed the title smoke test for NRI integration tests first success path test for NRI integration tests May 17, 2026
@SergeyKanzhelev

Copy link
Copy Markdown
Member Author

@haircommander @saschagrunert @samuelkarp can you please review this? Let's merge a simple test and handle more complex use cases one by one

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

Overall design is solid: an in-process NRI stub that registers as a plugin, records events, and validates ordering. The test is well-structured and the CI integration covers both containerd and CRI-O. A few comments inline.

Comment thread pkg/validate/nri_util_linux.go Outdated
Comment thread pkg/validate/nri_util_linux.go
Comment thread pkg/validate/nri_util_linux.go Outdated
}

p.mu.Unlock()
time.Sleep(50 * time.Millisecond)

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.

nit: Both WaitForEvent and WaitForEventCount use time.Sleep(50ms) polling loops. A sync.Cond broadcast from recordPodEvent/recordContainerEvent would be more idiomatic, avoid the latency/CPU tradeoff, and scale better as more tests use this framework.

Not a blocker, but worth considering since this is reusable test infrastructure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With sync.Cond, we will need a goroutine to cancel by timeout, right? I can do channel instead, but not sure it worth it

Comment thread pkg/validate/nri_util_linux.go Outdated
Comment thread pkg/validate/nri_linux.go Outdated
- name: Configure NRI for CRI-O
run: |
sudo mkdir -p /var/run/nri /opt/nri/plugins
sudo tee /etc/crio/crio.conf.d/05-nri.conf <<EOF

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.

nit: The heredoc body is indented to match the YAML nesting level, so the leading whitespace ends up in the actual TOML file written to /etc/crio/crio.conf.d/05-nri.conf. CRI-O's parser tolerates this, but it's a bit fragile. Unindenting the heredoc body or using <<-EOF with tabs would be cleaner.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought yaml will remove all whitespaces. Also those are whitespaces, I looked at <<-EOF and it removes tabs.

The CI shows no 9 whitespaces, I cannot tell if those two are definitely a log formatting, but it sure looks like it:

Image

Comment thread pkg/validate/nri_linux.go Outdated
@SergeyKanzhelev
SergeyKanzhelev force-pushed the nri-integration-tests-smoke branch from 7107aca to d402009 Compare May 19, 2026 07:46
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 19, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: saschagrunert, SergeyKanzhelev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [SergeyKanzhelev,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
k8s-ci-robot merged commit 3a77a80 into kubernetes-sigs:master May 19, 2026
31 checks passed
SergeyKanzhelev added a commit to AIAgentSandox/cri-tools that referenced this pull request May 23, 2026
Extract the "RunPodSandbox state contract and blocking behavior" Context
from PR kubernetes-sigs#2069 into the NRI validation suite. The block adds two specs:

1. The sandbox is not exposed via List/Status while the RunPodSandbox NRI
   hook is in progress, and becomes Ready once the hook returns.
2. RunPodSandbox is gated by the hook completion, so workload container
   creation cannot proceed until the hook releases.

Also adds the supporting NRITestPlugin.Reset and
NRITestPlugin.LastRunPodSandboxID helpers, and resets recorded events on
NRITestStub.Cleanup so the new AfterEach can recover the sandbox ID when
a test fails before capturing it from the CRI call.

Following the styling feedback from PR kubernetes-sigs#2071, cleanup errors are logged
through framework.Logf rather than silenced.
SergeyKanzhelev added a commit to AIAgentSandox/cri-tools that referenced this pull request May 23, 2026
Extract the "RunPodSandbox state contract and blocking behavior" Context
from PR kubernetes-sigs#2069 into the NRI validation suite. The block adds two specs:

1. The sandbox is not exposed via List/Status while the RunPodSandbox NRI
   hook is in progress, and becomes Ready once the hook returns.
2. RunPodSandbox is gated by the hook completion, so workload container
   creation cannot proceed until the hook releases.

Also adds the supporting NRITestPlugin.Reset and
NRITestPlugin.LastRunPodSandboxID helpers, and resets recorded events on
NRITestStub.Cleanup so the new AfterEach can recover the sandbox ID when
a test fails before capturing it from the CRI call.

Following the styling feedback from PR kubernetes-sigs#2071, cleanup errors are logged
through framework.Logf rather than silenced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants