From e74bca7199231a378a0734f6aa2da3369597d0d2 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Tue, 15 Mar 2022 11:17:13 +0100 Subject: [PATCH] fix: disable parallel operations for Pulumi as backend does not support that, yet --- cloudbender/cli.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/cloudbender/cli.py b/cloudbender/cli.py index 750b508..884b2ab 100644 --- a/cloudbender/cli.py +++ b/cloudbender/cli.py @@ -342,21 +342,39 @@ def _render(stacks): logger.info("{} uses Pulumi, render skipped.".format(s.stackname)) +def _anyPulumi(step): + for stack in step: + if stack.mode == "pulumi": + return True + + return False + + def _provision(cb, stacks): """Utility function to reuse code between tasks""" for step in sort_stacks(cb, stacks): if step: - with ThreadPoolExecutor(max_workers=len(step)) as group: - futures = [] + # if there are any Pulumi stacks in the step execute serial + if _anyPulumi(step): for stack in step: status = stack.get_status() if not status: - futures.append(group.submit(stack.create)) + stack.create() else: - futures.append(group.submit(stack.update)) + stack.update() - for future in as_completed(futures): - future.result() + else: + with ThreadPoolExecutor(max_workers=len(step)) as group: + futures = [] + for stack in step: + status = stack.get_status() + if not status: + futures.append(group.submit(stack.create)) + else: + futures.append(group.submit(stack.update)) + + for future in as_completed(futures): + future.result() cli.add_command(render)