From 30e0cef774a286a510e4412627f6ff5bfc183863 Mon Sep 17 00:00:00 2001 From: Ewerton Scaboro da Silva Date: Mon, 24 Aug 2026 20:18:13 +0000 Subject: [PATCH 1/2] Tag the gate resource group with CreatedOn when it is created The scheduled cleanup that deletes leftover 'javasdkgate*' resource groups lives in Azure/azure-iot-sdk-csharp (vsts/resource-group-cleanup.yaml). It used to delete every matching group unconditionally, including groups belonging to a Java gate run that was still executing, which tore that run's IoT hub, DPS instance and storage account away mid-run. That cleanup is being changed to only delete a group once it is at least three hours old, judged by a 'CreatedOn' tag. Groups created here carry no tags at all, so without this change every Java gate group falls onto the slower fallback path the cleanup keeps for untagged groups, and lingers about a day before it is reclaimed. Set the tag as part of `az group create` rather than in a following call, so a run that dies mid-setup cannot leave a group with no tag. A single tag is passed deliberately: under the AzureCLI@2 task, '--tags' with several key=value arguments collapses them into one tag value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- vsts/E2ETestsSetup/e2eTestsSetup.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vsts/E2ETestsSetup/e2eTestsSetup.ps1 b/vsts/E2ETestsSetup/e2eTestsSetup.ps1 index de6a9edf0e..4aedde01fe 100644 --- a/vsts/E2ETestsSetup/e2eTestsSetup.ps1 +++ b/vsts/E2ETestsSetup/e2eTestsSetup.ps1 @@ -58,7 +58,15 @@ $rgExists = az group exists --name $ResourceGroup if ($rgExists -eq "False") { Write-Host "`nCreating resource group $ResourceGroup in $Region" - az group create --name $ResourceGroup --location $Region --output none + + # Tagged as part of the creation itself, not afterwards: the scheduled cleanup in + # Azure/azure-iot-sdk-csharp vsts/resource-group-cleanup.yaml (which deletes leftover + # 'javasdkgate*' groups as well as 'dotnetsdkgate*' ones) uses 'CreatedOn' to tell a leftover + # group from one whose gate run is still in flight. A group created in one step and tagged in + # a second can be left untagged forever if the run dies in between. A single tag is passed + # here on purpose -- under the AzureCLI@2 task, '--tags' with several key=value arguments + # collapses them into one tag value. + az group create --name $ResourceGroup --location $Region --tags "CreatedOn=$([datetime]::UtcNow.ToString('o'))" --output none } $resourceGroupId = az group show -n $ResourceGroup --query id --out tsv From 68f036287ffd7ec1680ead451d4722a7e1bfe771 Mon Sep 17 00:00:00 2001 From: Ewerton Scaboro da Silva Date: Tue, 25 Aug 2026 21:51:25 +0000 Subject: [PATCH 2/2] Correct the tagging rationale comment The comment claimed a failed second tagging call leaves the group untagged forever. The scheduled cleanup stamps an untagged group and deletes it once the stamp ages, so the real consequence is the slower 24-hour fallback rather than the 3-hour path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- vsts/E2ETestsSetup/e2eTestsSetup.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vsts/E2ETestsSetup/e2eTestsSetup.ps1 b/vsts/E2ETestsSetup/e2eTestsSetup.ps1 index 4aedde01fe..da62c6faf8 100644 --- a/vsts/E2ETestsSetup/e2eTestsSetup.ps1 +++ b/vsts/E2ETestsSetup/e2eTestsSetup.ps1 @@ -62,10 +62,11 @@ if ($rgExists -eq "False") # Tagged as part of the creation itself, not afterwards: the scheduled cleanup in # Azure/azure-iot-sdk-csharp vsts/resource-group-cleanup.yaml (which deletes leftover # 'javasdkgate*' groups as well as 'dotnetsdkgate*' ones) uses 'CreatedOn' to tell a leftover - # group from one whose gate run is still in flight. A group created in one step and tagged in - # a second can be left untagged forever if the run dies in between. A single tag is passed - # here on purpose -- under the AzureCLI@2 task, '--tags' with several key=value arguments - # collapses them into one tag value. + # group from one whose gate run is still in flight. Tagging in a second, separate call would + # leave a window where a run that dies in between produces an untagged group. That cleanup + # still reclaims such a group, but only via the slower 24-hour first-observed fallback rather + # than the 3-hour path. A single tag is passed here on purpose -- under the AzureCLI@2 task, + # '--tags' with several key=value arguments collapses them into one tag value. az group create --name $ResourceGroup --location $Region --tags "CreatedOn=$([datetime]::UtcNow.ToString('o'))" --output none }