From a125bf13d67204fda006e521c331669ddb3e5838 Mon Sep 17 00:00:00 2001 From: JacksonMaxfield Date: Wed, 15 Jun 2022 11:33:02 -0700 Subject: [PATCH 1/3] Artificially depend on each index prior to the next --- cdp_backend/infrastructure/cdp_stack.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cdp_backend/infrastructure/cdp_stack.py b/cdp_backend/infrastructure/cdp_stack.py index 7c655fac..a4e31436 100644 --- a/cdp_backend/infrastructure/cdp_stack.py +++ b/cdp_backend/infrastructure/cdp_stack.py @@ -183,6 +183,7 @@ def __init__( ) # Create all firestore indexes + prior_index = None for model_cls in DATABASE_MODELS: for idx_field_set in model_cls._INDEXES: @@ -201,6 +202,15 @@ def __init__( # Finish creating the index set name idx_set_name = "_".join(idx_set_name_parts) fq_idx_set_name = f"{model_cls.collection_name}-{idx_set_name}" + + # Create depends on list + # We don't want to create a ton of indexes in parallel + if prior_index is None: + depends_on = [] + else: + depends_on = [prior_index] + + # Create firestore.Index( fq_idx_set_name, project=self.gcp_project_id, @@ -208,7 +218,10 @@ def __init__( collection_group_id=model_cls.collection_name, fields=idx_set_fields, query_scope="COLLECTION", - opts=pulumi.ResourceOptions(parent=self.firestore_app), + opts=pulumi.ResourceOptions( + parent=self.firestore_app, + depends_on=depends_on, + ), ) # Add metadata document From d12813bad4f454e865497f60b97d48ca6d961fe5 Mon Sep 17 00:00:00 2001 From: JacksonMaxfield Date: Wed, 15 Jun 2022 14:01:08 -0700 Subject: [PATCH 2/3] Create indexes one after another --- cdp_backend/infrastructure/cdp_stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdp_backend/infrastructure/cdp_stack.py b/cdp_backend/infrastructure/cdp_stack.py index a4e31436..e923eee6 100644 --- a/cdp_backend/infrastructure/cdp_stack.py +++ b/cdp_backend/infrastructure/cdp_stack.py @@ -211,7 +211,7 @@ def __init__( depends_on = [prior_index] # Create - firestore.Index( + prior_index = firestore.Index( fq_idx_set_name, project=self.gcp_project_id, database_id="(default)", From c2a2abb5972e93403341ca5c04b5232becca8e8e Mon Sep 17 00:00:00 2001 From: JacksonMaxfield Date: Wed, 15 Jun 2022 14:07:32 -0700 Subject: [PATCH 3/3] Lint and format --- cdp_backend/infrastructure/cdp_stack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdp_backend/infrastructure/cdp_stack.py b/cdp_backend/infrastructure/cdp_stack.py index e923eee6..412566f4 100644 --- a/cdp_backend/infrastructure/cdp_stack.py +++ b/cdp_backend/infrastructure/cdp_stack.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import json +from typing import List import pulumi import pulumi_gcp as gcp @@ -206,7 +207,7 @@ def __init__( # Create depends on list # We don't want to create a ton of indexes in parallel if prior_index is None: - depends_on = [] + depends_on: List[pulumi.Resource] = [] else: depends_on = [prior_index]