Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: remove PullHelperImageJob and mass server scheduling

Andras Bacsai318cd18dde8c
diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php
index 2a06428e23..0bf763d78d 100644
--- a/app/Actions/Server/UpdateCoolify.php
+++ b/app/Actions/Server/UpdateCoolify.php
@@ -2,7 +2,6 @@
namespace App\Actions\Server;
-use App\Jobs\PullHelperImageJob;
use App\Models\Server;
use Illuminate\Support\Sleep;
use Lorisleiva\Actions\Concerns\AsAction;
@@ -50,7 +49,9 @@ class UpdateCoolify
private function update()
{
- PullHelperImageJob::dispatch($this->server);
+ $helperImage = config('constants.coolify.helper_image');
+ $latest_version = getHelperVersion();
+ instant_remote_process(["docker pull -q {$helperImage}:{$latest_version}"], $this->server, false);
$image = config('constants.coolify.registry_url').'/coollabsio/coolify:'.$this->latestVersion;
instant_remote_process(["docker pull -q $image"], $this->server, false);
diff --git a/app/Jobs/PullHelperImageJob.php b/app/Jobs/PullHelperImageJob.php
deleted file mode 100644
index 7cdf1b81a2..0000000000
--- a/app/Jobs/PullHelperImageJob.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Models\Server;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldBeEncrypted;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-
-class PullHelperImageJob implements ShouldBeEncrypted, ShouldQueue
-{
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
- public $timeout = 1000;
-
- public function __construct(public Server $server)
- {
- $this->onQueue('high');
- }
-
- public function handle(): void
- {
- $helperImage = config('constants.coolify.helper_image');
- $latest_version = getHelperVersion();
- instant_remote_process(["docker pull -q {$helperImage}:{$latest_version}"], $this->server, false);
- }
-}
diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php
index cd1c05de4a..62b5760126 100644
--- a/app/Models/InstanceSettings.php
+++ b/app/Models/InstanceSettings.php
@@ -2,7 +2,6 @@
namespace App\Models;
-use App\Jobs\PullHelperImageJob;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Spatie\Url\Url;
@@ -35,14 +34,6 @@ class InstanceSettings extends Model
protected static function booted(): void
{
static::updated(function ($settings) {
- if ($settings->wasChanged('helper_version')) {
- Server::chunkById(100, function ($servers) {
- foreach ($servers as $server) {
- PullHelperImageJob::dispatch($server);
- }
- });
- }
-
// Clear trusted hosts cache when FQDN changes
if ($settings->wasChanged('fqdn')) {
\Cache::forget('instance_settings_fqdn_host');
diff --git a/tests/Feature/InstanceSettingsHelperVersionTest.php b/tests/Feature/InstanceSettingsHelperVersionTest.php
deleted file mode 100644
index e731fa8b4c..0000000000
--- a/tests/Feature/InstanceSettingsHelperVersionTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-use App\Jobs\PullHelperImageJob;
-use App\Models\InstanceSettings;
-use App\Models\Server;
-use App\Models\User;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Illuminate\Support\Facades\Queue;
-
-uses(RefreshDatabase::class);
-
-it('dispatches PullHelperImageJob when helper_version changes', function () {
- Queue::fake();
-
- // Create user and servers
- $user = User::factory()->create();
- $team = $user->teams()->first();
- Server::factory()->count(3)->create(['team_id' => $team->id]);
-
- $settings = InstanceSettings::firstOrCreate([], ['helper_version' => 'v1.0.0']);
-
- // Change helper_version
- $settings->helper_version = 'v1.2.3';
- $settings->save();
-
- // Verify PullHelperImageJob was dispatched for all servers
- Queue::assertPushed(PullHelperImageJob::class, 3);
-});
-
-it('does not dispatch PullHelperImageJob when helper_version is unchanged', function () {
- Queue::fake();
-
- // Create user and servers
- $user = User::factory()->create();
- $team = $user->teams()->first();
- Server::factory()->count(3)->create(['team_id' => $team->id]);
-
- $settings = InstanceSettings::firstOrCreate([], ['helper_version' => 'v1.0.0']);
- $currentVersion = $settings->helper_version;
-
- // Set to same value
- $settings->helper_version = $currentVersion;
- $settings->save();
-
- // Verify no jobs were dispatched
- Queue::assertNotPushed(PullHelperImageJob::class);
-});
-
-it('does not dispatch PullHelperImageJob when other fields change', function () {
- Queue::fake();
-
- // Create user and servers
- $user = User::factory()->create();
- $team = $user->teams()->first();
- Server::factory()->count(3)->create(['team_id' => $team->id]);
-
- $settings = InstanceSettings::firstOrCreate([], ['helper_version' => 'v1.0.0']);
-
- // Change different field
- $settings->is_auto_update_enabled = ! $settings->is_auto_update_enabled;
- $settings->save();
-
- // Verify no jobs were dispatched
- Queue::assertNotPushed(PullHelperImageJob::class);
-});
-
-it('detects helper_version changes with wasChanged', function () {
- $changeDetected = false;
-
- InstanceSettings::updated(function ($settings) use (&$changeDetected) {
- if ($settings->wasChanged('helper_version')) {
- $changeDetected = true;
- }
- });
-
- $settings = InstanceSettings::firstOrCreate([], ['helper_version' => 'v1.0.0']);
- $settings->helper_version = 'v2.0.0';
- $settings->save();
-
- expect($changeDetected)->toBeTrue();
-});