Skip to content

fix(unikontainers): preserve slice order when removing element#678

Open
mdryaan wants to merge 1 commit into
urunc-dev:mainfrom
mdryaan:fix/remove-preserves-order
Open

fix(unikontainers): preserve slice order when removing element#678
mdryaan wants to merge 1 commit into
urunc-dev:mainfrom
mdryaan:fix/remove-preserves-order

Conversation

@mdryaan
Copy link
Copy Markdown

@mdryaan mdryaan commented May 14, 2026

Description

remove() in pkg/unikontainers/utils.go removed an element by swapping it with the last element before truncating. This destroyed the ordering of all remaining elements. Both call sites are affected: handleQueueProxy (removes SERVING_READINESS_PROBE from spec.Process.Env) and the vAccel env cleanup in unikontainers.go (removes VACCEL_RPC_ADDRESS). Replace the swap-and-truncate with append(s[:i], s[i+1:]...) to preserve order.

Related issues

How was this tested?

Added TestRemovePreservesOrder to pkg/unikontainers/utils_test.go. The test
calls remove([]string{"a", "b", "c", "d"}, 0) and asserts the result is
["b", "c", "d"].

Before fix:

Screenshot 2026-05-14 083407

After fix:

Screenshot 2026-05-14 083605

Run with:
go test ./pkg/unikontainers/ -v -run TestRemovePreservesOrder

golangci-lint run passes with 0 issues. make builds successfully.

LLM usage

N/A

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

Signed-off-by: mdryaan <alikhurshid842001@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 14, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 05846d1
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a0542158416110008e7aa42

@mdryaan
Copy link
Copy Markdown
Author

mdryaan commented May 14, 2026

Hey @cmainas , Could you please have a look at this PR whenever you have time? Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve slice order when removing environment variable

1 participant