-
Notifications
You must be signed in to change notification settings - Fork 147
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
Amend destroy_env_no_terraform.sh to purge container repos #4230
Conversation
Unit Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 07880e7. ♻️ This comment has been updated with latest results. |
@jonnyry shouldn't the script just find the ACRs in the groups it's going to delete? |
Yes good point, probably should - I'll amend. |
@tamirkamara Now updated to search for containter registries rather than requiring a separate parameter. |
/test 07880e7 |
🤖 pr-bot 🤖 🏃 Running tests: https://github.com/microsoft/AzureTRE/actions/runs/12562577242 (with refid (in response to this comment from @jonnyry) |
/test 07880e7 |
🤖 pr-bot 🤖 🏃 Running tests: https://github.com/microsoft/AzureTRE/actions/runs/12563009383 (with refid (in response to this comment from @jonnyry) |
/destroy-test-env |
🤖 pr-bot 🤖
You can use the following commands: (in response to this comment from @jonnyry) |
/test-destroy-env |
Destroying PR test environment (RG: rg-tre853a7c83)... (run: https://github.com/microsoft/AzureTRE/actions/runs/12563557593) |
PR test environment destroy complete (RG: rg-tre853a7c83) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Problem
When using Defender to scan container images -
If the container registry is deleted as a whole (instead of deleting individual container repositories first), Defender does not remove scans of container images.
If redeploying a fresh TRE using the same name as previously, this leads to misleading results in Defender in dev/test environments with repeated scans 'stacking up' and making the results look larger than they actually are (see screen shots below).
Example of Defender results that are 'stacking up':
Example of Defender holding on to scans of deleted images (there is only 1 image in each repository):
Diagnosis
According to this Microsoft documentation, container scans should be deleted within an hour, or maximum three days, however our experience is that container scans for deleted images (where the registry was deleted as a whole) can persist for up to two weeks.
It appears the 'hook' Defender uses to remove scans does not work when the ACR is deleted as a whole with images remaining in it, and only functions as intended when repositories/images are deleted individually first.
Solution
This PR amends the
destroy_env_no_terraform.sh
script to individually delete container repositories, before the script continues as usual to delete the resource groups (including the container registry).This ensures the 'hook' Defender uses to remove scans fires and scans are cleared up when a TRE is destroyed.