Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 4944 (Azure#19706)
Browse files Browse the repository at this point in the history
* Helm template for deploy script

* Update eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>

* fixing helm upgrade command

Co-authored-by: Albert Cheng <albertcheng@microsoft.com>
Co-authored-by: Albert Cheng <38804567+ckairen@users.noreply.github.com>
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
  • Loading branch information
4 people authored Dec 14, 2022
1 parent 228969d commit 51c2003
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions eng/common/scripts/stress-testing/deploy-stress-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 12 additions & 8 deletions eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -298,11 +299,13 @@ 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

$generatedConfigPath = Join-Path $pkg.Directory generatedValues.yaml
$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

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
Expand All @@ -324,12 +327,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()
Expand Down

0 comments on commit 51c2003

Please sign in to comment.