Repository navigation
internal/cri/server: remove remaining uses of k8s.io/utils - #14003
Merged
Merged
Conversation
k8s.io/utils/exec.CodeExitError was the only remaining direct use of k8s.io/utils. Replace it with a local error type implementing the same interface. The streaming server uses this interface to distinguish commands terminating with a non-zero exit status from errors executing the command, and to propagate the exit status to the client. Add a FIXME to define this error contract in k8s.io/cri-streaming, where it is consumed, instead of requiring runtime implementations to implicitly match k8s.io/utils/exec.ExitError. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the last direct dependency of the CRI streaming runtime on k8s.io/utils/exec.CodeExitError by replacing it with a local error type that matches the exit-error interface expected by k8s.io/cri-streaming’s remotecommand.ServeExec.
Changes:
- Replaces
k8s.io/utils/exec.CodeExitErrorusage with a localcodeExitErrorthat implements the same exit-status contract. - Updates the streaming runtime’s
Execimplementation/comments to reflect the local exit-error type. - Moves
k8s.io/utilsfrom a direct to an indirect dependency ingo.mod.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/cri/server/streaming.go | Introduces a local exit-error interface + implementation and returns it from Exec on non-zero exit status. |
| go.mod | Removes the direct k8s.io/utils requirement (keeps it as indirect via transitive deps). |
Suppressed comments (1)
internal/cri/server/streaming.go:53
- This comment mentions “the upper bits of os.exec.ExitStatus”, but
os.execisn’t a Go package path and this implementation just stores the exit code provided by containerd. Suggest simplifying the wording to avoid incorrect stdlib references.
// codeExitError is an implementation of exitError consisting of an error object
// and an exit code (the upper bits of os.exec.ExitStatus).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mikebrow
approved these changes
Aug 21, 2026
fuweid
approved these changes
Aug 21, 2026
Member
Author
|
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
k8s.io/utils/exec.CodeExitError was the only remaining direct use of k8s.io/utils. Replace it with a local error type implementing the same interface. The streaming server uses this interface to distinguish commands terminating with a non-zero exit status from errors executing the command, and to propagate the exit status to the client.
Add a FIXME to define this error contract in k8s.io/cri-streaming, where it is consumed, instead of requiring runtime implementations to implicitly match k8s.io/utils/exec.ExitError.
☝️ for the above; currently the interface is defined in utils (producer side) https://github.com/kubernetes/utils/blob/28399d86e0b55e612b83ad94dc6bac8e5de2a5ac/exec/exec.go#L83-L91
But it should be defined on the receiver side, because that's where it's part of the contract;
https://github.com/kubernetes/cri-streaming/blob/v0.36.3/pkg/streaming/remotecommand/exec.go#L48-L64
That interface must be documented as part of the contract (to avoid a 500 internal server error for expected cases); the interface can be simplified to only the parts needed;
BUT! It ... could .. even be more elegant. Instead of defining a Kubernetes-specific
ExitStatus(), k8s.io/cri-streaming could define an interface stdlib:That interface would be satisfied by
*os/exec.ExitError(through*os.ProcessState), and implementations could just return a*exec.ExitErrordirectly without wrapping; and k8s.io/cri-streaming could have a small utility to match either; quick draw-up;And document it;