Tag the gate resource group with CreatedOn when it is created - #1865
Open
Ewerton Scaboro da Silva (ewertons) wants to merge 2 commits into
Open
Tag the gate resource group with CreatedOn when it is created#1865Ewerton Scaboro da Silva (ewertons) wants to merge 2 commits into
Ewerton Scaboro da Silva (ewertons) wants to merge 2 commits into
Conversation
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>
Tim Taylor (timtay-microsoft)
approved these changes
Aug 24, 2026
Copilot started reviewing on behalf of
Ewerton Scaboro da Silva (ewertons)
August 24, 2026 22:24
View session
There was a problem hiding this comment.
Pull request overview
Tags Java gate resource groups at creation so scheduled cleanup can apply age-based deletion safely.
Changes:
- Adds an ISO 8601 UTC
CreatedOntag toaz group create. - Documents why tagging must be atomic and limited to one tag.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One line: tag the gate resource group with
CreatedOnas part ofaz group create.Why
The scheduled cleanup that deletes leftover
javasdkgate*groups lives in the C# repo (Azure/azure-iot-sdk-csharp,vsts/resource-group-cleanup.yaml) — it handlesjavasdkgate*anddotnetsdkgate*together. Today it deletes every matching group unconditionally, with no age check, including groups belonging to a Java gate run that is still executing. When it fires mid-run it removes that run's IoT hub, DPS instance and storage account, and the run fails on unrelated errors.Azure/azure-iot-sdk-csharp#3538 fixes that by only deleting a group once it is at least 3 h old, judged by a
CreatedOntag.Groups created here carry no tags at all, so without this change every Java gate group lands on the slower fallback path that PR keeps for untagged groups (stamp on first sight, delete after 24 h). They would still be cleaned up and still be safe from mid-run deletion — just reclaimed roughly a day later than necessary. This restores the fast 3 h path.
Two details
AzureCLI@2task,--tagswith severalkey=valuearguments collapses them into one tag value.Azure/iot-sdks-e2e-fxalready hit this (d87ebbb). One pair has nothing to collapse.Ordering
Independent of Azure/azure-iot-sdk-csharp#3538 and safe to merge in either order. Before it, this tag is simply unused; after it, it moves Java groups onto the fast path.
Testing
I have no ARM credential in this environment, so this is not verified against live Azure — please confirm on a gate run.
Verified locally with PowerShell 7.4.6: the script parses clean, the tag reaches
azas a single argument token (CreatedOn=2026-08-24T20:17:00.0327400Z, confirmed by argument-count check, so the collapsing bug cannot apply), and the value round-trips through the exact[datetimeoffset]::Parse(..., AssumeUniversal)call the cleanup uses to judge age.The existing behaviour is otherwise untouched: the group is still only created when
az group existsreportsFalse, so a pre-existing group is not retagged.