fix(docker-cleanup): skip broadcast for executions of deleted servers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras BacsaiandClaude Opus 5.5 committed 2026-10-28 22:13:27 +01:00
1 parent 70c1bcb138
commit 24648d4b20
2 files changed
+32 -4

No files matched your search

+16 -4
View File
@@ -13,13 +13,25 @@ class DockerCleanupDone implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(public DockerCleanupExecution $execution) {}
public ?int $teamId;
public function __construct(public DockerCleanupExecution $execution)
{
$this->teamId = $execution->server?->team_id;
}
/**
* A deleted server has no team to tell, so nothing is broadcast.
*
* @return array<int, PrivateChannel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('team.'.$this->execution->server->team->id),
];
if (is_null($this->teamId)) {
return [];
}
return [new PrivateChannel("team.{$this->teamId}")];
}
/**
+16
View File
@@ -867,3 +867,19 @@ it('keeps the images of an application while it deploys, because its new images
->and($removals->first())->toContain("'{$idle->uuid}:old'")
->not->toContain($deploying->uuid);
})->with(['queued', 'in_progress']);
it('fails an interrupted cleanup of a deleted server without breaking its broadcast', function () {
Carbon::setTestNow(Carbon::create(2026, 10, 28, 12, 0, 0, 'UTC'));
Queue::fake();
Notification::fake();
$server = dockerCleanupReachableServer();
$interrupted = DockerCleanupExecution::create(['server_id' => $server->id]);
$server->delete();
Carbon::setTestNow(now()->addSeconds(CleanupDocker::overlapLockExpiresAfter() + 1));
DockerCleanupJob::failInterruptedExecutions();
expect($interrupted->fresh()->status)->toBe('failed');
Queue::assertPushed(BroadcastEvent::class, fn (BroadcastEvent $job) => $job->event instanceof DockerCleanupDone
&& $job->event->broadcastOn() === []);
});