1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-17 23:49:06 +00:00

Avoid allocating empty strings in the Env slice

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.
This commit is contained in:
Jiaqi Luo
2024-06-04 16:11:58 -07:00
parent 7903c0d07d
commit 4613cce211
3 changed files with 76 additions and 1 deletions

View File

@@ -90,6 +90,25 @@ nodes:
- address: rke-node-${node}
role: [etcd, controlplane, worker]
user: ubuntu
services:
etcd:
extra_env:
- TEST_VAR=etcd
kubeproxy:
extra_env:
- TEST_VAR=kube-proxy
scheduler:
extra_env:
- TEST_VAR=scheduler
kubelet:
extra_env:
- TEST_VAR=kubelet
kube-controller:
extra_env:
- TEST_VAR=kube-controller
kube-api:
extra_env:
- TEST_VAR=kube-api
EOF
if [ "x${NETWORK_PLUGIN}" != "x" ]; then