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

Expand variables in containers' env, cmd, args #8149

Merged
merged 1 commit into from May 27, 2015

Conversation

pmorie
Copy link
Member

@pmorie pmorie commented May 12, 2015

Depends on #7936, not ready for review.

@pmorie pmorie force-pushed the container-env-resolution branch 5 times, most recently from 0ab9ad2 to c1d9f0a Compare May 18, 2015 23:28
@pmorie
Copy link
Member Author

pmorie commented May 18, 2015

@pmorie pmorie changed the title WIP: Expand env var values in kubelet Expand variables in containers' env, cmd, args May 19, 2015
@pmorie
Copy link
Member Author

pmorie commented May 19, 2015

cc @thockin

//
// 1. Determine the runtime value of all variables by resolving
// alternate env var sources.
// 2. Determine the final value of each variable by expanding `$var` and `${var}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(var) references

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

@derekwaynecarr derekwaynecarr self-assigned this May 19, 2015
// 3. Create the container's environment in the order variables are declared

// Step 1: resolve alternate env var sources
tmpEnv := make(map[string]string)
for _, value := range container.Env {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method has a bug -- currently, you could have incorrect expansion of a var declared later in a container's environment, which is not supposed to be legal according to the spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified it is a bug, will be fixed in next push.

@pmorie
Copy link
Member Author

pmorie commented May 19, 2015

For the record, I decided when coding this that adding a new env var source was unnecessary / inconsistent with the rest of the agreed upon changes.

@pmorie pmorie force-pushed the container-env-resolution branch 2 times, most recently from 5b70258 to dc84fc5 Compare May 19, 2015 18:15
@@ -513,7 +513,8 @@ type EnvVar struct {
// Required: This must be a C_IDENTIFIER.
Name string `json:"name"`
// Optional: no more than one of the following may be specified.
// Optional: Defaults to "".
// Optional: Defaults to ""; variable references ("$(VAR_NAME)") are
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derekwaynecarr if you like the copy here and in the v1 types.go file, I will change the other API versions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR I am hands-off on this - just swamped. @a-robinson is running point

On Tue, May 19, 2015 at 11:17 AM, Paul Morie notifications@github.com
wrote:

In pkg/api/types.go
#8149 (comment)
:

@@ -513,7 +513,8 @@ type EnvVar struct {
// Required: This must be a C_IDENTIFIER.
Name string json:"name"
// Optional: no more than one of the following may be specified.

  • // Optional: Defaults to "".
  • // Optional: Defaults to ""; variable references ("$(VAR_NAME)") are

@derekwaynecarr https://github.com/derekwaynecarr if you like the copy
here and in the v1 types.go file, I will change the other API versions.


Reply to this email directly or view it on GitHub
https://github.com/GoogleCloudPlatform/kubernetes/pull/8149/files#r30629300
.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a new acronym I'm going to steal from Tim.

----- Original Message -----

@@ -513,7 +513,8 @@ type EnvVar struct {
// Required: This must be a C_IDENTIFIER.
Name string json:"name"
// Optional: no more than one of the following may be specified.

  • // Optional: Defaults to "".
  • // Optional: Defaults to ""; variable references ("$(VAR_NAME)") are

FTR I am hands-off on this - just swamped. @a-robinson is running point

On Tue, May 19, 2015 at 11:17 AM, Paul Morie notifications@github.com
wrote:

In pkg/api/types.go
#8149 (comment)
:

@@ -513,7 +513,8 @@ type EnvVar struct {
// Required: This must be a C_IDENTIFIER.
Name string json:"name"
// Optional: no more than one of the following may be specified.

  • // Optional: Defaults to "".
  • // Optional: Defaults to ""; variable references ("$(VAR_NAME)") are

@derekwaynecarr https://github.com/derekwaynecarr if you like the copy
here and in the v1 types.go file, I will change the other API versions.


Reply to this email directly or view it on GitHub
https://github.com/GoogleCloudPlatform/kubernetes/pull/8149/files#r30629300
.


Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/8149/files#r30641318

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally open to discussion, but think it's more clear to get rid of the extraneous symbols around the example, leaving something like -
variable references of the form $(VAR_NAME) are expanded to the value of VAR_NAME according to the variable expansion spec

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it would be even better if you could briefly explain the behavior rather than only referring to a spec that the reader has to search for

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like @a-robinson , I would prefer that the pertinent documentation piece goes in the description field for the value. Also note if you change these you will need to regen the swagger docs.

@pmorie
Copy link
Member Author

pmorie commented May 19, 2015

@a-robinson if you have bandwidth I'd love your input on this

Command []string `json:"command,omitempty" description:"entrypoint array; not executed within a shell; the docker image's entrypoint is used if this is not provided; cannot be updated"`
// Optional: The docker image's cmd is used if this is not provided; cannot be updated.
Args []string `json:"args,omitempty" description:"command array; the docker image's cmd is used if this is not provided; arguments to the entrypoint; cannot be updated"`
// Optional: The docker image's entrypoint is used if this is not provided; cannot be updated;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to have missed the comment on EnvVar.Value in this file

@pmorie pmorie force-pushed the container-env-resolution branch 2 times, most recently from 8c6f7de to be12662 Compare May 22, 2015 22:42
@@ -639,9 +645,13 @@ type Container struct {
Name string `json:"name"`
// Required.
Image string `json:"image"`
// Optional: The docker image's entrypoint is used if this is not provided; cannot be updated.
// Optional: The docker image's entrypoint is used if this is not provided;
// cannot be updated; variable references ("$(VAR_NAME)") are expanded according
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the extra parentheses and quotes around $(VAR_NAME) as you did above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also refer the reader to the rules for how EnvVar.Value is expanded rather than to the full spec, or just copy what you put there as you did in the versioned API files

@a-robinson
Copy link
Contributor

LGTM other than a few really minor cleanups. Thanks for the revisions!

@pmorie
Copy link
Member Author

pmorie commented May 24, 2015

Re: ordering sure thing
On Sat, May 23, 2015 at 7:43 PM Alex Robinson notifications@github.com
wrote:

LGTM other than a few really minor cleanups. Thanks for the revisions!


Reply to this email directly or view it on GitHub
#8149 (comment)
.

@pmorie
Copy link
Member Author

pmorie commented May 26, 2015

@a-robinson PR deloused, PTAL

@a-robinson a-robinson added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2015
@a-robinson
Copy link
Contributor

@derekwaynecarr, any other comments?

@pmorie pmorie mentioned this pull request May 26, 2015
9 tasks
@pmorie
Copy link
Member Author

pmorie commented May 27, 2015

@a-robinson, derek is too stunned to speak, clearly. any chance the on-call can TAL tomorrow?

@pmorie
Copy link
Member Author

pmorie commented May 27, 2015

@a-robinson unfortunately I need to remove LGTM status from this, i believe there is something I missed that needs to be updated.

@pmorie
Copy link
Member Author

pmorie commented May 27, 2015

elaborating on my prior comment, looks like the dns test needs to be updated since it uses the subshell $() syntax in the image's command.

@pmorie
Copy link
Member Author

pmorie commented May 27, 2015

Cluster logging e2e is affected too. They should both pass but I don't want to be sloppy.

@pmorie pmorie removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2015
@a-robinson
Copy link
Contributor

Good catch, let me know when you've fixed them up.

The oncall is still catching up with the backlog from last week's merge freeze, so the current protocol is just to slap the status/lgtm on it and wait for them to come by and merge it.

@pmorie
Copy link
Member Author

pmorie commented May 27, 2015

@a-robinson Latest code has fixes. Thnx for clarification re: on-call.

@a-robinson
Copy link
Contributor

LGTM, assuming you made sure the modified e2e tests pass.

@a-robinson a-robinson added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2015
@pmorie
Copy link
Member Author

pmorie commented May 27, 2015

Yeah, i got a clean e2e run in GCE
On Wed, May 27, 2015 at 12:46 AM Alex Robinson notifications@github.com
wrote:

LGTM, assuming you made sure the modified e2e tests pass.


Reply to this email directly or view it on GitHub
#8149 (comment)
.

thockin added a commit that referenced this pull request May 27, 2015
Expand variables in containers' env, cmd, args
@thockin thockin merged commit 57df04e into kubernetes:master May 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants