fix(server): enable disabled self-hosted servers again on validation

On self-hosted, a validation that connects now clears force_disabled. The unreachable cleanup skips the localhost server, and the server page explains why a server is disabled. Cloud and transferred servers stay disabled.

Closes #12475
This commit is contained in:
Andras Bacsai
2026-11-06 18:57:06 +01:00
parent 5af4715b8a
commit f7ea962145
4 changed files with 101 additions and 1 deletions
+17
View File
@@ -1438,6 +1438,15 @@ $siteAddress {
return $this->settings->force_disabled;
}
/**
* On self-hosted, only the unreachable cleanup disables a server, so a working connection can enable it again.
* On Cloud the flag enforces the plan server limit, and a transferred server stays an archive.
*/
public function canBeReEnabled(): bool
{
return $this->settings->force_disabled === true && ! isCloud() && ! $this->isTransferredAway();
}
/**
* Server was migrated away from this Coolify instance (source side).
* Must not be revalidated or re-enabled as a live managed host.
@@ -2544,6 +2553,11 @@ $siteAddress {
public function validateConnection(bool $justCheckingNewKey = false)
{
// A validation enables a disabled self-hosted server again, but only when the connection works.
$isReEnabling = $this->canBeReEnabled() && ! $this->hasPlaceholderIp();
if ($isReEnabling) {
$this->forceEnableServer();
}
if ($this->skipServer()) {
return ['uptime' => false, 'error' => 'Server skipped.'];
}
@@ -2564,6 +2578,9 @@ $siteAddress {
return ['uptime' => true, 'error' => null];
} catch (\Throwable $e) {
if ($isReEnabling) {
$this->forceDisableServer();
}
$error = $e->getMessage();
if ($error === SshMultiplexingHelper::HOST_KEY_CHANGED_MESSAGE && ! $this->recordHostKeyMismatch()) {
$error = 'SSH host key verification failed, but the server still sends the trusted host key.';