-
Couldn't load subscription status.
- Fork 5
test: Allow Storm to accept any env vars, not just proxy vars #132
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
Changes from 7 commits
e049086
df6b131
75411ad
d10c8f8
7e2c325
0a11b46
c55cc0a
41fa134
cf07c74
73143fe
12c5193
1de9f14
f1ce724
6fe7aa9
e410774
5c92b73
910492f
faf8e97
c644cdb
e66110d
e3b8a44
6b28ac2
1338975
34282b8
b5db98f
36eb1d3
f0e8bbe
0fb3f2d
449617b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ parameters: | |
| type: string | ||
| default: "" | ||
|
|
||
| - name: httpsProxy | ||
| - name: envVars | ||
|
||
| type: string | ||
| default: "" | ||
|
|
||
|
|
@@ -74,8 +74,8 @@ steps: | |
| -s "${{ parameters.artifactsDirectory }}" > ./stage-ab-update-deployment.log 2>&1 & | ||
|
|
||
| PROXY_ARG="" | ||
| if [ -n "${{ parameters.httpsProxy }}" ]; then | ||
| PROXY_ARG="--proxy HTTPS_PROXY=${{ parameters.httpsProxy }}" | ||
| if [ -n "${{ parameters.envVars }}" ]; then | ||
| PROXY_ARG="--env-vars ${{ parameters.envVars }}" | ||
| fi | ||
|
|
||
| echo "Running script to stage A/B update..." | ||
|
|
@@ -142,8 +142,8 @@ steps: | |
| -s "${{ parameters.artifactsDirectory }}" > ./finalize-ab-update.log 2>&1 & | ||
|
|
||
| PROXY_ARG="" | ||
| if [ -n "${{ parameters.httpsProxy }}" ]; then | ||
| PROXY_ARG="--proxy HTTPS_PROXY=${{ parameters.httpsProxy }}" | ||
| if [ -n "${{ parameters.envVars }}" ]; then | ||
| PROXY_ARG="--env-vars ${{ parameters.envVars }}" | ||
| fi | ||
|
|
||
| echo "Running script to finalize A/B update..." | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,10 +19,10 @@ const ( | |||||||||||||
| DOCKER_IMAGE_PATH = "/var/lib/trident/trident-container.tar.gz" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| func BuildTridentContainerCommand(env string) string { | ||||||||||||||
| func BuildTridentContainerCommand(envVars []string) string { | ||||||||||||||
| cmd := DOCKER_COMMAND_BASE | ||||||||||||||
| if env != "" { | ||||||||||||||
| cmd += fmt.Sprintf("--env %s ", env) | ||||||||||||||
| if len(envVars) != 0 { | ||||||||||||||
| cmd += fmt.Sprintf("--env %s ", strings.Join(envVars, " ")) | ||||||||||||||
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| } | ||||||||||||||
| cmd += TRIDENT_CONTAINER | ||||||||||||||
| return cmd | ||||||||||||||
|
|
@@ -38,23 +38,29 @@ func BuildTridentContainerCommand(env string) string { | |||||||||||||
| // - The SSH session cannot be created | ||||||||||||||
| // - There was an error starting the command. | ||||||||||||||
| // - Some IO error occurred while reading stdout or stderr. | ||||||||||||||
| func InvokeTrident(env TridentEnvironment, client *ssh.Client, proxy string, arguments string) (*SshCmdOutput, error) { | ||||||||||||||
| func InvokeTrident(env TridentEnvironment, client *ssh.Client, envVars []string, arguments string) (*SshCmdOutput, error) { | ||||||||||||||
| var cmd string | ||||||||||||||
| switch env { | ||||||||||||||
| case TridentEnvironmentHost: | ||||||||||||||
| cmd = TRIDENT_BINARY | ||||||||||||||
| case TridentEnvironmentContainer: | ||||||||||||||
| cmd = BuildTridentContainerCommand(proxy) | ||||||||||||||
| cmd = BuildTridentContainerCommand(envVars) | ||||||||||||||
| case TridentEnvironmentNone: | ||||||||||||||
| return nil, fmt.Errorf("trident service is not running") | ||||||||||||||
| default: | ||||||||||||||
| return nil, fmt.Errorf("invalid environment: %s", env) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| var cmdPrefix string | ||||||||||||||
| if proxy != "" { | ||||||||||||||
| envVar := strings.Split(proxy, "=")[0] | ||||||||||||||
| cmdPrefix = fmt.Sprintf("%s sudo --preserve-env=%s", proxy, envVar) | ||||||||||||||
| if len(envVars) != 0 { | ||||||||||||||
| var envKeys []string | ||||||||||||||
| for _, v := range envVars { | ||||||||||||||
| if key := strings.Split(v, "=")[0]; key != "" { | ||||||||||||||
ayaegashi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| envKeys = append(envKeys, key) | ||||||||||||||
|
||||||||||||||
| if key := strings.Split(v, "=")[0]; key != "" { | |
| envKeys = append(envKeys, key) | |
| if strings.Contains(v, "=") { | |
| if key := strings.SplitN(v, "=", 2)[0]; key != "" { | |
| envKeys = append(envKeys, key) | |
| } |
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.
So, these
BAREMETAL_ENV_VARSwill include other var-s, and HTTPS_PROXY will only be one of them? Just curious why this change is neededThere 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.
Yep, that's correct. This PR is in response to this comment on my previous PR a couple weeks back: #86 (comment) I didn't see this comment until recently haha
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 would suggest that everything in the pipeline stays mostly the same, otherwise there are many edge cases not being considered, and only when we get to invoking the storm binary we transform it into the proxy, ie