Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI Environment] Do not delete tags that already exist on subscription level #3280

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ntaheij
Copy link

@ntaheij ntaheij commented May 26, 2023

Description

Currently, whenever the Microsoft.Resources/tags module is tested by the CI environment, it will delete the entire tags object, which in most cases, is not desirable.
This change gets all the previous tags from Azure and after deletion adds them back without the test tags.

Behaviour:
image

.\Invoke-ResourceRemoval -Type 'Microsoft.Resources/tags' -ResourceId '/subscriptions/6cc9c28f-2452-4c50-832d-187cad67447b/providers/Microsoft.Resources/tags'

image

Pipeline references

For module/pipeline changes, please create and attach the status badge of your successful run.

Pipeline
Resources - Tags - passing

Type of Change

Please delete options that are not relevant.

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Update to documentation

Checklist

  • I'm sure there are no other open Pull Requests for the same update/change
  • My corresponding pipelines / checks run clean and green without any errors or warnings
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (readme)
  • I did format my code

@ntaheij ntaheij requested a review from a team as a code owner May 26, 2023 11:41
@ntaheij
Copy link
Author

ntaheij commented May 26, 2023

@microsoft-github-policy-service agree

@AlexanderSehr AlexanderSehr added enhancement New feature or request [cat] pipelines category: pipelines [cat] testing category: testing labels May 26, 2023
$currentTags = $(Get-AzTag -ResourceId /subscriptions/$subscriptionId).Properties

# Get the tags to remove
$tagsToRemove = @('Test', 'TestToo')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tags provided by deployment validation tests are just for testing purposes and shouldn't be hardcoded in the CI environment utilities.

If the entire tags object gets deleted even if onlyUpdate is set to true, then I agree that an issue should be opened to address it. @ntaheij could you please open a bug in the board explaining the actual and indended behavior?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response. Currently, yes, onlyUpdate does delete all tags. Issue is that, when deploying the tests for the module, currently all tags are being deleted, which means tags for i.e. billing are not available. I will open a bug.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is any way to only delete the tags that are created, I'd be interested to use that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ntaheij! I'm going to put the PR in draft for the moment and reference the PR in the issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I replied in the issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[cat] pipelines category: pipelines [cat] testing category: testing enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants