Monitor's partner card read phase flags that only ever describe the mirror, so the owner rendered as not provisioned on the mirror

This commit is contained in:
Gmer4Lfe
2026-08-21 21:43:00 -04:00
parent 96b907acbc
commit 4808a57289
+18
View File
@@ -74,6 +74,20 @@ function vv_partner_state(): array {
$setupDb = vv_setup_state_read();
// HOST<n>_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,