diff --git a/.pipelines/templates/stages/testing_common/e2e-ab-update-stage-finalize-test-run.yml b/.pipelines/templates/stages/testing_common/e2e-ab-update-stage-finalize-test-run.yml index d7079cd72..572e07684 100644 --- a/.pipelines/templates/stages/testing_common/e2e-ab-update-stage-finalize-test-run.yml +++ b/.pipelines/templates/stages/testing_common/e2e-ab-update-stage-finalize-test-run.yml @@ -75,7 +75,7 @@ steps: PROXY_ARG="" if [ -n "${{ parameters.httpsProxy }}" ]; then - PROXY_ARG="--proxy HTTPS_PROXY=${{ parameters.httpsProxy }}" + PROXY_ARG="--env-vars HTTPS_PROXY=${{ parameters.httpsProxy }}" fi echo "Running script to stage A/B update..." @@ -143,7 +143,7 @@ steps: PROXY_ARG="" if [ -n "${{ parameters.httpsProxy }}" ]; then - PROXY_ARG="--proxy HTTPS_PROXY=${{ parameters.httpsProxy }}" + PROXY_ARG="--env-vars HTTPS_PROXY=${{ parameters.httpsProxy }}" fi echo "Running script to finalize A/B update..." diff --git a/.pipelines/templates/stages/testing_common/e2e-test-run.yml b/.pipelines/templates/stages/testing_common/e2e-test-run.yml index 6bc72bcfc..5c4ff5f83 100644 --- a/.pipelines/templates/stages/testing_common/e2e-test-run.yml +++ b/.pipelines/templates/stages/testing_common/e2e-test-run.yml @@ -134,7 +134,7 @@ steps: PROXY_ARG="" if [ -n "${{ parameters.httpsProxy }}" ]; then - PROXY_ARG="--proxy HTTPS_PROXY=${{ parameters.httpsProxy }}" + PROXY_ARG="--env-vars HTTPS_PROXY=${{ parameters.httpsProxy }}" fi echo "Running script to stage and finalize A/B update..." @@ -243,7 +243,7 @@ steps: PROXY_ARG="" if [ -n "${{ parameters.httpsProxy }}" ]; then - PROXY_ARG="--proxy HTTPS_PROXY=${{ parameters.httpsProxy }}" + PROXY_ARG="--env-vars HTTPS_PROXY=${{ parameters.httpsProxy }}" fi echo "Running script to stage and finalize A/B update..." diff --git a/tools/storm/helpers/ab_update.go b/tools/storm/helpers/ab_update.go index adb4b4a03..02ebc111c 100644 --- a/tools/storm/helpers/ab_update.go +++ b/tools/storm/helpers/ab_update.go @@ -21,11 +21,11 @@ type AbUpdateHelper struct { args struct { utils.SshCliSettings `embed:""` utils.EnvCliSettings `embed:""` - TridentConfig string `short:"c" required:"" help:"File name of the custom read-write Trident config on the host to point Trident to."` - Version string `short:"v" required:"" help:"Version of the Trident image to use for the A/B update."` - StageAbUpdate bool `short:"s" help:"Controls whether A/B update should be staged."` - FinalizeAbUpdate bool `short:"f" help:"Controls whether A/B update should be finalized."` - Proxy string `help:"Proxy address. Input should include the env var name, i.e. HTTPS_PROXY=http://0.0.0.0."` + TridentConfig string `short:"c" required:"" help:"File name of the custom read-write Trident config on the host to point Trident to."` + Version string `short:"v" required:"" help:"Version of the Trident image to use for the A/B update."` + StageAbUpdate bool `short:"s" help:"Controls whether A/B update should be staged."` + FinalizeAbUpdate bool `short:"f" help:"Controls whether A/B update should be finalized."` + EnvVars []string `short:"e" help:"Environment variables. Multiple vars can be passed as a list of comma-separated strings, or this flag can be used multiple times. Each var should include the env var name, i.e. HTTPS_PROXY=http://0.0.0.0."` } client *ssh.Client @@ -65,7 +65,7 @@ func (h *AbUpdateHelper) getHostConfig(tc storm.TestCase) error { } }) - out, err := utils.InvokeTrident(h.args.Env, h.client, h.args.Proxy, "get configuration") + out, err := utils.InvokeTrident(h.args.Env, h.client, h.args.EnvVars, "get configuration") if err != nil { return fmt.Errorf("failed to invoke Trident: %w", err) } @@ -230,7 +230,7 @@ func (h *AbUpdateHelper) triggerTridentUpdate(tc storm.TestCase) error { for i := 1; ; i++ { logrus.Infof("Invoking Trident attempt #%d with args: %s", i, args) - out, err := utils.InvokeTrident(h.args.Env, h.client, h.args.Proxy, args) + out, err := utils.InvokeTrident(h.args.Env, h.client, h.args.EnvVars, args) if err != nil { if err, ok := err.(*ssh.ExitMissingError); ok && strings.Contains(out.Stderr, "Rebooting system") { // The connection closed without an exit code, and the output contains "Rebooting system". diff --git a/tools/storm/utils/trident.go b/tools/storm/utils/trident.go index adaf15108..06e7f6e96 100644 --- a/tools/storm/utils/trident.go +++ b/tools/storm/utils/trident.go @@ -19,10 +19,12 @@ 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 { + for _, envVar := range envVars { + cmd += fmt.Sprintf("--env '%s' ", envVar) + } } cmd += TRIDENT_CONTAINER return cmd @@ -38,13 +40,13 @@ 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: @@ -52,9 +54,12 @@ func InvokeTrident(env TridentEnvironment, client *ssh.Client, proxy string, arg } 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 quotedEnvVars = "" + for _, v := range envVars { + quotedEnvVars += fmt.Sprintf("'%s' ", v) + } + cmdPrefix = fmt.Sprintf("sudo %s", quotedEnvVars) } else { cmdPrefix = "sudo" }