@mindexec/cli 0.2.313 → 0.2.314
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/package.json +1 -1
- package/server.js +67 -8
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -6475,6 +6475,22 @@ function isRemoteHostTargetRenewSoftSkipReason(reason) {
|
|
|
6475
6475
|
.test(String(reason || '').trim());
|
|
6476
6476
|
}
|
|
6477
6477
|
|
|
6478
|
+
function getRemoteHostTargetRegistryErrorReason(error) {
|
|
6479
|
+
const statusCode = Number(error?.statusCode || 0);
|
|
6480
|
+
const text = String(error?.message || error || '');
|
|
6481
|
+
if (statusCode === 401
|
|
6482
|
+
|| statusCode === 403
|
|
6483
|
+
|| /registry-(rest|rpc)[^ ]*-40[13]|JWT expired|PGRST303/i.test(text)) {
|
|
6484
|
+
return 'registry-not-authenticated';
|
|
6485
|
+
}
|
|
6486
|
+
|
|
6487
|
+
if (/PGRST20[25]|remote_host_targets|set_remote_host_target|clear_remote_host_target/i.test(text)) {
|
|
6488
|
+
return 'registry-table-unavailable';
|
|
6489
|
+
}
|
|
6490
|
+
|
|
6491
|
+
return 'registry-publish-failed';
|
|
6492
|
+
}
|
|
6493
|
+
|
|
6478
6494
|
async function publishLocalRemoteHostTargetToRegistry(hub, { takeover = false } = {}) {
|
|
6479
6495
|
const registryPayload = buildRemoteHostTargetRegistryPayload(hub);
|
|
6480
6496
|
if (!registryPayload.ok) {
|
|
@@ -6500,14 +6516,33 @@ async function publishLocalRemoteHostTargetToRegistry(hub, { takeover = false }
|
|
|
6500
6516
|
};
|
|
6501
6517
|
}
|
|
6502
6518
|
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6519
|
+
let row = null;
|
|
6520
|
+
try {
|
|
6521
|
+
row = await callRemoteRegistryRpc(
|
|
6522
|
+
context.config,
|
|
6523
|
+
context.session,
|
|
6524
|
+
'set_remote_host_target',
|
|
6525
|
+
{
|
|
6526
|
+
...registryPayload.payload,
|
|
6527
|
+
p_takeover: takeover === true
|
|
6528
|
+
});
|
|
6529
|
+
} catch (error) {
|
|
6530
|
+
const reason = getRemoteHostTargetRegistryErrorReason(error);
|
|
6531
|
+
return {
|
|
6532
|
+
ok: false,
|
|
6533
|
+
active: false,
|
|
6534
|
+
reason,
|
|
6535
|
+
error: error?.message || String(error || reason),
|
|
6536
|
+
endpoint: registryPayload.endpoint,
|
|
6537
|
+
endpointCandidates: registryPayload.endpointCandidates,
|
|
6538
|
+
leaseId: registryPayload.leaseId,
|
|
6539
|
+
nodeId: registryPayload.nodeId,
|
|
6540
|
+
hostInstanceId: registryPayload.hostInstanceId,
|
|
6541
|
+
expiresAt: registryPayload.expiresAt,
|
|
6542
|
+
stale: false
|
|
6543
|
+
};
|
|
6544
|
+
}
|
|
6545
|
+
|
|
6511
6546
|
const reason = row.reason || (row.ok ? 'ok' : 'registry-publish-failed');
|
|
6512
6547
|
return {
|
|
6513
6548
|
ok: row.ok,
|
|
@@ -6837,6 +6872,30 @@ async function runRemoteHostTargetRenewOnce(trigger = 'timer', options = {}) {
|
|
|
6837
6872
|
retryDelay,
|
|
6838
6873
|
registry.ok ? 'renewed' : 'renew-skipped');
|
|
6839
6874
|
return serializeRemoteHostTargetRenewState();
|
|
6875
|
+
} catch (error) {
|
|
6876
|
+
const currentHub = remoteHub.getStatus({ includeSecrets: true });
|
|
6877
|
+
const reason = getRemoteHostTargetRegistryErrorReason(error);
|
|
6878
|
+
updateRemoteHostTargetRenewState({
|
|
6879
|
+
status: 'skipped',
|
|
6880
|
+
reason,
|
|
6881
|
+
nodeId: currentHub?.hostTargetNodeId || remoteHostTargetRenewState.nodeId,
|
|
6882
|
+
leaseId: currentHub?.hostTargetLeaseId || remoteHostTargetRenewState.leaseId,
|
|
6883
|
+
hostInstanceId: currentHub?.hostTargetHostInstanceId || currentHub?.hostInstanceId || remoteHostTargetRenewState.hostInstanceId,
|
|
6884
|
+
endpoint: currentHub?.hostTargetEndpoint || remoteHostTargetRenewState.endpoint,
|
|
6885
|
+
endpointCandidates: currentHub?.hostTargetEndpointCandidates || remoteHostTargetRenewState.endpointCandidates || [],
|
|
6886
|
+
expiresAt: currentHub?.hostTargetExpiresAt || remoteHostTargetRenewState.expiresAt,
|
|
6887
|
+
lastAttemptAt: attemptedAt,
|
|
6888
|
+
lastError: isRemoteHostTargetRenewSoftSkipReason(reason)
|
|
6889
|
+
? ''
|
|
6890
|
+
: (error?.message || String(error || reason))
|
|
6891
|
+
});
|
|
6892
|
+
logRemoteHostTargetRenew('skipped', reason, remoteHostTargetRenewState.endpoint);
|
|
6893
|
+
scheduleRemoteHostTargetRenew(
|
|
6894
|
+
isRemoteHostTargetRenewSoftSkipReason(reason)
|
|
6895
|
+
? REMOTE_HOST_TARGET_RENEW_MS
|
|
6896
|
+
: REMOTE_REGISTRY_FOLLOWER_FAST_RETRY_MS,
|
|
6897
|
+
'renew-error');
|
|
6898
|
+
return serializeRemoteHostTargetRenewState();
|
|
6840
6899
|
} finally {
|
|
6841
6900
|
remoteHostTargetRenewInFlight = false;
|
|
6842
6901
|
}
|