def process(self, resources):
client = local_session(self.manager.session_factory).client('rds')
# restore up to 10 in parallel, we have to wait on each.
with self.executor_factory(
max_workers=min(10, len(resources) or 1)) as w:
futures = {}
for r in resources:
tags = {t['Key']: t['Value'] for t in r['Tags']}
if not set(tags).issuperset(self.restore_keys):
self.log.warning(
"snapshot:%s missing restore tags",
r['DBSnapshotIdentifier'])
continue
futures[w.submit(self.process_instance, client, r)] = r
for f in as_completed(futures):
r = futures[f]
if f.exception():
self.log.warning(
"Error restoring db:%s from:%s error:\n%s",
r['DBInstanceIdentifier'], r['DBSnapshotIdentifier'],
f.exception())
continue
评论列表
文章目录