Skip to content
Snippets Groups Projects
Verified Commit 0ab46055 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Add sleep to avoid race condition when importing products

parent 8da1fa6c
No related branches found
No related tags found
1 merge request!201Add imported products
Pipeline #86614 canceled
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import csv import csv
import ipaddress import ipaddress
import json import json
import time
from datetime import UTC, datetime from datetime import UTC, datetime
from pathlib import Path from pathlib import Path
from typing import Any, TypeVar from typing import Any, TypeVar
...@@ -225,6 +226,9 @@ def _generic_import_product( ...@@ -225,6 +226,9 @@ def _generic_import_product(
except ValidationError as e: except ValidationError as e:
typer.echo(f"Validation error: {e}") typer.echo(f"Validation error: {e}")
typer.echo("Waiting for the dust to settle before moving on the importing new products...")
time.sleep(1)
# Migrate new products from imported to "full" counterpart. # Migrate new products from imported to "full" counterpart.
imported_products = get_subscriptions( imported_products = get_subscriptions(
[imported_product_type], lifecycles=[SubscriptionLifecycle.ACTIVE], includes=["subscription_id"] [imported_product_type], lifecycles=[SubscriptionLifecycle.ACTIVE], includes=["subscription_id"]
...@@ -331,6 +335,9 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: ...@@ -331,6 +335,9 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None:
except ValidationError as e: except ValidationError as e:
typer.echo(f"Validation error: {e}") typer.echo(f"Validation error: {e}")
typer.echo("Waiting for the dust to settle before moving on the importing new products...")
time.sleep(1)
trunk_ids = get_subscriptions( trunk_ids = get_subscriptions(
[ProductType.IMPORTED_IP_TRUNK], lifecycles=[SubscriptionLifecycle.ACTIVE], includes=["subscription_id"] [ProductType.IMPORTED_IP_TRUNK], lifecycles=[SubscriptionLifecycle.ACTIVE], includes=["subscription_id"]
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment