Repository navigation
Handle []byte envvar value for CRI - #13453
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates CRI container creation to support environment variable values represented as []byte (instead of string), and aligns existing unit tests with the updated runtime.KeyValue shape.
Changes:
- Updated Linux/Windows/Darwin spec builders to convert env var values from
[]bytetostringwhen assembling OCI env entries. - Updated container creation test data on Linux/Windows/Other to use
[]byte(...)env values.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/cri/server/container_create.go | Converts runtime.KeyValue.Value bytes to string when building OCI env arrays across OS-specific spec builders. |
| internal/cri/server/container_create_linux_test.go | Adjusts test container config env values to []byte. |
| internal/cri/server/container_create_windows_test.go | Adjusts test container config env values to []byte. |
| internal/cri/server/container_create_other_test.go | Adjusts test container config env values to []byte. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
12bbf46 to
66f4cbc
Compare
|
(the vendor verification task of the "Project Checks" CI is expected to fail since this is monkeying with a vendored cri-api file ... other compile / test checks should succeed) |
|
e2e failure doesn't look related: looks like other tests passed |
|
I believe this PR converts the CRI request ENV options, as an []byte, over to the container spec's array of strings early enough to avoid type issues. For awareness https://github.com/containerd/nri/blob/main/pkg/api/api.proto#L748-L752 Since we're converting to type string before storage into the meta store and creation of the container spec.. and calling over ttRPC to NRI for NRI adjustments ... this change direction should be good, will look forward to seeing this merge and perhaps we'll want to pipe through some docs (NRI etc) to explain that these strings might need to be treated as []byte for cases where the kubelet/crictl users etal. are pushing binary env's https://github.com/containerd/containerd/blob/main/vendor/github.com/opencontainers/runtime-spec/specs-go/config.go#L79 |
...
nod was a flake.. retry succedded |
|
The change looks good to me. |
|
CI is failing on the manual vendor changes. You could bypass that with a |
I don't really care if the project vendor check fails for now (unless it's keeping us from getting unit/integration/e2e signal), I just wanted to mock out the rest of the changes |
| replace github.com/containerd/containerd/api => ./api | ||
|
|
||
| replace k8s.io/cri-api => github.com/liggitt/cri-api v0.37.0-alpha.0.0.20260623175924-f29312ad3d70 |
| env := append([]string{}, imageConfig.Env...) | ||
| for _, e := range config.GetEnvs() { | ||
| env = append(env, e.GetKey()+"="+e.GetValue()) | ||
| env = append(env, e.GetKey()+"="+string(e.GetValue())) | ||
| } | ||
| specOpts = append(specOpts, oci.WithEnv(env)) |
Can confirm that a build of K3s with this replacement for cri-api, along with a cherry-pick of the commits from this PR on to containerd v2.3, work properly. |
Signed-off-by: Jordan Liggitt <[email protected]>
Signed-off-by: Jordan Liggitt <[email protected]>
|
updated to release v0.36.3 tag containing kubernetes/kubernetes#139964 |

Part of recovering from a regression in the ability of v0.34.0+ cri-api being able to transmit binary non-utf8 envvar values
xref
cc @mikebrow @samuelkarp
This updates to a cri-api patch release that switched the proto type of the envvar value field from
stringtobytes, and adds a []byte → go string cast in the spot that handles this CRI field.