fix(upgrade): keep Coolify running when Docker reports IPv6 gateways with a prefix

Docker Engine 27.0 to 28.0.0 reports an IPv6 network gateway with its
prefix length (fd00::1/64) until the daemon restarts (moby/moby#49520).
The Docker CLI 29 and Compose 5 in the helper image reject it, so
deployments failed and the upgrade left Coolify stopped.

- Stop the upgrade before it changes containers when the coolify network
  has such a gateway, and tell the user to restart or upgrade Docker.
- Create a new coolify network again without IPv6 when Docker reports
  its gateway with a prefix.
- Report an error, not "Upgrade complete", when the new Coolify
  containers do not start.
- Add the fix to deployment errors that contain this ParseAddr failure.

Fixes #11583
This commit is contained in:
Andras Bacsai
2026-10-16 21:19:35 +02:00
parent f1f7d5269e
commit 420692c020
7 changed files with 304 additions and 35 deletions
@@ -0,0 +1,63 @@
<?php
/**
* Runs the detached container restart block of the upgrade script with a fake docker.
*
* @return array{exitCode: int, status: string}
*/
function runUpgradeScriptContainerStart(string $script, int $composeExitCode, bool $coolifyRunning): array
{
$dir = sys_get_temp_dir().'/upgrade-start-'.bin2hex(random_bytes(4));
mkdir($dir);
touch("{$dir}/status");
$source = file_get_contents(getcwd().'/'.$script);
preg_match('/^nohup bash -c "\n(.*?)^" >>"\$LOGFILE" 2>&1 &$/ms', $source, $match);
$running = $coolifyRunning ? 'true' : 'false';
$harness = <<<BASH
LOGFILE="{$dir}/upgrade.log"
STATUS_FILE="{$dir}/status"
DOCKER_CONFIG_MOUNT=''
REGISTRY_URL='docker.io'
LATEST_HELPER_VERSION='1.0.17'
LATEST_IMAGE='4.4.7'
docker() {
case "\$1" in
run) return {$composeExitCode} ;;
inspect) echo {$running} ;;
esac
}
sleep() { :; }
export -f docker sleep
bash -c "
{$match[1]}"
BASH;
exec('bash -c '.escapeshellarg($harness).' >/dev/null 2>&1', result_code: $exitCode);
$status = is_file("{$dir}/status") ? file_get_contents("{$dir}/status") : '';
exec('rm -rf '.escapeshellarg($dir));
return ['exitCode' => $exitCode, 'status' => $status];
}
it('reports an error when the new Coolify containers do not start', function (string $script) {
$result = runUpgradeScriptContainerStart($script, composeExitCode: 1, coolifyRunning: false);
expect($result['exitCode'])->toBe(1)
->and($result['status'])->toStartWith('error|')
->toContain('upgrade log');
})->with(['scripts/upgrade.sh', 'other/nightly/upgrade.sh']);
it('completes the upgrade when the coolify container runs but is not healthy within the wait timeout', function (string $script) {
$result = runUpgradeScriptContainerStart($script, composeExitCode: 1, coolifyRunning: true);
expect($result['exitCode'])->toBe(0)
->and($result['status'])->toBe('');
})->with(['scripts/upgrade.sh', 'other/nightly/upgrade.sh']);
it('completes the upgrade when docker compose up succeeds', function (string $script) {
$result = runUpgradeScriptContainerStart($script, composeExitCode: 0, coolifyRunning: true);
expect($result['exitCode'])->toBe(0)
->and($result['status'])->toBe('');
})->with(['scripts/upgrade.sh', 'other/nightly/upgrade.sh']);