From 9cf4a0e5258a5a041eb0a28153ab74a7eb681272 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Tue, 18 Jul 2023 00:31:37 +0300 Subject: [PATCH] add gitlab command delays to avoid race condition --- .../production/management/commands/advance_git_repos.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scipost_django/production/management/commands/advance_git_repos.py b/scipost_django/production/management/commands/advance_git_repos.py index 4c93d9a3d..6212b7c38 100644 --- a/scipost_django/production/management/commands/advance_git_repos.py +++ b/scipost_django/production/management/commands/advance_git_repos.py @@ -5,6 +5,8 @@ from datetime import datetime from functools import reduce from itertools import cycle from typing import Any, Callable, Dict, List, Tuple +from time import sleep + from django.core.management.base import BaseCommand, CommandParser from django.conf import settings @@ -189,6 +191,10 @@ class Command(BaseCommand): base_actions = self._get_project_cloning_actions(base_template_project) journal_actions = self._get_project_cloning_actions(journal_template_project) + # Add some delays to avoid: + # - Commiting the files before the branch has finished being created + # - Changing the protected branch before the files have been commited + sleep(3) # Commit the actions project.commits.create( { @@ -197,6 +203,7 @@ class Command(BaseCommand): "actions": base_actions + journal_actions, } ) + sleep(3) # Allow Developers to push to the protected "main" branch # Protected branches lay on top of the branches. Deleting and recreating them is -- GitLab