mirror of
https://github.com/coollabsio/coolify.git
synced 2026-03-11 08:55:47 +00:00
Add configurable `capacity_wait_timeout` to runner configs and use it in `ProvisionGithubRunnerJob` to re-dispatch jobs while at capacity, preserving initial wait start time and stopping after timeout. Improve runner provisioning by caching an extracted runner template and copying it into new runner directories. Update Livewire GitHub Runners UI to lazy-load accessible repositories via `wire:init`, track loading state, add timeout input, and remove preinstall binary action. Add/extend feature tests for capacity retry timeout behavior and deferred repository loading.
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class GithubRunnerConfig extends BaseModel
|
|
{
|
|
protected $guarded = [];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'labels' => 'array',
|
|
'is_enabled' => 'boolean',
|
|
'max_runners' => 'integer',
|
|
'capacity_wait_timeout' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function organization(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => $this->githubApp?->organization,
|
|
);
|
|
}
|
|
|
|
public function server(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Server::class);
|
|
}
|
|
|
|
public function githubApp(): BelongsTo
|
|
{
|
|
return $this->belongsTo(GithubApp::class);
|
|
}
|
|
|
|
public function executions(): HasMany
|
|
{
|
|
return $this->hasMany(GithubRunnerExecution::class);
|
|
}
|
|
|
|
public function activeRunnerCount(): int
|
|
{
|
|
return $this->executions()
|
|
->whereIn('status', ['queued', 'provisioning', 'running', 'cleaning'])
|
|
->count();
|
|
}
|
|
|
|
public function hasCapacity(): bool
|
|
{
|
|
return $this->activeRunnerCount() < $this->max_runners;
|
|
}
|
|
|
|
public function matchesLabels(array $requestedLabels): bool
|
|
{
|
|
$configLabels = collect($this->labels)->map(fn ($l) => strtolower($l));
|
|
|
|
return collect($requestedLabels)
|
|
->every(fn ($label) => $configLabels->contains(strtolower($label)));
|
|
}
|
|
}
|