@cotal-ai/cli 0.169.0 → 0.171.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +24 -8
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +40 -18
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/channels.js +1 -1
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +9 -4
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +4 -3
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +19 -5
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +70 -6
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +17 -8
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +5 -4
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +19 -10
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/manager-service.js +1 -1
- package/dist/commands/manager-service.js.map +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +2 -7
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +20 -2
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +6 -15
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.js +3 -1
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +19 -5
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +5 -1
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +22 -16
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +36 -16
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +4 -8
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-gone.d.ts.map +1 -1
- package/dist/commands/stack-gone.js +2 -2
- package/dist/commands/stack-gone.js.map +1 -1
- package/dist/commands/stack-up.d.ts +2 -2
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +152 -83
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team.d.ts.map +1 -1
- package/dist/commands/team.js +4 -1
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/up.d.ts +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +24 -117
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.js +10 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +7 -5
- package/dist/commands/use.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +29 -27
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/channel-seed.d.ts +15 -0
- package/dist/lib/channel-seed.d.ts.map +1 -0
- package/dist/lib/channel-seed.js +121 -0
- package/dist/lib/channel-seed.js.map +1 -0
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +4 -2
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/reset-space-plan.d.ts +3 -2
- package/dist/lib/reset-space-plan.d.ts.map +1 -1
- package/dist/lib/reset-space-plan.js +9 -7
- package/dist/lib/reset-space-plan.js.map +1 -1
- package/dist/lib/self-exec.d.ts +1 -1
- package/dist/lib/self-exec.d.ts.map +1 -1
- package/dist/lib/self-exec.js +16 -11
- package/dist/lib/self-exec.js.map +1 -1
- package/dist/lib/service-systemd-files.js +2 -2
- package/dist/lib/service-systemd-files.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +4 -0
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +13 -0
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/store-dir.d.ts +2 -0
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +16 -0
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +15 -5
- package/dist/render.js.map +1 -1
- package/package.json +4 -4
package/dist/commands/status.js
CHANGED
|
@@ -3,7 +3,7 @@ import { drainAndClose } from "@cotal-ai/core";
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { CotalEndpoint, agentFilePath, dialerFor, EpEnvelopeError, formatAge, isReachable, isStreamNotFound, mintCreds, mintLifecycleUid, resolveService, realDirNoSymlink, invokeRepairingSplit, standaloneConnectOpts, newIdentity, idFromCreds, principalKey, DEV_OWNER, unansweredRequest, resolveAuthProvider, personaDir, } from "@cotal-ai/core";
|
|
6
|
-
import { stoppedLoopbackListener, stackRunsUnderOtherHome, accountInventory, authDir, isCommandFailure, readMaintenanceJournal, recordsElsewhereError, recordsElsewhereText, restoreRolledBackRuns, targetErrorSpace, brokerAddressForDisplay, brokerCheck, canonicalRoot, CLI_USER_ACTOR, codeSpan, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, folderSpaceOverSelection, meshesForRoot, resolveReadsLiveness, stoppedStack, unsettledStackOperation, withdrawOperationNote, hasUserAuthState, homeCotalDir, installationWriter, cachedPreferences, loadLaunchPersonaFile, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadManagerInstanceIdentity, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, NATS_PIDFILE, oneLine, spaceKey, PREFERENCE_KEYS, plainFlag, preflightTarget, presentationOf, principalFromBearer, verifyIdentityPin, probeWebReadiness, readCurrent, readMeshRegistry, readPidfile, preparedRecordSkipped, readPreparedSpaces, stackJournalPath, readRenewalRecord, recordOperationSpace, renderWorkspaceError, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, workspaceSecretStore, displayWidth, terminalWidth, wrapWords, writeResult, workspaceErrorParts, preferencesPath, preferencesFolderWarning, cotalDirLink, movedProject, spaceStreamsAbsent, spaceStreamsExpected, resolveControlTarget, } from "@cotal-ai/workspace";
|
|
6
|
+
import { stoppedLoopbackListener, stackRunsUnderOtherHome, accountInventory, authDir, isCommandFailure, readMaintenanceJournal, recordsElsewhereError, recordsElsewhereText, restoreRolledBackRuns, targetErrorSpace, brokerAddressForDisplay, brokerCheck, brokerUrlKey, canonicalRoot, CLI_USER_ACTOR, codeSpan, credentialFileExposure, CommandFailure, deliveryCredsKey, DELIVERY_PIDFILE, extensionsDir, findCotalRoot, folderSpaceOverSelection, meshesForRoot, resolveReadsLiveness, stoppedStack, unsettledStackOperation, withdrawOperationNote, hasUserAuthState, homeCotalDir, installationWriter, cachedPreferences, loadLaunchPersonaFile, resolvePreference, isMeshRegistryError, isWorkspaceTargetError, jsonFlag, loadManagerInstanceIdentity, loadSoleSpaceAuth, localProcessPath, localProcessVisible, MANAGER_PIDFILE, NATS_PIDFILE, oneLine, spaceKey, PREFERENCE_KEYS, plainFlag, preflightTarget, presentationOf, principalFromBearer, verifyIdentityPin, probeWebReadiness, readCurrent, readMeshRegistry, readPidfile, preparedRecordSkipped, readPreparedSpaces, stackJournalPath, readRenewalRecord, recordOperationSpace, renderWorkspaceError, resolveMeshTarget, serverFlag, spaceFlag, userAuthStateDir, WEB_PIDFILE, workspaceSecretStore, displayWidth, terminalWidth, wrapWords, writeResult, workspaceErrorParts, preferencesPath, preferencesFolderWarning, cotalDirLink, movedProject, spaceStreamsAbsent, spaceStreamsExpected, resolveControlTarget, } from "@cotal-ai/workspace";
|
|
7
7
|
import { localProcessSurface } from "../ext-loader.js";
|
|
8
8
|
import { cliVersion, cliProvenance, readExtensionVersions } from "../lib/version.js";
|
|
9
9
|
import { agentSkillsSkew } from "../lib/agent-skills.js";
|
|
@@ -32,7 +32,8 @@ import { additiveTeamRecordedState, listAdditiveTeamAttempts } from "../lib/team
|
|
|
32
32
|
import { maintenanceNextStep, rolledBackNotes } from "../lib/restore.js";
|
|
33
33
|
import { journalRecordedElsewhere, readStackJournal, serviceHeldRecords, STACK_ADAPTER, STACK_DEFINITION, stackStartedWithoutManager, stackOperationBlock, stackRootGone, unfinishedStackOperation, } from "../lib/stack-journal.js";
|
|
34
34
|
import { cotalLinkHere, homeHoldsStack, linkedCotalRemedy } from "../lib/paths.js";
|
|
35
|
-
import {
|
|
35
|
+
import { channelSeedRestartBlock } from "../lib/channel-seed.js";
|
|
36
|
+
import { rootStoreProblem } from "../lib/store-dir.js";
|
|
36
37
|
import { stackStoreWarnings } from "../lib/store-identity.js";
|
|
37
38
|
import { natsServerLabel } from "../lib/nats-bin.js";
|
|
38
39
|
import { askManager } from "@cotal-ai/workspace/control";
|
|
@@ -181,13 +182,36 @@ export async function status(args) {
|
|
|
181
182
|
// health they never checked. It is read before the folder section because that section renders
|
|
182
183
|
// the delivery process row, and a live pid means nothing without it.
|
|
183
184
|
const preflight = selected.ok && selected.target.mode !== "user" ? await preflightTarget(selected.target) : undefined;
|
|
184
|
-
const responder = await readResponderAxis(selected, preflight);
|
|
185
|
+
const responder = await readResponderAxis(selected, preflight, gaps);
|
|
185
186
|
const folder = blocked ? unreadFolder(root, blocked) : await readFolder(root, selected, values, responder.state, gaps, hints);
|
|
187
|
+
if (selected.ok) {
|
|
188
|
+
try {
|
|
189
|
+
const renewal = readRenewalRecord(selected.target.root, selected.target.space);
|
|
190
|
+
if (renewal?.adoption?.ok === false) {
|
|
191
|
+
gaps.add("RENEWAL_ADOPTION_REFUSED", "the recorded renewal adoption was refused; a bound delivery responder does not clear that finding", { root: selected.target.root, space: selected.target.space });
|
|
192
|
+
hints.push("start or repair this space's manager, the renewal owner, so it re-signs the daemon credentials and the broker accepts them; do not respawn agents for this finding");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
gaps.add("RENEWAL_RECORD_UNREADABLE", error.message, { root: selected.target.root, space: selected.target.space });
|
|
197
|
+
if (isCommandFailure(error) && error.remedy)
|
|
198
|
+
hints.push(error.remedy);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
186
201
|
const meshes = await readMeshes(cwd, selected, Boolean(values.all), gaps, offline, preflight);
|
|
187
202
|
const maintenance = blocked ? { root, space: null, state: "unreadable", attemptId: null, next: null } : readMaintenance(root, gaps);
|
|
188
203
|
const recovery = backupRecovery(maintenance);
|
|
189
204
|
const selectedHints = [];
|
|
190
205
|
const target = await readSelected(selected, responder, folder, gaps, selectedHints, preflight);
|
|
206
|
+
// Do not offer the conditional store reset when this folder needs a channel seed repair first,
|
|
207
|
+
// while a maintenance journal holds the store, or if the store is unwritable.
|
|
208
|
+
if (folder.storedState && folder.processSpace !== null && maintenance === null && !(target.channelSeedBlocksRestart && target.root === root) && !rootStoreProblem(root)) {
|
|
209
|
+
const cmd = displayCmd();
|
|
210
|
+
const resetSpace = storeResetSpace(root, folder.processSpace);
|
|
211
|
+
hints.push(resetSpace !== undefined
|
|
212
|
+
? `if the stored JetStream state is stale: \`${cmd} reset store ${resetSpace}\`, then \`up\` with your usual flags`
|
|
213
|
+
: `if the stored JetStream state is stale: \`${cmd} clean store --force\`, then \`up\` with your usual flags (\`clean all\` also resets identity)`);
|
|
214
|
+
}
|
|
191
215
|
// A held backup must be released before this root can start. Keep the selection's diagnostics,
|
|
192
216
|
// but replace its ordinary restart advice with the journal's recovery step.
|
|
193
217
|
if (recovery)
|
|
@@ -241,7 +265,7 @@ export async function status(args) {
|
|
|
241
265
|
...(parts ? { partial: { message: `status could not read ${parts === 1 ? "one part" : `${parts} parts`} of what it reports; the warnings name ${parts === 1 ? "it" : "each"}` } } : {}),
|
|
242
266
|
}, (result) => statusView(result, Boolean(values.verbose), Boolean(values.all) || Boolean(values.wide)));
|
|
243
267
|
if (values.components)
|
|
244
|
-
await printComponentHealth(selected);
|
|
268
|
+
await printComponentHealth(selected, store);
|
|
245
269
|
}
|
|
246
270
|
/** Why this account cannot list or search `root`, or undefined when it can. */
|
|
247
271
|
function folderReadProblem(root) {
|
|
@@ -483,21 +507,22 @@ function readExtensions(gaps) {
|
|
|
483
507
|
*
|
|
484
508
|
* READ-ONLY AND BEST EFFORT. A workspace that never launched a daemon locally (an adopted or remote
|
|
485
509
|
* one) has no creds file, and that is not an error: the caller then does not check the holder, the
|
|
486
|
-
* same concession `waitForDeliveryLease` makes for an adopted daemon.
|
|
487
|
-
*
|
|
510
|
+
* same concession `waitForDeliveryLease` makes for an adopted daemon. An existing credential that
|
|
511
|
+
* cannot be read privately refuses the check rather than silently disabling holder attribution. */
|
|
488
512
|
async function expectedDeliveryHolder(target) {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
catch {
|
|
513
|
+
const key = deliveryCredsKey(target.space, { injected: false, root: target.root });
|
|
514
|
+
const path = join(target.root, ".cotal", key);
|
|
515
|
+
const stat = lstatSync(path, { throwIfNoEntry: false });
|
|
516
|
+
const exposure = stat?.isFile() ? credentialFileExposure(path, stat) : undefined;
|
|
517
|
+
if (exposure)
|
|
518
|
+
throw new CommandFailure("refused", "PERMISSION_DENIED", `${path}: ${exposure.reason}`, { remedy: exposure.remedy, target: { path, space: target.space } });
|
|
519
|
+
const creds = await workspaceSecretStore(target.root).get(key);
|
|
520
|
+
if (!creds)
|
|
499
521
|
return undefined;
|
|
500
|
-
|
|
522
|
+
// The daemon declares no owner/actor, so the endpoint falls back to DEV_OWNER for the owner and
|
|
523
|
+
// to the connection id for the actor: `local.<idFromCreds>`. Built through `principalKey` rather
|
|
524
|
+
// than string concatenation so this tracks the one definition of the dot-form.
|
|
525
|
+
return principalKey(DEV_OWNER, idFromCreds(creds)).key;
|
|
501
526
|
}
|
|
502
527
|
/** Read the delivery responder axis for the bare-status rows (#1576).
|
|
503
528
|
*
|
|
@@ -514,13 +539,22 @@ async function expectedDeliveryHolder(target) {
|
|
|
514
539
|
*
|
|
515
540
|
* `leased` says whether the read found a delivery lease record. An open mesh runs no delivery
|
|
516
541
|
* daemon, so there a missing lease is the normal state rather than an unbound responder. */
|
|
517
|
-
async function readResponderAxis(selected, preflight) {
|
|
542
|
+
async function readResponderAxis(selected, preflight, gaps) {
|
|
518
543
|
let leased = false;
|
|
519
544
|
if (!selected.ok)
|
|
520
545
|
return { state: "unknown", leased };
|
|
521
546
|
const target = selected.target;
|
|
522
547
|
if (target.mode === "user")
|
|
523
548
|
return { state: "unknown", leased };
|
|
549
|
+
let holder;
|
|
550
|
+
try {
|
|
551
|
+
holder = await expectedDeliveryHolder(target);
|
|
552
|
+
}
|
|
553
|
+
catch (error) {
|
|
554
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
555
|
+
gaps.add("DELIVERY_CREDENTIAL_UNREADABLE", isCommandFailure(error) && error.remedy ? `${message}; ${error.remedy}` : message, { root: target.root, space: target.space });
|
|
556
|
+
return { state: "unknown", leased };
|
|
557
|
+
}
|
|
524
558
|
try {
|
|
525
559
|
if (!preflight?.ok)
|
|
526
560
|
return { state: "unknown", leased };
|
|
@@ -557,7 +591,6 @@ async function readResponderAxis(selected, preflight) {
|
|
|
557
591
|
// `--components` surface deliberately does NOT use it: that surface must tell a missing lease
|
|
558
592
|
// stream apart from a refused read, and flattening both to `unknown` would erase a
|
|
559
593
|
// distinction it reports.
|
|
560
|
-
const holder = await expectedDeliveryHolder(target);
|
|
561
594
|
const state = await deliveryResponderState(async () => { const lease = await ep.readDeliveryLease(0); leased = lease !== undefined; return lease; }, holder);
|
|
562
595
|
// A daemon killed before it could release shard 0 leaves its ready row, which names this
|
|
563
596
|
// folder's credential, until the bucket TTL removes it. When this folder's delivery pidfile
|
|
@@ -578,7 +611,6 @@ async function readResponderAxis(selected, preflight) {
|
|
|
578
611
|
}
|
|
579
612
|
}
|
|
580
613
|
async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
581
|
-
const cmd = displayCmd();
|
|
582
614
|
let stackJournal;
|
|
583
615
|
try {
|
|
584
616
|
stackJournal = lstatSync(stackJournalPath(root), { throwIfNoEntry: false }) === undefined ? "absent" : "present";
|
|
@@ -668,6 +700,11 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
|
668
700
|
processes.push({ name: component.name, state: "unreadable", pid: null, detail: `pidfile unreadable · ${e.message}` });
|
|
669
701
|
continue;
|
|
670
702
|
}
|
|
703
|
+
if (state.liveness === "unknown") {
|
|
704
|
+
const path = localProcessPath(component.pidFile, context);
|
|
705
|
+
gaps.add("PIDFILE_UNATTRIBUTABLE", `the ${component.name} pidfile ${path} cannot establish process state: ${state.note ?? "pid liveness unknown"}`, { root, space, process: component.name });
|
|
706
|
+
hints.push(`inspect ${path} and its process before restoring or removing that pidfile; no stopped state was inferred`);
|
|
707
|
+
}
|
|
671
708
|
if (component.name === "nats")
|
|
672
709
|
nats = state;
|
|
673
710
|
// #2073: a live manager pid used to print green `running` on the pidfile alone, which is how
|
|
@@ -698,6 +735,7 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
|
698
735
|
// rest of the report still stands.
|
|
699
736
|
if (isCommandFailure(error) && (error.code === "SCHEMA_INVALID" || error.code === "PERMISSION_DENIED")) {
|
|
700
737
|
unusable = true;
|
|
738
|
+
stackJournal = "unreadable";
|
|
701
739
|
gaps.add(error.code === "PERMISSION_DENIED" ? "STACK_JOURNAL_UNREADABLE" : "STACK_JOURNAL_INVALID", error.remedy ? `${error.message}; ${error.remedy}` : error.message, { root });
|
|
702
740
|
if (error.remedy)
|
|
703
741
|
hints.push(error.remedy);
|
|
@@ -707,8 +745,10 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
|
707
745
|
}
|
|
708
746
|
const brokerIndex = processes.findIndex((row) => row.name === "nats");
|
|
709
747
|
if (brokerIndex !== -1)
|
|
710
|
-
processes[brokerIndex] =
|
|
711
|
-
|
|
748
|
+
processes[brokerIndex] = unusable
|
|
749
|
+
? { name: "nats", state: "unreadable", pid: null, detail: "stack journal unreadable; no broker stopped state was inferred" }
|
|
750
|
+
: brokerProcess(processes[brokerIndex], controllerStack ? journal : undefined, gaps);
|
|
751
|
+
const managerIndex = !unusable && !controllerStack && (nats?.liveness === "alive" || nats?.liveness === "dead")
|
|
712
752
|
? processes.findIndex((row) => row.name === "manager" && row.state === "stopped" && row.pid === null)
|
|
713
753
|
: -1;
|
|
714
754
|
if (managerIndex !== -1 && legacyManagerStopped(root, space))
|
|
@@ -752,22 +792,7 @@ async function readFolder(root, selected, values, responder, gaps, hints) {
|
|
|
752
792
|
catch {
|
|
753
793
|
legacyElsewhere = false;
|
|
754
794
|
}
|
|
755
|
-
const storedState = !controllerStack && !elsewhere && !copiedStack && !legacyElsewhere && nats?.liveness !== "alive" && existsSync(join(root, ".cotal", "nats"));
|
|
756
|
-
// While a maintenance journal holds the store, clean store refuses, so it is not offered.
|
|
757
|
-
let maintained = false;
|
|
758
|
-
try {
|
|
759
|
-
maintained = readMaintenanceJournal(root) !== undefined;
|
|
760
|
-
}
|
|
761
|
-
catch {
|
|
762
|
-
maintained = true;
|
|
763
|
-
}
|
|
764
|
-
// Its next step is the unusable journal's, which every stack command refuses until it is fixed.
|
|
765
|
-
if (storedState && !maintained && !unusable) {
|
|
766
|
-
const resetSpace = storeResetSpace(root, space);
|
|
767
|
-
hints.push(resetSpace !== undefined
|
|
768
|
-
? `if the stored JetStream state is stale: \`${cmd} reset store ${resetSpace}\`, then \`up\` with your usual flags`
|
|
769
|
-
: `if the stored JetStream state is stale: \`${cmd} clean store --force\`, then \`up\` with your usual flags (\`clean all\` also resets identity)`);
|
|
770
|
-
}
|
|
795
|
+
const storedState = !unusable && !controllerStack && !elsewhere && !copiedStack && !legacyElsewhere && nats?.liveness !== "alive" && existsSync(join(root, ".cotal", "nats"));
|
|
771
796
|
// A stack started with --no-manager can still have a manager: a `manager` preset service run here.
|
|
772
797
|
let managerService = null;
|
|
773
798
|
if (noManager && journal)
|
|
@@ -876,8 +901,13 @@ function brokerProcess(legacy, journal, gaps) {
|
|
|
876
901
|
const row = { ...legacy, source: journal ? "owned-service" : "legacy-pidfile", legacyPidfile: { state, pid, detail }, ownedService: null };
|
|
877
902
|
if (!journal)
|
|
878
903
|
return row;
|
|
879
|
-
|
|
880
|
-
|
|
904
|
+
const recordedHome = journal.recovery?.home;
|
|
905
|
+
if (recordedHome !== homeCotalDir() && stackRunsUnderOtherHome(journal.root, journal)) {
|
|
906
|
+
const detail = recordedHome === undefined ? "stack member records are missing from this Cotal home" : `stack member records belong to ${recordedHome}`;
|
|
907
|
+
if (recordedHome === undefined)
|
|
908
|
+
gaps.add("FOLDER_BROKER_UNAVAILABLE", `owned broker observation unavailable · ${detail}`, { root: journal.root, space: journal.space });
|
|
909
|
+
return { ...row, state: "unknown", pid: null, detail };
|
|
910
|
+
}
|
|
881
911
|
try {
|
|
882
912
|
const instances = serviceInstances(journal.space, STACK_DEFINITION.broker);
|
|
883
913
|
if (instances.length === 0) {
|
|
@@ -1195,23 +1225,6 @@ function unusableServiceInstances(space) {
|
|
|
1195
1225
|
return isCommandFailure(error) && error.code === "SCHEMA_INVALID" ? error : undefined;
|
|
1196
1226
|
}
|
|
1197
1227
|
}
|
|
1198
|
-
/** Why the broker of the stack at `root` cannot start on its store: the one its stack journal recorded,
|
|
1199
|
-
* or `.cotal/nats`. */
|
|
1200
|
-
function rootStoreProblem(root) {
|
|
1201
|
-
let recorded;
|
|
1202
|
-
try {
|
|
1203
|
-
recorded = readStackJournal(root)?.journal.broker?.storeDir;
|
|
1204
|
-
}
|
|
1205
|
-
catch {
|
|
1206
|
-
recorded = undefined;
|
|
1207
|
-
}
|
|
1208
|
-
try {
|
|
1209
|
-
return storeWriteProblem(recorded ?? join(root, ".cotal", "nats"));
|
|
1210
|
-
}
|
|
1211
|
-
catch {
|
|
1212
|
-
return undefined;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
1228
|
async function readSelected(selected, responder, folder, gaps, hints, preflight) {
|
|
1216
1229
|
const cmd = displayCmd();
|
|
1217
1230
|
if (!selected.ok) {
|
|
@@ -1242,7 +1255,7 @@ async function readSelected(selected, responder, folder, gaps, hints, preflight)
|
|
|
1242
1255
|
// <name>`, `cotal up --user-auth`, …). A fixed `up --detach` hint would be right for at most one
|
|
1243
1256
|
// of the codes and point the others at a command that does not fix them. The section states the
|
|
1244
1257
|
// selection, and Next gives its repair once.
|
|
1245
|
-
const { message, remedy } = workspaceErrorParts({ kind: "target", error: e });
|
|
1258
|
+
const { message, remedy, restartRoot } = workspaceErrorParts({ kind: "target", error: e });
|
|
1246
1259
|
const d = e.details;
|
|
1247
1260
|
// A copy or a moved folder is reported under the space its records name, as the commands run here
|
|
1248
1261
|
// refuse under it, and says what the folder holds; Next gives the step they name.
|
|
@@ -1273,8 +1286,19 @@ async function readSelected(selected, responder, folder, gaps, hints, preflight)
|
|
|
1273
1286
|
hints.push(instances.remedy ?? instances.message);
|
|
1274
1287
|
else if (store)
|
|
1275
1288
|
hints.push(`${store.message}; ${store.remedy}`);
|
|
1276
|
-
else if (
|
|
1277
|
-
|
|
1289
|
+
else if (restartRoot !== undefined) {
|
|
1290
|
+
const block = channelSeedRestartBlock(restartRoot);
|
|
1291
|
+
if (block) {
|
|
1292
|
+
result.channelSeedBlocksRestart = true;
|
|
1293
|
+
hints.push(`Restart blocked: ${block.message}. ${block.remedy}`);
|
|
1294
|
+
}
|
|
1295
|
+
else
|
|
1296
|
+
hints.push(remedy ?? message);
|
|
1297
|
+
}
|
|
1298
|
+
else if (!d.unsettled || !servedStack(folder, result)) {
|
|
1299
|
+
const step = remedy ?? message;
|
|
1300
|
+
hints.push(e.code === "no-meshes" && d.root === undefined ? step.replaceAll("`cotal ", () => `\`${cmd} `) : step);
|
|
1301
|
+
}
|
|
1278
1302
|
else if (!folder.stackBlock && !folder.stackUnfinished)
|
|
1279
1303
|
hints.push(`start it with \`cotal up\` in ${d.root}`);
|
|
1280
1304
|
return result;
|
|
@@ -1351,16 +1375,24 @@ async function readSelected(selected, responder, folder, gaps, hints, preflight)
|
|
|
1351
1375
|
// starts it again rather than a registration to repair.
|
|
1352
1376
|
const flagged = (target.source === "flag-server" || target.source === "flag-space-override") && target.recordedServer !== target.server;
|
|
1353
1377
|
const offline = preflight.kind === "unreachable" && !flagged && target.origin === "up";
|
|
1378
|
+
const store = offline ? rootStoreProblem(target.root) : undefined;
|
|
1379
|
+
let seedBlock;
|
|
1354
1380
|
// A blocked stack refuses that `up`, and Next names the step that clears the block instead.
|
|
1355
1381
|
if (preflight.kind === "unreachable" && (flagged || offline) && !(servedStack(folder, base) && folder.stackBlock)) {
|
|
1356
|
-
const { message, remedy } = workspaceErrorParts({ kind: "preflight", failure: "unreachable", target, pruned: !offline && preflight.prune });
|
|
1357
|
-
|
|
1382
|
+
const { message, remedy, restartRoot } = workspaceErrorParts({ kind: "preflight", failure: "unreachable", target, pruned: !offline && preflight.prune });
|
|
1383
|
+
seedBlock = store || restartRoot === undefined ? undefined : channelSeedRestartBlock(restartRoot);
|
|
1384
|
+
if (store)
|
|
1385
|
+
hints.push(`${store.message}; ${store.remedy}`);
|
|
1386
|
+
else if (seedBlock)
|
|
1387
|
+
hints.push(`${message}. Restart blocked: ${seedBlock.message}. ${seedBlock.remedy}`);
|
|
1388
|
+
else
|
|
1389
|
+
hints.push(remedy === undefined ? message : `${message}; ${remedy}`);
|
|
1358
1390
|
}
|
|
1359
1391
|
if (preflight.kind === "non-nats-listener" || preflight.kind === "auth-unsupported" || preflight.kind === "jetstream-unsupported") {
|
|
1360
1392
|
const { message, remedy } = workspaceErrorParts({ kind: "preflight", failure: preflight.kind, target, pruned: false });
|
|
1361
1393
|
hints.push(remedy === undefined ? message : `${message}; ${remedy}`);
|
|
1362
1394
|
}
|
|
1363
|
-
return { ...base, connection: preflight.kind, ...(preflight.pid === undefined ? {} : { brokerPid: preflight.pid }), staleRecord: preflight.prune && !offline, snapshot: { state: "skipped", reason: "broker not connected" } };
|
|
1395
|
+
return { ...base, connection: preflight.kind, ...(seedBlock ? { channelSeedBlocksRestart: true } : {}), ...(preflight.pid === undefined ? {} : { brokerPid: preflight.pid }), staleRecord: preflight.prune && !offline, snapshot: { state: "skipped", reason: "broker not connected" } };
|
|
1364
1396
|
}
|
|
1365
1397
|
// The mesh-level statement of the same axis (#1576). The folder section says what this machine's
|
|
1366
1398
|
// delivery PROCESS is doing; this says whether the SPACE currently has a bound responder, which is
|
|
@@ -1479,8 +1511,8 @@ function personaCell(p, dim = false) {
|
|
|
1479
1511
|
}
|
|
1480
1512
|
function processCell(p) {
|
|
1481
1513
|
const detail = p.detail ? ` · ${p.detail}` : "";
|
|
1482
|
-
if (p.state === "unreadable")
|
|
1483
|
-
return cell(p.detail ?? "
|
|
1514
|
+
if (p.state === "unreadable" || p.state === "unknown")
|
|
1515
|
+
return cell(p.detail ?? "process state unknown", "failed");
|
|
1484
1516
|
if (p.state === "not-serving")
|
|
1485
1517
|
return cell(`not serving (pid ${p.pid})${detail}`, "failed");
|
|
1486
1518
|
if (p.state === "running")
|
|
@@ -1849,7 +1881,7 @@ function spacesOverview(r, wide) {
|
|
|
1849
1881
|
});
|
|
1850
1882
|
const columns = [{ key: "space", label: "Space" }, { key: "state", label: "Connection" }, { key: "detail", label: "Signs in" }];
|
|
1851
1883
|
if (!r.meshes.items.length && !r.meshes.unreadable.length)
|
|
1852
|
-
blocks.push({ kind: "lines", lines: [cell("No spaces registered", "hint"), cell(
|
|
1884
|
+
blocks.push({ kind: "lines", lines: [cell("No spaces registered", "hint"), cell(`Sign in to Cotal Cloud with \`${displayCmd()} login\`.`, "hint")] });
|
|
1853
1885
|
else if (wide) {
|
|
1854
1886
|
const groups = new Map();
|
|
1855
1887
|
for (const entry of r.meshes.items) {
|
|
@@ -1943,6 +1975,9 @@ function selectedOverview(r) {
|
|
|
1943
1975
|
if (r.folder.root === s.root && r.folder.processSpace === s.space && r.folder.controllerStack) {
|
|
1944
1976
|
blocks.push({ kind: "lines", lines: [cell("Controller stack · its members are the stack-* rows under Owned services", "hint")] }, ...stackLines(r.folder));
|
|
1945
1977
|
}
|
|
1978
|
+
else if (r.folder.root === s.root && r.folder.stackJournal === "unreadable") {
|
|
1979
|
+
blocks.push({ kind: "lines", lines: [cell("Stack journal unreadable · no stack membership or stopped state was inferred; see Owned services and the journal warning", "failed")] });
|
|
1980
|
+
}
|
|
1946
1981
|
else if (r.folder.root === s.root && r.folder.processSpace === s.space && r.folder.processes) {
|
|
1947
1982
|
blocks.push({ kind: "lines", lines: [cell("Legacy local process records", "label")] });
|
|
1948
1983
|
blocks.push({
|
|
@@ -1950,7 +1985,7 @@ function selectedOverview(r) {
|
|
|
1950
1985
|
columns: [{ key: "name", label: "Service" }, { key: "state", label: "State" }],
|
|
1951
1986
|
rows: r.folder.processes.map((item) => ({
|
|
1952
1987
|
name: item.name === "nats" ? "Broker" : item.name === "manager" ? "Manager" : item.name === "delivery" ? "Delivery" : item.name === "web" ? "Web" : item.name,
|
|
1953
|
-
state: item.state
|
|
1988
|
+
state: item.state !== "stopped" ? processCell(item) : stateCell(item.pid === null && item.detail !== "stopped" ? "not started" : item.detail ?? "stopped", "hint"),
|
|
1954
1989
|
})),
|
|
1955
1990
|
});
|
|
1956
1991
|
}
|
|
@@ -2037,6 +2072,7 @@ function nextActions(r) {
|
|
|
2037
2072
|
const elsewhere = dialed !== undefined && dialed.mode !== "user" && (dialed.source === "flag-server" || dialed.source === "flag-space-override")
|
|
2038
2073
|
&& r.meshes.items.find((m) => m.space === dialed.space)?.server !== dialed.server;
|
|
2039
2074
|
const stack = servedStack(r.folder, r.selected), own = stack !== undefined;
|
|
2075
|
+
const seedBlocksRestart = r.selected.channelSeedBlocksRestart;
|
|
2040
2076
|
// This folder's own stack is blocked the same way under another selection, and its block leads too.
|
|
2041
2077
|
const blocked = stack ?? folderStack(r.folder, r.selected);
|
|
2042
2078
|
const block = blocked ? r.folder.stackBlock : undefined;
|
|
@@ -2046,6 +2082,7 @@ function nextActions(r) {
|
|
|
2046
2082
|
const local = r.selected.resolved && r.selected.mode === "auth" && !r.folder.controllerStack && r.folder.root === r.selected.root && r.folder.processSpace === r.selected.space
|
|
2047
2083
|
&& !["manual", "catalog"].includes(r.meshes.items.find((m) => m.space === r.selected.space)?.origin ?? "up");
|
|
2048
2084
|
const exited = local ? (r.folder.processes ?? []).filter((row) => (row.name === "nats" || row.name === "manager") && row.state === "stopped" && (row.pid !== null || row.detail === "stopped")).map((row) => row.name) : [];
|
|
2085
|
+
const storeBlocked = !elsewhere && r.selected.resolved && r.selected.connection === "unreachable" && rootStoreProblem(r.selected.root) !== undefined;
|
|
2049
2086
|
if (r.selected.resolved && r.selected.connection === "broker-stopped")
|
|
2050
2087
|
items.unshift({ command: `kill -CONT ${r.selected.brokerPid}`, description: "Resume the stopped broker process so it answers again" });
|
|
2051
2088
|
else if (block && blocked) {
|
|
@@ -2059,10 +2096,10 @@ function nextActions(r) {
|
|
|
2059
2096
|
// running broker, and delivery does not start for a space that is not registered.
|
|
2060
2097
|
items.unshift(...(part.kind === "up"
|
|
2061
2098
|
? r.selected.resolved || !part.running.length
|
|
2062
|
-
? [{ command: restart, description: `Finish starting the stack: the last up ended before ${roleList(part.stopped)} started` }]
|
|
2099
|
+
? seedBlocksRestart ? [] : [{ command: restart, description: `Finish starting the stack: the last up ended before ${roleList(part.stopped)} started` }]
|
|
2063
2100
|
: [{ command: `${cmd} down --yes`, description: `Stop what the last up started: it ended before it registered the space, so up cannot finish it` }, { command: restart, description: "Then start the stack again" }]
|
|
2064
2101
|
: [{ command: `${cmd} down --yes`, description: `Finish stopping the stack: the last down ended with ${roleList(part.running)} still running` },
|
|
2065
|
-
...(part.stopped.length ? [{ command: `${cmd} up --root ${shellWord(stack.root)}`, description: "Or restart this stack's stopped members from its recorded inputs" }] : [])]));
|
|
2102
|
+
...(part.stopped.length && !seedBlocksRestart ? [{ command: `${cmd} up --root ${shellWord(stack.root)}`, description: "Or restart this stack's stopped members from its recorded inputs" }] : [])]));
|
|
2066
2103
|
}
|
|
2067
2104
|
else if (r.selected.resolved && r.selected.spaceStreams.state === "absent") {
|
|
2068
2105
|
// Up creates the streams again only while the stack's other members are stopped.
|
|
@@ -2076,18 +2113,18 @@ function nextActions(r) {
|
|
|
2076
2113
|
extra.push(`${absent.message}; ${absent.remedy}`);
|
|
2077
2114
|
}
|
|
2078
2115
|
}
|
|
2079
|
-
else if (own && r.selected.resolved && r.store?.state !== "full" && (memberGone || !elsewhere && r.selected.connection !== "ok" && r.selected.connection !== "reachable")) {
|
|
2116
|
+
else if (!storeBlocked && !seedBlocksRestart && own && r.selected.resolved && r.store?.state !== "full" && (memberGone || !elsewhere && r.selected.connection !== "ok" && r.selected.connection !== "reachable")) {
|
|
2080
2117
|
// `up` neither adopts nor replaces a service outside the stack that runs one of this root's
|
|
2081
2118
|
// records, so each is stopped first, with the stop `up` names.
|
|
2082
2119
|
const held = r.folder.heldServices ?? [], space = r.selected.space;
|
|
2083
2120
|
items.unshift(...held.map((row) => ({ command: `${cmd} svc stop ${row.definition} --instance ${row.instanceId} --space ${space} --yes`, description: `Stop the ${row.definition} service, which runs this root's ${row.record} (pid ${row.pid}) outside the stack` })), { command: `${cmd} up --root ${shellWord(r.selected.root)}${r.folder.noManager ? " --no-manager" : ""}`, description: held.length ? "Then restart this stack's stopped members from its recorded inputs" : "Restart this stack's stopped members from its recorded inputs" });
|
|
2084
2121
|
}
|
|
2085
|
-
else if (exited.length) {
|
|
2122
|
+
else if (!storeBlocked && !seedBlocksRestart && exited.length) {
|
|
2086
2123
|
const broker = exited.includes("nats"), manager = exited.includes("manager");
|
|
2087
2124
|
const notes = [...(broker ? ["up reopens the recorded store"] : []), ...(manager ? ["pass --runtime again if the manager ran on one"] : [])];
|
|
2088
2125
|
items.unshift({ command: `${cmd} up`, description: `Restart this folder's ${broker && manager ? "broker and manager" : broker ? "broker" : "manager"}, which exited; ${notes.join("; ")}` });
|
|
2089
2126
|
}
|
|
2090
|
-
else if (local && r.selected.resolved && r.selected.connection === "unreachable" && (r.folder.processes ?? []).every((row) => row.state === "stopped")) {
|
|
2127
|
+
else if (!storeBlocked && !seedBlocksRestart && local && r.selected.resolved && r.selected.connection === "unreachable" && (r.folder.processes ?? []).every((row) => row.state === "stopped")) {
|
|
2091
2128
|
// A clean down leaves every member stopped with no pidfile. Spawn and ps need the stack, so the
|
|
2092
2129
|
// bare `up` that starts it again on its recorded address and store comes first.
|
|
2093
2130
|
items.unshift({ command: `${cmd} up`, description: "Start this folder's stopped stack again; pass --runtime again if the manager ran on one" });
|
|
@@ -2551,6 +2588,26 @@ async function deliveryHealth(target, context, credential) {
|
|
|
2551
2588
|
facts.push("renewal adoption not reported");
|
|
2552
2589
|
else
|
|
2553
2590
|
facts.push(renewal.adoption.ok ? "renewal adoption accepted" : `renewal adoption refused${renewal.adoption.error ? `: ${renewal.adoption.error}` : ""}`);
|
|
2591
|
+
const renewalRefused = renewal?.adoption?.ok === false;
|
|
2592
|
+
if (target.mode === "open" && record.kind === "absent" && !renewalRefused) {
|
|
2593
|
+
if (credential.kind === "unavailable")
|
|
2594
|
+
return { name: "delivery", verdict: "refused", facts: [credential.reason] };
|
|
2595
|
+
try {
|
|
2596
|
+
const component = await componentEp(target, credential);
|
|
2597
|
+
try {
|
|
2598
|
+
if (!await component.ep.readDeliveryLease(0))
|
|
2599
|
+
return { name: "delivery", verdict: "not-started", facts: ["not used on an open mesh"] };
|
|
2600
|
+
}
|
|
2601
|
+
finally {
|
|
2602
|
+
await component.close();
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
catch (error) {
|
|
2606
|
+
if (deliveryLeaseAbsent(error))
|
|
2607
|
+
return { name: "delivery", verdict: "not-started", facts: ["not used on an open mesh"] };
|
|
2608
|
+
return { name: "delivery", verdict: "refused", facts: [`lease probe refused: ${error instanceof Error ? error.message : String(error)}`] };
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2554
2611
|
if (stopped) {
|
|
2555
2612
|
if (record.kind === "dead")
|
|
2556
2613
|
facts.push("stale pidfile");
|
|
@@ -2558,7 +2615,7 @@ async function deliveryHealth(target, context, credential) {
|
|
|
2558
2615
|
facts.push("unattributable pidfile");
|
|
2559
2616
|
if (record.kind === "unknown")
|
|
2560
2617
|
facts.push("pid liveness unestablishable");
|
|
2561
|
-
return { name: "delivery", verdict: stopped, facts };
|
|
2618
|
+
return { name: "delivery", verdict: renewalRefused ? "refused" : stopped, facts };
|
|
2562
2619
|
}
|
|
2563
2620
|
let close;
|
|
2564
2621
|
try {
|
|
@@ -2583,7 +2640,7 @@ async function deliveryHealth(target, context, credential) {
|
|
|
2583
2640
|
const state = deliveryResponderFromLease(lease, await expectedDeliveryHolder(target));
|
|
2584
2641
|
if (!lease) {
|
|
2585
2642
|
facts.push("ready lease absent", `responder not bound - ${RESPONDER_UNBOUND_CONSEQUENCE}`);
|
|
2586
|
-
return { name: "delivery", verdict: "not-serving", facts };
|
|
2643
|
+
return { name: "delivery", verdict: renewalRefused ? "refused" : "not-serving", facts };
|
|
2587
2644
|
}
|
|
2588
2645
|
facts.push(`lease holder ${lease.holder}`);
|
|
2589
2646
|
if (state === "stale") {
|
|
@@ -2591,12 +2648,12 @@ async function deliveryHealth(target, context, credential) {
|
|
|
2591
2648
|
// operator cannot derive from the other facts on the line.
|
|
2592
2649
|
facts.push("ready, but held by a DIFFERENT daemon than this workspace launched (a dead holder's record expires on its own)");
|
|
2593
2650
|
facts.push(`responder not bound - ${RESPONDER_UNBOUND_CONSEQUENCE}`);
|
|
2594
|
-
return { name: "delivery", verdict: "not-serving", facts };
|
|
2651
|
+
return { name: "delivery", verdict: renewalRefused ? "refused" : "not-serving", facts };
|
|
2595
2652
|
}
|
|
2596
2653
|
facts.push(state === "bound" ? "ready" : "starting (lease not ready)");
|
|
2597
2654
|
if (state !== "bound")
|
|
2598
2655
|
facts.push(`responder not bound - ${RESPONDER_UNBOUND_CONSEQUENCE}`);
|
|
2599
|
-
return { name: "delivery", verdict: state === "bound" ? "serving" : "not-serving", facts };
|
|
2656
|
+
return { name: "delivery", verdict: renewalRefused ? "refused" : state === "bound" ? "serving" : "not-serving", facts };
|
|
2600
2657
|
}
|
|
2601
2658
|
catch (e) {
|
|
2602
2659
|
// A live recorded daemon with no delivery lease bucket cannot be serving this build's delivery
|
|
@@ -2605,7 +2662,9 @@ async function deliveryHealth(target, context, credential) {
|
|
|
2605
2662
|
const noLeaseSurface = deliveryLeaseAbsent(e);
|
|
2606
2663
|
const msg = e instanceof Error ? e.message : String(e);
|
|
2607
2664
|
facts.push(noLeaseSurface ? "ready lease absent" : `lease probe refused: ${msg}`);
|
|
2608
|
-
|
|
2665
|
+
if (isCommandFailure(e) && e.remedy)
|
|
2666
|
+
facts.push(e.remedy);
|
|
2667
|
+
return { name: "delivery", verdict: renewalRefused || !noLeaseSurface ? "refused" : "not-serving", facts };
|
|
2609
2668
|
}
|
|
2610
2669
|
finally {
|
|
2611
2670
|
await close?.();
|
|
@@ -2686,14 +2745,15 @@ async function webHealth(context) {
|
|
|
2686
2745
|
}
|
|
2687
2746
|
return { name: "web", verdict: "not-serving", facts: [...facts, `host ${bound.host}`, `port ${bound.port}`, "http not answered"] };
|
|
2688
2747
|
}
|
|
2689
|
-
async function brokerHealth(target) {
|
|
2748
|
+
async function brokerHealth(target, store) {
|
|
2690
2749
|
const address = brokerAddressForDisplay(target.server);
|
|
2691
2750
|
if (address === undefined)
|
|
2692
2751
|
return { name: "broker", verdict: "refused", facts: ["registered address unavailable", "invalid broker address"] };
|
|
2693
2752
|
try {
|
|
2694
2753
|
const context = { root: target.root, space: target.space };
|
|
2695
2754
|
const journal = readStackJournal(target.root)?.journal;
|
|
2696
|
-
|
|
2755
|
+
const serverKey = brokerUrlKey(target.server);
|
|
2756
|
+
if (journal?.space === target.space && brokerUrlKey(journal.server) === serverKey) {
|
|
2697
2757
|
const member = journal.members.find((row) => row.role === "broker");
|
|
2698
2758
|
const instance = serviceInstances(target.space, STACK_DEFINITION.broker).find((row) => row.name === member?.instanceId);
|
|
2699
2759
|
const observed = instance && instanceProjection(instance).observedProcess;
|
|
@@ -2702,19 +2762,23 @@ async function brokerHealth(target) {
|
|
|
2702
2762
|
if (observed !== "running")
|
|
2703
2763
|
return { name: "broker", verdict: "refused", facts: [`registered ${address}`, `local process ${observed}`] };
|
|
2704
2764
|
}
|
|
2705
|
-
else if (target.origin === "up" && target.mode !== "user" && (target.recordedServer === undefined || target.recordedServer ===
|
|
2765
|
+
else if (target.origin === "up" && target.mode !== "user" && (target.recordedServer === undefined || brokerUrlKey(target.recordedServer) === serverKey)) {
|
|
2706
2766
|
const record = processRecord(NATS_PIDFILE, context);
|
|
2707
2767
|
const verdict = processVerdict(record);
|
|
2708
2768
|
if (verdict)
|
|
2709
2769
|
return { name: "broker", verdict, facts: [`registered ${address}`, ...pidFacts(record), ...(record.kind === "dead" ? ["stale pidfile"] : [])] };
|
|
2710
2770
|
}
|
|
2771
|
+
const storeFailure = store?.state === "write-failed" ? `store write failed: ${store.cause}`
|
|
2772
|
+
: store?.state === "full" ? `store full: ${store.used} bytes exceeds ${store.cap} bytes at ${store.path}` : undefined;
|
|
2711
2773
|
if (target.mode !== "user") {
|
|
2712
2774
|
const preflight = await preflightTarget(target);
|
|
2713
2775
|
if (!preflight.ok)
|
|
2714
2776
|
return { name: "broker", verdict: "not-serving", facts: [`registered ${address}`, workspaceErrorParts({ kind: "preflight", failure: preflight.kind, target, pruned: false }).message] };
|
|
2715
|
-
return { name: "broker", verdict: "serving", facts: [`registered ${address}`, "reachable"] };
|
|
2777
|
+
return { name: "broker", verdict: storeFailure ? "not-serving" : "serving", facts: [`registered ${address}`, "reachable", ...(storeFailure ? [storeFailure] : [])] };
|
|
2716
2778
|
}
|
|
2717
2779
|
const reachable = await isReachable(target.server, target.tlsRequired ? { tls: true } : {});
|
|
2780
|
+
if (storeFailure)
|
|
2781
|
+
return { name: "broker", verdict: "not-serving", facts: [`registered ${address}`, reachable ? "reachable" : "unreachable", storeFailure] };
|
|
2718
2782
|
return reachable
|
|
2719
2783
|
? { name: "broker", verdict: "serving", facts: [`registered ${address}`, "reachable"] }
|
|
2720
2784
|
: { name: "broker", verdict: "not-serving", facts: [`registered ${address}`, "unreachable"] };
|
|
@@ -2723,10 +2787,15 @@ async function brokerHealth(target) {
|
|
|
2723
2787
|
return { name: "broker", verdict: "refused", facts: [`registered ${address}`, `probe refused: ${e.message}`] };
|
|
2724
2788
|
}
|
|
2725
2789
|
}
|
|
2726
|
-
async function printComponentHealth(selected) {
|
|
2790
|
+
async function printComponentHealth(selected, store) {
|
|
2727
2791
|
section("Component Health");
|
|
2728
2792
|
if (!selected.ok) {
|
|
2729
2793
|
const e = selected.error;
|
|
2794
|
+
if (isMeshRegistryError(e)) {
|
|
2795
|
+
printComponent({ name: "target", verdict: "refused", facts: ["SCHEMA_INVALID", e.message] });
|
|
2796
|
+
process.exitCode = COMPONENT_EXIT.refused;
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2730
2799
|
if (isWorkspaceTargetError(e)) {
|
|
2731
2800
|
const verdict = e.code === "not-started" ? "absent" : "refused";
|
|
2732
2801
|
printComponent({ name: "target", verdict, facts: [e.code, renderWorkspaceError({ kind: "target", error: e }).replace(/^✗ /, "")] });
|
|
@@ -2746,7 +2815,7 @@ async function printComponentHealth(selected) {
|
|
|
2746
2815
|
// static shape is just the target's own auth material), shared by the manager and delivery
|
|
2747
2816
|
// probes so the two rows cannot disagree about whose credential they probed with.
|
|
2748
2817
|
const credential = await componentCredential(target);
|
|
2749
|
-
const broker = await brokerHealth(target);
|
|
2818
|
+
const broker = await brokerHealth(target, store);
|
|
2750
2819
|
const components = await Promise.all([
|
|
2751
2820
|
managerHealth(target, context, credential, broker),
|
|
2752
2821
|
deliveryHealth(target, context, credential),
|