New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double dollar signs in a container's args or env section are incorrectly treated as escape characters #101137
Comments
@MartinKanters: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
For env, see #75907 (comment)
|
Hi @pacoxu The docs do say that $$ can be used to escape vars, but in this case we are not using vars. ANY $$ is escaped to just |
/sig api-machinery |
/assign |
/remove-sig api-machinery |
For posterity, copying comment from the PR: I disagree that this is a bug (or at worst is a docs bug). The behavior and syntax was modelled after
The only place we are different, I think, is that we don't eat the V in Worse, "fixing" this is a breaking change. Someone out there is depending on the current behavior, and to fix one app you silently break another. We can't do that. |
I recommend opening a new issue in this repo that covers updating API documentation such as kubernetes/pkg/apis/core/types.go Lines 2103 to 2107 in 2112bdd
|
`kubectl run ... --env=NAME=VALUE` interprets `$$` in VALUE as a (broken) interpolation of variables. Values containing `$$` need to be escaped as `$$$$` as `$$` is turned into `$`. `sed` does this job, but specifies `$` as `\$`; `$` on its own means end-of-the-string. Since the `sed` shell command is inside the Makefile, all `$` further double in number to avoid interpolation as a Make variable. See kubernetes/kubernetes#101137
What happened:
I'm trying to pass two dollar sign in the args or env fields of a pod, but they are reduced to one dollar sign.
What you expected to happen:
The two dollar signs should be propagated to the container.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Kubernetes can expand variables used in the args and env section with the following syntax:$(var). $ $(var) is a way of escaping this variable, resulting in it not being expanded. I don't think '$$' should be regarded as something to be escaped, though.
Here's the expansion code, I believe.
I can take a shot at fixing it, but I first want to know for sure that this is not intended behavior.
Environment:
kubectl version
):cat /etc/os-release
):Ubuntu over WSL
uname -a
):Linux MartinK 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
This issue was found during debugging what we first thought to be a Tekton issue: Tekton converts double dollar symbols to one tektoncd/pipeline#3871.
The text was updated successfully, but these errors were encountered: