Kami commented on a change in pull request #1617:
URL: https://github.com/apache/libcloud/pull/1617#discussion_r734829210
##########
File path: integration/storage/test_azure_blobs.py
##########
@@ -124,17 +128,46 @@ def setUpClass(cls):
)
location = os.getenv('AZURE_LOCATION', DEFAULT_AZURE_LOCATION)
- name = 'libcloud'
+ name = RESOURCE_GROUP_NAME_PREFIX
name += random_string(MAX_STORAGE_ACCOUNT_NAME_LENGTH - len(name))
timeout = float(os.getenv('AZURE_TIMEOUT_SECONDS',
DEFAULT_TIMEOUT_SECONDS))
+ # We clean up any left over resource groups from previous runs on
setUpClass. If tests on
+ # CI get terminated non-gracefully, old resources will be left laying
around and we want
+ # to clean those up to ensure we dont hit any limits.
+ # To avoid deleting groups from concurrent runs, we only delete
resources older than a
+ # couple (6) of hours
+ print("Checking and cleaning up any old stray resource groups...")
+
+ resource_groups = resource_client.resource_groups.list()
+ now_ts = int(time.time())
+ delete_threshold_ts = now_ts -
int(datetime.timedelta(hours=6).total_seconds())
+
+ for resource_group in resource_groups:
+ resource_create_ts = resource_group.tags.get('create_ts', now_ts)
+
+ if resource_group.name.startswith(RESOURCE_GROUP_NAME_PREFIX) and \
+ resource_group.location.lower() == location.lower() and \
+ 'test' in resource_group.tags and resource_create_ts <=
delete_threshold_ts:
+ assert
resource_group.name.startswith(RESOURCE_GROUP_NAME_PREFIX)
Review comment:
It's jut an additional safe guard in case there was a fat finger in if
or similar which could potentially result in objects with a different prefix to
be deleted (granted, it's probably an over kill since we have additional checks
and right now that account is only used for those tests).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]