Skip to content

Commit 99d5aa9

Browse files
committed
add loop detection
#25
1 parent f1692e0 commit 99d5aa9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

app/Console/Commands/PerformUpdate.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Models\Site;
77
use Illuminate\Console\Command;
88
use App\Console\Traits\RequestTargetVersion;
9+
use Illuminate\Support\Facades\Log;
910

1011
class PerformUpdate extends Command
1112
{
@@ -35,6 +36,14 @@ public function handle(): int
3536
/** @var Site $site */
3637
$site = Site::findOrFail($this->input->getArgument('siteId'));
3738

39+
$updateCount = $site->updates()->where('new_version', $targetVersion)->count();
40+
41+
if ($updateCount >= config('autoupdates.max_update_tries')) {
42+
Log::info("Update Loop detected for Site: " . $site->id . '; TargetVersion: ' . $targetVersion);
43+
44+
return Command::SUCCESS;
45+
}
46+
3847
UpdateSite::dispatchSync(
3948
$site,
4049
$targetVersion

config/autoupdates.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
'healthcheck_interval' => env('HEALTH_CHECK_INTERVAL', 24),
55
'cleanup_site_delay' => env('CLEANUP_SITE_DELAY', 7),
66
'tuf_repo_cachetime' => env('TUF_REPO_CACHETIME', 5),
7+
'max_update_tries' => env('MAX_UPDATE_TRIES', 5),
78
];

0 commit comments

Comments
 (0)