-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Conversation
0ab9ad2
to
c1d9f0a
Compare
c1d9f0a
to
95f75af
Compare
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}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(var)
references
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
// 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
95f75af
to
c84931b
Compare
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. |
5b70258
to
dc84fc5
Compare
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 stringjson:"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
.
There was a problem hiding this comment.
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 stringjson:"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 stringjson:"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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@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; |
There was a problem hiding this comment.
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
8c6f7de
to
be12662
Compare
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
LGTM other than a few really minor cleanups. Thanks for the revisions! |
Re: ordering sure thing
|
be12662
to
c247852
Compare
@a-robinson PR deloused, PTAL |
@derekwaynecarr, any other comments? |
@a-robinson, derek is too stunned to speak, clearly. any chance the on-call can TAL tomorrow? |
@a-robinson unfortunately I need to remove LGTM status from this, i believe there is something I missed that needs to be updated. |
elaborating on my prior comment, looks like the dns test needs to be updated since it uses the subshell |
Cluster logging e2e is affected too. They should both pass but I don't want to be sloppy. |
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. |
c247852
to
8b33886
Compare
@a-robinson Latest code has fixes. Thnx for clarification re: on-call. |
LGTM, assuming you made sure the modified e2e tests pass. |
Yeah, i got a clean e2e run in GCE
|
Expand variables in containers' env, cmd, args
Depends on #7936, not ready for review.