The Helm chart should protect users against setting duplicate env variables
Summary
Recently .com attempted to roll out a change that mucked with environment variables. We hit a bug with the way interpolates all the environment variables that we had not seen before. The addition of an unrelated env variable caused a sort to detect an environment variable had been duplicated which led to a deployment failure.
Our configuration essentially looked something like this:
env:
# always present
- name: GITLAB_TRACING_URL
value: {{ value | quote }}
# populated from extraEnv, when set
- name: GITLAB_TRACING_URL
value: "some_url"
The reason why this went undetected until a new env being added is not the scope of this issue.
Current behavior
If a user accidentally sets a variable twice, it may either be rejected by Kubernetes, or the value may be incorrectly set and the user may not know this until an audit.
Expected behavior
We should protect users from manually setting variables that may be set by the helm chart by other means, the above is an example that was set manually, but can also be set via values.global.tracing.urlTemplate
. This was unknown to us.
Minimally, for env variables that the helm chart configures, we should fail a template if the user decides to implement the same variable. A further iteration may loop through all variables to ensure that the helm chart is not allowing duplicate values to be set as this is denied by Kubernetes.