Skip to content

Commit a33d51b

Browse files
Merge pull request #193 from EcovadisCode/adoAgentTweaks2
Refactored preStop windows script
2 parents f78a0ee + bb24087 commit a33d51b

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

charts/ado-build-agents/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
22
description: A Helm chart with Keda scalable Azure Devops build agent for Kubernetes
33
name: charts-ado-build-agents
4-
version: 3.6.0
4+
version: 3.6.1
55
appVersion: "1.0"

charts/ado-build-agents/templates/scalejob-staging.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,19 @@ spec:
145145
preStop:
146146
exec:
147147
command:
148-
- "powershell.exe"
149-
- "-NoLogo"
150-
- "-NoProfile"
151-
- "-Command"
152-
- "Start-Sleep -Seconds {{ .Values.agent.terminationGracePeriodSeconds }}"
148+
- powershell.exe
149+
- -NoLogo
150+
- -NoProfile
151+
- -Command
152+
- |
153+
$token = Get-Content C:\azp\.token
154+
while($true) {
155+
C:\azp\agent\config.cmd remove --unattended --auth PAT --token $token >> C:\azp\cleanup.log 2>&1
156+
if ($LASTEXITCODE -eq 0) {
157+
break
158+
}
159+
Start-Sleep -Seconds 30
160+
}
153161
{{- end }}
154162
imagePullPolicy: IfNotPresent
155163
{{- with .Values.agent.securityContext }}

charts/ado-build-agents/templates/scalejob.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ spec:
144144
preStop:
145145
exec:
146146
command:
147-
- "powershell.exe"
148-
- "-NoLogo"
149-
- "-NoProfile"
150-
- "-Command"
151-
- "Start-Sleep -Seconds {{ .Values.agent.terminationGracePeriodSeconds }}"
147+
- powershell.exe
148+
- -NoLogo
149+
- -NoProfile
150+
- -Command
151+
- |
152+
$token = Get-Content C:\azp\.token
153+
while($true) {
154+
C:\azp\agent\config.cmd remove --unattended --auth PAT --token $token >> C:\azp\cleanup.log 2>&1
155+
if ($LASTEXITCODE -eq 0) {
156+
break
157+
}
158+
Start-Sleep -Seconds 30
159+
}
152160
{{- end }}
153161
imagePullPolicy: IfNotPresent
154162
{{- with .Values.agent.securityContext }}

0 commit comments

Comments
 (0)