Skip to content

Commit 24a6d83

Browse files
author
ddeleo
committed
feat: gracefully handle existing environments during creation and add a 10-second delay after listing target DAGs.
1 parent 73ac8c5 commit 24a6d83

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

composer/tools/composer_migrate.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def create_environment_from_config(self, config: Any) -> Any:
7878
# The original code did: POST .../environments with body.
7979

8080
response = self.session.post(url, json=config)
81+
if response.status_code == 409:
82+
logger.info("Environment already exists, skipping creation.")
83+
return
84+
8185
if response.status_code != 200:
8286
raise RuntimeError(
8387
f"Failed to create environment: {response.text}"
@@ -488,6 +492,7 @@ def main(
488492
target_env_dag_ids = [dag["dag_id"] for dag in target_env_dags]
489493
all_dags_present = set(source_env_dag_ids) == set(target_env_dag_ids)
490494
logger.info("List of DAGs in the target environment: %s", target_env_dag_ids)
495+
time.sleep(10)
491496
# Unpause only DAGs that were not paused in the source environment.
492497
# Optimization: if all DAGs were unpaused in source, use bulk unpause.
493498
if not any(d["is_paused"] for d in source_env_dags):

0 commit comments

Comments
 (0)