mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-14 00:33:44 -04:00
fix(scheduler): spread CDN update checks over a random delay
All instances share the same default update cron, so they request the CDN at the same second and Cloudflare rejects the burst (error 1200). Queue the CDN fetching jobs with a random 0-600s delay to spread the load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
154b50647e
commit
21dc34ae61
@@ -1,10 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\CheckForUpdatesJob;
|
||||
use App\Jobs\CheckHelperImageJob;
|
||||
use App\Jobs\PullChangelog;
|
||||
use App\Jobs\PullTemplatesFromCDN;
|
||||
use App\Jobs\UpdateCoolifyJob;
|
||||
use App\Models\InstanceSettings;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
@@ -51,6 +57,22 @@ it('schedules every production job with onOneServer', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('dispatches CDN fetching jobs with a random delay so instances do not hit the CDN at the same second', function () {
|
||||
InstanceSettings::query()->whereKey(0)->update(['is_auto_update_enabled' => true]);
|
||||
Queue::fake();
|
||||
|
||||
$jobs = [CheckHelperImageJob::class, CheckForUpdatesJob::class, PullTemplatesFromCDN::class, PullChangelog::class, UpdateCoolifyJob::class];
|
||||
$schedule = app(Schedule::class);
|
||||
|
||||
foreach ($jobs as $job) {
|
||||
$event = collect($schedule->events())->first(fn ($e) => $e->description === $job);
|
||||
expect($event)->not->toBeNull("[{$job}] is not scheduled");
|
||||
$event->run(app());
|
||||
|
||||
Queue::assertPushed($job, fn ($pushed) => is_int($pushed->delay) && $pushed->delay >= 0 && $pushed->delay <= 600);
|
||||
}
|
||||
});
|
||||
|
||||
it('does not schedule Stripe subscription reconciliation automatically', function () {
|
||||
$schedule = app(Schedule::class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user