Fix: Traefik proxy startup issues (#7400)

This commit is contained in:
Andras Bacsai 2025-11-28 20:39:28 +01:00 committed by GitHub
commit 1dd2a81f89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 69 additions and 7 deletions

View file

@ -10,6 +10,7 @@
use App\Models\Server;
use App\Services\ProxyDashboardCacheService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
class Navbar extends Component
@ -72,7 +73,15 @@ public function restart()
// Check Traefik version after restart to provide immediate feedback
if ($this->server->proxyType() === ProxyTypes::TRAEFIK->value) {
CheckTraefikVersionForServerJob::dispatch($this->server, get_traefik_versions());
$traefikVersions = get_traefik_versions();
if ($traefikVersions !== null) {
CheckTraefikVersionForServerJob::dispatch($this->server, $traefikVersions);
} else {
Log::warning('Traefik version check skipped: versions.json data unavailable', [
'server_id' => $this->server->id,
'server_name' => $this->server->name,
]);
}
}
} catch (\Throwable $e) {
return handleError($e, $this);

View file

@ -79,12 +79,11 @@ protected function getTraefikVersions(): ?array
// Load from global cached helper (Redis + filesystem)
$versionsData = get_versions_data();
$this->cachedVersionsFile = $versionsData;
if (! $versionsData) {
return null;
}
$this->cachedVersionsFile = $versionsData;
$traefikVersions = data_get($versionsData, 'traefik');
return is_array($traefikVersions) ? $traefikVersions : null;

View file

@ -6,6 +6,20 @@
use App\Models\Server;
use Symfony\Component\Yaml\Yaml;
/**
* Check if a network name is a Docker predefined system network.
* These networks cannot be created, modified, or managed by docker network commands.
*
* @param string $network Network name to check
* @return bool True if it's a predefined network that should be skipped
*/
function isDockerPredefinedNetwork(string $network): bool
{
// Only filter 'default' and 'host' to match existing codebase patterns
// See: bootstrap/helpers/parsers.php:891, bootstrap/helpers/shared.php:689,748
return in_array($network, ['default', 'host'], true);
}
function collectProxyDockerNetworksByServer(Server $server)
{
if (! $server->isFunctional()) {
@ -66,8 +80,12 @@ function collectDockerNetworksByServer(Server $server)
$networks->push($network);
$allNetworks->push($network);
}
$networks = collect($networks)->flatten()->unique();
$allNetworks = $allNetworks->flatten()->unique();
$networks = collect($networks)->flatten()->unique()->filter(function ($network) {
return ! isDockerPredefinedNetwork($network);
});
$allNetworks = $allNetworks->flatten()->unique()->filter(function ($network) {
return ! isDockerPredefinedNetwork($network);
});
if ($server->isSwarm()) {
if ($networks->count() === 0) {
$networks = collect(['coolify-overlay']);
@ -219,8 +237,8 @@ function generateDefaultProxyConfiguration(Server $server, array $custom_command
$array_of_networks = collect([]);
$filtered_networks = collect([]);
$networks->map(function ($network) use ($array_of_networks, $filtered_networks) {
if ($network === 'host') {
return; // network-scoped alias is supported only for containers in user defined networks
if (isDockerPredefinedNetwork($network)) {
return; // Predefined networks cannot be used in network configuration
}
$array_of_networks[$network] = [

View file

@ -153,3 +153,39 @@
expect($result)->toBeTrue();
});
it('identifies default as predefined network', function () {
expect(isDockerPredefinedNetwork('default'))->toBeTrue();
});
it('identifies host as predefined network', function () {
expect(isDockerPredefinedNetwork('host'))->toBeTrue();
});
it('identifies coolify as not predefined network', function () {
expect(isDockerPredefinedNetwork('coolify'))->toBeFalse();
});
it('identifies coolify-overlay as not predefined network', function () {
expect(isDockerPredefinedNetwork('coolify-overlay'))->toBeFalse();
});
it('identifies custom networks as not predefined', function () {
$customNetworks = ['my-network', 'app-network', 'custom-123'];
foreach ($customNetworks as $network) {
expect(isDockerPredefinedNetwork($network))->toBeFalse();
}
});
it('identifies bridge as not predefined (per codebase pattern)', function () {
// 'bridge' is technically a Docker predefined network, but existing codebase
// only filters 'default' and 'host', so we maintain consistency
expect(isDockerPredefinedNetwork('bridge'))->toBeFalse();
});
it('identifies none as not predefined (per codebase pattern)', function () {
// 'none' is technically a Docker predefined network, but existing codebase
// only filters 'default' and 'host', so we maintain consistency
expect(isDockerPredefinedNetwork('none'))->toBeFalse();
});