Skip to content
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

Rejecting valid Environment Variable Names #47

Closed
DarqueWarrior opened this issue Aug 5, 2017 · 31 comments
Closed

Rejecting valid Environment Variable Names #47

DarqueWarrior opened this issue Aug 5, 2017 · 31 comments
Assignees
Labels
area/kubectl help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/P1 sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@DarqueWarrior
Copy link

Kubernetes version:

Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.0", GitCommit:"d3ada0119e776222f11ec7945e6d860061339aad", GitTreeState:"clean", BuildDate:"2017-06-29T23 15:59Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.6", GitCommit:"7fa1c1756d8bc963f1a389f4a6937dc71f08ada2", GitTreeState:"clean", BuildDate:"2017-06-16T18 21:54Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: Azure Container Service
  • OS: Windows 10
  • Install tools:
  • Others:

What happened:
I was invoking the following command:
kubectl run myname --image=myimage:86 --port=80 --env="ConnectionStrings:DefaultConnection=Data Source=tcp:mySqlServer,1433;Initial Catalog=myDB;User Id=myUser;Password=mypassword;"
I got errors about invalid env:
error: invalid env: ConnectionStrings:DefaultConnection=Data Source=tcp:mySqlServer

I tried this with a YAML file as well and got a better error message stating I was using invalid characters for my name. However, : is valid the only values not allowed in names is "=". To work around this I removed the : then I got an error because it split my value on "," between my server and port.

What you expected to happen:
I expected a new environment variable to be created with the following information:

  • name: ConnectionStrings:DefaultConnection
  • value: Data Source=tcp:mySqlServer,1433;Initial Catalog=myDB;User Id=myUser;Password=mypassword;

How to reproduce it (as minimally and precisely as possible):
Just try and set the environment variable name to something that includes a ":" and have a value that contains a ",". The splitting should not split on "," in the value of the environment variable.

Anything else we need to know:
I am using .NET Core and it allows you to create nested configurations that are built using a : in the environment variable name. I was able to use this just fine with docker run commands against my own host because docker and Linux does support the string as I originally submitted it. This only breaks because of the validation of values and parsing logic of kubectl.

@zjj2wry
Copy link

zjj2wry commented Aug 8, 2017

@DarqueWarrior the env key not support name: "a:b", but value can set value: "a:b".

@apelisse
Copy link
Member

apelisse commented Aug 10, 2017

According to POSIX:

Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. Other characters may be permitted by an implementation; applications shall tolerate the presence of such names.

Which let's me believe that we should allow "other characters".

Also, try this:

$ python
>>> import os
>>> os.environ["ConnectionStrings:DefaultConnection"] = "Data Source=tcp:mySqlServer,1433;Initial Catalog=myDB;User Id=myUser;Password=mypassword;"
>>> print os.environ["ConnectionStrings:DefaultConnection"]
Data Source=tcp:mySqlServer,1433;Initial Catalog=myDB;User Id=myUser;Password=mypassword;
>>> os.system("env | grep 'ConnectionStrings:DefaultConnection'")
ConnectionStrings:DefaultConnection=Data Source=tcp:mySqlServer,1433;Initial Catalog=myDB;User Id=myUser;Password=mypassword;
0

I don't see anything wrong there.

@apelisse apelisse added the bug label Aug 10, 2017
@pwittrock
Copy link
Member

Fixed in 1.8

kubernetes/kubernetes@b99e571

@mengqiy
Copy link
Member

mengqiy commented Aug 10, 2017

kubernetes/kubernetes#47460 doesn't fix this issue with :.
Reopening the issue.

@mengqiy mengqiy reopened this Aug 10, 2017
@mengqiy
Copy link
Member

mengqiy commented Aug 11, 2017

It seems kubectl doesn't like : in the env key.

@shiywang Do have bandwidth to verify if this is a bug in Cobra or in kubectl code?

@shiywang
Copy link

/assign

@k8s-ci-robot k8s-ci-robot added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed help-wanted labels Dec 15, 2017
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 15, 2018
@mengqiy mengqiy removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 16, 2018
@mengqiy
Copy link
Member

mengqiy commented Mar 16, 2018

@shiywang Any update?

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. and removed bug labels Jun 5, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 3, 2018
@nikhita
Copy link
Member

nikhita commented Sep 3, 2018

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 3, 2018
@vithati
Copy link

vithati commented Sep 25, 2018

I wanted to learn more about kubernetes and thus started investigating this issue out of interest.

@mengqiy , I found that the issue is not in Cobra but in kubectl code. Cobra is parsing arguments properly but kubectl is not allowing ":" in environment name. Allowed characters in environment are [-._a-zA-Z][-._a-zA-Z0-9]* as per this code.

Is it ok if I take up this issue and raise PR for the fix?

@apelisse
Copy link
Member

@vithati Please, feel free to open a PR for this! Thanks (and please assign me).

@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

/sig cli
/area kubectl

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. area/kubectl labels Sep 25, 2018
@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

/assign @vithati

@k8s-ci-robot
Copy link
Contributor

@seans3: GitHub didn't allow me to assign the following users: vithati.

Note that only kubernetes members and repo collaborators can be assigned.
For more information please see the contributor guide

In response to this:

/assign @vithati

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.

@seans3
Copy link
Contributor

seans3 commented Sep 25, 2018

/priority P1

@bgrant0607
Copy link
Member

Please see kubernetes/kubernetes#53201

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 23, 2019
@seans3
Copy link
Contributor

seans3 commented Jan 23, 2019

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 23, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 29, 2019
@seans3
Copy link
Contributor

seans3 commented Apr 29, 2019

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 29, 2019
@pswica
Copy link
Contributor

pswica commented Jun 11, 2019

I tried resolving this here: kubernetes/kubernetes#78910

@apelisse
Copy link
Member

There is already a proposal to fix it in kubernetes/kubernetes#69415, and it's not that easy. Though it seems like it's been abandoned. so I'd be happy to see someone pick it up

@pswica
Copy link
Contributor

pswica commented Jun 11, 2019

Woah yeah it looks like this had much more history than I expected, and that I'm probably wrong haha.

Would you happen to know why my solution is not good? I basically found that line was the culprit and ran some fmt.Printlns. From there I went to a regex tester until I found something that worked. Then I tested against hack/local-up-cluster.sh and it worked like a charm.

@apelisse
Copy link
Member

Your code is perfectly fine. The problem is with backward compatibility. If we start inserting these newly permitted object in the database, it might be a problem when you have multiple masters running at the same time (and not being updated at the same time), or if you fallback your master upgrade to a former version. Then those objects are no longer valid (this is an API change) and will be "stuck" in etcd.

@pswica
Copy link
Contributor

pswica commented Jun 11, 2019

That was an amazing explanation. Thanks a lot for taking the time to post that, I can now see that my solution was pretty naive because, in its current state, I can't imagine it being backwards compatible.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 9, 2019
@seans3
Copy link
Contributor

seans3 commented Sep 9, 2019

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 9, 2019
@liggitt
Copy link
Member

liggitt commented Sep 24, 2019

/close
in favor of kubernetes/kubernetes#53201 (specifically coordinating in kubernetes/kubernetes#53201 (comment))

@k8s-ci-robot
Copy link
Contributor

@liggitt: Closing this issue.

In response to this:

/close
in favor of kubernetes/kubernetes#53201 (specifically coordinating in kubernetes/kubernetes#53201 (comment))

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.

kubectl prioritized bugs automation moved this from Priority P1 to Closed Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/P1 sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects