Created
July 8, 2016 17:18
-
-
Save kapilt/c386867f209ac1b55d33b8817c9b3f91 to your computer and use it in GitHub Desktop.
This file contains 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
(custodian)60f81dc15d88:c7n ylv522$ git diff tags.py | |
diff --git a/c7n/tags.py b/c7n/tags.py | |
index a24e1d6..e83fa32 100644 | |
--- a/c7n/tags.py | |
+++ b/c7n/tags.py | |
@@ -289,11 +289,15 @@ class Tag(Action, ResourceTag): | |
batch_size = self.data.get('batch_size', self.batch_size) | |
+ id_key = self.manager.get_model().id | |
+ | |
with self.executor_factory(max_workers=self.concurrency) as w: | |
- futures = [] | |
+ futures = {} | |
for resource_set in utils.chunks(resources, size=batch_size): | |
- futures.append( | |
- w.submit(self.process_resource_set, resource_set, tags)) | |
+ futures[ | |
+ w.submit( | |
+ self.process_resource_set, resource_set, tags) | |
+ ] = resource_set | |
for f in as_completed(futures): | |
if f.exception(): | |
@@ -325,17 +329,24 @@ class RemoveTag(Action, ResourceTag): | |
tags = self.data.get('tags', [DEFAULT_TAG]) | |
batch_size = self.data.get('batch_size', self.batch_size) | |
+ id_key = self.manager.get_model().id | |
+ | |
with self.executor_factory(max_workers=self.concurrency) as w: | |
- futures = [] | |
+ futures = {} | |
for resource_set in utils.chunks(resources, size=batch_size): | |
- futures.append( | |
- w.submit(self.process_resource_set, resource_set, tags)) | |
+ futures[ | |
+ w.submit( | |
+ self.process_resource_set, resource_set, tags) | |
+ ] = resource_set | |
for f in as_completed(futures): | |
if f.exception(): | |
+ resource_set = futures[f] | |
self.log.error( | |
"Exception removing tags: %s on resources:%s \n %s" % ( | |
- tags, self.id_key, f.exception())) | |
+ tags, | |
+ ", ".join([r[id_key] for r in resource_set]), | |
+ f.exception())) | |
def process_resource_set(self, vol_set, tag_keys): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment