From 5d2623158bf3a5251f9bfb0649da931fbbe7a765 Mon Sep 17 00:00:00 2001 From: "Mads W. Pedersen" Date: Mon, 9 Mar 2026 10:57:50 +0100 Subject: [PATCH 1/3] Made Scalable more patient with GitLab (again) --- app/Listeners/GitLab/Project/DisableForking.php | 5 ++--- app/Listeners/GitLab/Project/UnprotectDefaultBranch.php | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Listeners/GitLab/Project/DisableForking.php b/app/Listeners/GitLab/Project/DisableForking.php index c7bde004..a91868a8 100644 --- a/app/Listeners/GitLab/Project/DisableForking.php +++ b/app/Listeners/GitLab/Project/DisableForking.php @@ -43,16 +43,15 @@ public function handle(ProjectCreated $event): void Log::info("Disabling GitLab forking for project {$event->project->id}"); - $attempts = 3; + $attempts = 5; $gitLabManager = app(GitLabManager::class); $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); while (($project['import_error'] != null || $project['import_status'] != 'finished') && $attempts > 1) { // The system is sometimes too fast for the Gitlab server, this buys the Gitlab server some more time before Scalable moves on. - usleep(250000); + usleep(250_000); $attempts--; $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); - } if($project['import_error'] != null || $project['import_status'] != 'finished') diff --git a/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php b/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php index 26d8f9ee..78e954fd 100644 --- a/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php +++ b/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php @@ -44,14 +44,14 @@ public function handle(ProjectCreated $event): void $gitLabManager = app(GitLabManager::class); - $attempts = 3; + $attempts = 5; $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); while (($project['import_error'] != null || $project['import_status'] != 'finished') && $attempts > 1) { // The system is sometimes too fast for the Gitlab server, this buys the Gitlab server some more time before Scalable moves on. - usleep(250000); + usleep(250_000); $attempts--; $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); From 9a7e817459a286590d3dc8d052cbe715304fbd04 Mon Sep 17 00:00:00 2001 From: "Mads W. Pedersen" Date: Mon, 9 Mar 2026 11:05:39 +0100 Subject: [PATCH 2/3] I changed my mind, now it is even more patient --- app/Listeners/GitLab/Project/DisableForking.php | 4 ++-- app/Listeners/GitLab/Project/UnprotectDefaultBranch.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Listeners/GitLab/Project/DisableForking.php b/app/Listeners/GitLab/Project/DisableForking.php index a91868a8..f7952a36 100644 --- a/app/Listeners/GitLab/Project/DisableForking.php +++ b/app/Listeners/GitLab/Project/DisableForking.php @@ -43,13 +43,13 @@ public function handle(ProjectCreated $event): void Log::info("Disabling GitLab forking for project {$event->project->id}"); - $attempts = 5; + $attempts = 7; $gitLabManager = app(GitLabManager::class); $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); while (($project['import_error'] != null || $project['import_status'] != 'finished') && $attempts > 1) { // The system is sometimes too fast for the Gitlab server, this buys the Gitlab server some more time before Scalable moves on. - usleep(250_000); + usleep(300_000); $attempts--; $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); } diff --git a/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php b/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php index 78e954fd..c198cc70 100644 --- a/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php +++ b/app/Listeners/GitLab/Project/UnprotectDefaultBranch.php @@ -44,14 +44,14 @@ public function handle(ProjectCreated $event): void $gitLabManager = app(GitLabManager::class); - $attempts = 5; + $attempts = 7; $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); while (($project['import_error'] != null || $project['import_status'] != 'finished') && $attempts > 1) { // The system is sometimes too fast for the Gitlab server, this buys the Gitlab server some more time before Scalable moves on. - usleep(250_000); + usleep(300_000); $attempts--; $project = $gitLabManager->projects()->show($event->project->gitlab_project_id); From abd39f326324861d8d05fda79ad1b6ba616e2b21 Mon Sep 17 00:00:00 2001 From: "Mads W. Pedersen" Date: Mon, 9 Mar 2026 11:25:36 +0100 Subject: [PATCH 3/3] Updated tests... --- tests/Unit/App/Jobs/DisableForkingJobTest.php | 2 +- tests/Unit/App/Jobs/UnprotectDefaultBranchJobTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Unit/App/Jobs/DisableForkingJobTest.php b/tests/Unit/App/Jobs/DisableForkingJobTest.php index de7691cf..df85d36e 100644 --- a/tests/Unit/App/Jobs/DisableForkingJobTest.php +++ b/tests/Unit/App/Jobs/DisableForkingJobTest.php @@ -52,7 +52,7 @@ $this->project->save(); $this->mock(GitLabManager::class, function (MockInterface $mock) { - $mock->shouldReceive('projects->show')->atMost()->times(3)->andReturn([ + $mock->shouldReceive('projects->show')->atMost()->times(7)->andReturn([ 'import_error' => 'error', 'import_status' => 'finished', ]); diff --git a/tests/Unit/App/Jobs/UnprotectDefaultBranchJobTest.php b/tests/Unit/App/Jobs/UnprotectDefaultBranchJobTest.php index 17a6ee3f..4ab33dd8 100644 --- a/tests/Unit/App/Jobs/UnprotectDefaultBranchJobTest.php +++ b/tests/Unit/App/Jobs/UnprotectDefaultBranchJobTest.php @@ -52,7 +52,7 @@ $this->project->save(); $this->mock(GitLabManager::class, function (MockInterface $mock) { - $mock->shouldReceive('projects->show')->atMost()->times(3)->andReturn([ + $mock->shouldReceive('projects->show')->atMost()->times(7)->andReturn([ 'import_error' => 'error', 'import_status' => 'finished', ]);