Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bacckport] [1.5] Avoid allocating empty strings in the Env slice #3599

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

jiaqiluo
Copy link
Member

@jiaqiluo jiaqiluo commented Jun 7, 2024

rancher/rancher#45656
#3596

This PR is the backport of #3597, please check the original PR for details.

Previously, we declared the Env slice with the size of the `c.Services.KubeAPI.ExtraEnv` field, which leads to empty strings at the beginning of the Env slice because we use Golang's append function to add new elements, and Docker is not happy with that.
We fix this issue by declaring the Env variable as an empty slice. We also enhance the `getUniqStringList` function to properly trim leading and trailing spaces in each element and to ignore empty strings. We add unit tests for the `getUniqStringList` function and update the integration tests.
@jiaqiluo jiaqiluo requested a review from a team as a code owner June 7, 2024 16:37
@jiaqiluo jiaqiluo changed the title [Bacckport] [1.5] Avoid allocating empty strings in the Env slic [Bacckport] [1.5] Avoid allocating empty strings in the Env slice Jun 7, 2024
@jiaqiluo jiaqiluo merged commit 3957fcc into rancher:release/v1.5 Jun 7, 2024
1 check passed
@jiaqiluo jiaqiluo deleted the fix-kubeapi-env-15 branch June 7, 2024 17:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants