diff --git a/Plugin/unraid/include/monitor.php b/Plugin/unraid/include/monitor.php index a907431..f312e21 100644 --- a/Plugin/unraid/include/monitor.php +++ b/Plugin/unraid/include/monitor.php @@ -74,6 +74,20 @@ function vv_partner_state(): array { $setupDb = vv_setup_state_read(); + // HOST_PHASE*_DONE always describes the MIRROR — it is the owner's record of how far it got + // provisioning the other side, so the owner's own slot has no such flag and never will. Read from + // the mirror that made the owner compute phase 0 and render "Not provisioned" on the very host + // that had just finished onboarding it. An ACTIVE partnership is the authority on whether the + // mesh is provisioned; the flags only say who did what to whom. Same rule as vv_pt_nodes(). + $ptFile = STATE_DIR . '/partnership_' . vv_get_hostname() . '.db'; + $ptRaw = []; + foreach ((is_readable($ptFile) ? file($ptFile) : []) ?: [] as $line) { + [$k, $v] = array_pad(explode('=', trim($line), 2), 2, ''); + $ptRaw[trim($k)] = trim($v, "\"'"); + } + $ptActive = ($ptRaw['state'] ?? '') === 'ACTIVE'; + $ptMembers = array_filter([strtolower($ptRaw['owner'] ?? ''), strtolower($ptRaw['mirror'] ?? '')]); + $hosts = []; foreach ($hostIds as $id) { $hostname = $vars[$id] ?? ''; @@ -84,6 +98,10 @@ function vv_partner_state(): array { $onboardPhase = $isMe ? null : (($setupDb[$id . '_PHASE2_DONE'] ?? '') === 'true' ? 2 : (($setupDb[$id . '_PHASE1_DONE'] ?? '') === 'true' ? 1 : 0)); + if ($onboardPhase !== null && $onboardPhase < 2 && $ptActive + && in_array(strtolower($hostname), $ptMembers, true)) { + $onboardPhase = 2; + } $hosts[] = [ 'id' => $id, 'hostname' => $hostname,