From eea96c5b61a7018c713bf64b60c104e58500e0a8 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 12 Dec 2022 02:08:01 -0800 Subject: [PATCH 1/3] Helm template for deploy script --- .../stress-testing/deploy-stress-tests.ps1 | 3 +++ .../stress-test-deployment-lib.ps1 | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 b/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 index c71e62943158..4181e933e254 100644 --- a/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 +++ b/eng/common/scripts/stress-testing/deploy-stress-tests.ps1 @@ -26,6 +26,9 @@ param( # Override remote stress-test-addons with local on-disk addons for development [System.IO.FileInfo]$LocalAddonsPath, + # Renders chart templates locally without deployment + [Parameter(Mandatory=$False)][switch]$Template, + # Matrix generation parameters [Parameter(Mandatory=$False)][string]$MatrixFileName, [Parameter(Mandatory=$False)][string]$MatrixSelection, diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index 80c12a8bc68d..1f77bc20fa4f 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -97,6 +97,7 @@ function DeployStressTests( return $true })] [System.IO.FileInfo]$LocalAddonsPath, + [Parameter(Mandatory=$False)][switch]$Template, [Parameter(Mandatory=$False)][string]$MatrixFileName, [Parameter(Mandatory=$False)][string]$MatrixSelection = "sparse", [Parameter(Mandatory=$False)][string]$MatrixDisplayNameFilter, @@ -298,11 +299,11 @@ function DeployStressPackage( } Write-Host "Installing or upgrading stress test $($pkg.ReleaseName) from $($pkg.Directory)" - $result = (Run helm upgrade $pkg.ReleaseName $pkg.Directory ` - -n $pkg.Namespace ` - --install ` - --set stress-test-addons.env=$environment ` - --values (Join-Path $pkg.Directory generatedValues.yaml)) 2>&1 + + $helmCommandArg = "helm", ($Template ? "template":"upgrade"), $pkg.ReleaseName, $pkg.Directory, "-n", $pkg.Namespace, + ($Template ? "":"--install"), "--set", "stress-test-addons.env=$environment", "--values", (Join-Path $pkg.Directory generatedValues.yaml) + + $result = (Run @helmCommandArg) 2>&1 | Write-Host if ($LASTEXITCODE) { # Error: UPGRADE FAILED: create: failed to create: Secret "sh.helm.release.v1.stress-test.v3" is invalid: data: Too long: must have at most 1048576 bytes @@ -324,12 +325,13 @@ function DeployStressPackage( # Helm 3 stores release information in kubernetes secrets. The only way to add extra labels around # specific releases (thereby enabling filtering on `helm list`) is to label the underlying secret resources. # There is not currently support for setting these labels via the helm cli. - $helmReleaseConfig = RunOrExitOnFailure kubectl get secrets ` + if(!$Template) { + $helmReleaseConfig = RunOrExitOnFailure kubectl get secrets ` -n $pkg.Namespace ` -l "status=deployed,name=$($pkg.ReleaseName)" ` -o jsonpath='{.items[0].metadata.name}' - - Run kubectl label secret -n $pkg.Namespace --overwrite $helmReleaseConfig deployId=$deployId + Run kubectl label secret -n $pkg.Namespace --overwrite $helmReleaseConfig deployId=$deployId + } } function CheckDependencies() From a9fa18030bba688f4019296155a2597ebd1237a6 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:19:16 -0800 Subject: [PATCH 2/3] Update eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 Co-authored-by: Ben Broderick Phillips --- .../scripts/stress-testing/stress-test-deployment-lib.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index 1f77bc20fa4f..79c1b6fad746 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -300,8 +300,9 @@ function DeployStressPackage( Write-Host "Installing or upgrading stress test $($pkg.ReleaseName) from $($pkg.Directory)" - $helmCommandArg = "helm", ($Template ? "template":"upgrade"), $pkg.ReleaseName, $pkg.Directory, "-n", $pkg.Namespace, - ($Template ? "":"--install"), "--set", "stress-test-addons.env=$environment", "--values", (Join-Path $pkg.Directory generatedValues.yaml) + $generatedConfigPath = Join-Path $pkg.Directory generatedValues.yaml + $subCommand = $Template ? "template" : "upgrade --install" + $helmCommandArg = "helm", $subCommand, $pkg.ReleaseName, $pkg.Directory, "-n", $pkg.Namespace, "--set", "stress-test-addons.env=$environment", "--values", $generatedConfigPath $result = (Run @helmCommandArg) 2>&1 | Write-Host From 8d11dbecf2ee9db69f6cc031acde1794c9cc239e Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 13 Dec 2022 12:51:09 -0800 Subject: [PATCH 3/3] fixing helm upgrade command --- .../scripts/stress-testing/stress-test-deployment-lib.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index 79c1b6fad746..77df8230532d 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -301,8 +301,9 @@ function DeployStressPackage( Write-Host "Installing or upgrading stress test $($pkg.ReleaseName) from $($pkg.Directory)" $generatedConfigPath = Join-Path $pkg.Directory generatedValues.yaml - $subCommand = $Template ? "template" : "upgrade --install" - $helmCommandArg = "helm", $subCommand, $pkg.ReleaseName, $pkg.Directory, "-n", $pkg.Namespace, "--set", "stress-test-addons.env=$environment", "--values", $generatedConfigPath + $subCommand = $Template ? "template" : "upgrade" + $installFlag = $Template ? "" : "--install" + $helmCommandArg = "helm", $subCommand, $pkg.ReleaseName, $pkg.Directory, "-n", $pkg.Namespace, $installFlag, "--set", "stress-test-addons.env=$environment", "--values", $generatedConfigPath $result = (Run @helmCommandArg) 2>&1 | Write-Host