@m8t-stack/cli 0.2.66 → 0.2.68
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/cli.js +29 -3
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1364,7 +1364,7 @@ var init_enable_hosted_brain = __esm({
|
|
|
1364
1364
|
import { Builtins, Cli } from "clipanion";
|
|
1365
1365
|
|
|
1366
1366
|
// src/lib/package-version.ts
|
|
1367
|
-
var CLI_VERSION = "0.2.
|
|
1367
|
+
var CLI_VERSION = "0.2.68";
|
|
1368
1368
|
|
|
1369
1369
|
// src/lib/render-error.ts
|
|
1370
1370
|
init_errors();
|
|
@@ -21295,6 +21295,7 @@ function resolveHeadlessContextFromEnv(env) {
|
|
|
21295
21295
|
|
|
21296
21296
|
// src/lib/apply-request-store.ts
|
|
21297
21297
|
import { TableClient as TableClient4 } from "@azure/data-tables";
|
|
21298
|
+
var MAX_LEASE_TAKEOVERS = 2;
|
|
21298
21299
|
async function openApplyTable(opts) {
|
|
21299
21300
|
const { tableEndpoint } = await discoverStampStorage(opts);
|
|
21300
21301
|
return new TableClient4(tableEndpoint, "Metadata", opts.credential);
|
|
@@ -21314,12 +21315,37 @@ async function readApplyRequest(client) {
|
|
|
21314
21315
|
async function claimApplyRequest(client, executionId, nowIso, leaseMs) {
|
|
21315
21316
|
const cur = await readApplyRequest(client);
|
|
21316
21317
|
if (!cur) return null;
|
|
21317
|
-
const leaseExpired = cur.status
|
|
21318
|
+
const leaseExpired = isInFlight(cur.status) && cur.leaseUntil !== null && Date.parse(cur.leaseUntil) < Date.parse(nowIso);
|
|
21318
21319
|
const claimable = cur.status === "pending" || cur.status === "awaiting-engine-update" || leaseExpired;
|
|
21319
21320
|
if (!claimable) return null;
|
|
21320
21321
|
const nowMs = Date.parse(nowIso);
|
|
21321
21322
|
const leaseUntil = new Date((Number.isNaN(nowMs) ? Date.now() : nowMs) + leaseMs).toISOString();
|
|
21322
|
-
|
|
21323
|
+
if (leaseExpired && cur.attempt >= MAX_LEASE_TAKEOVERS) {
|
|
21324
|
+
const held = {
|
|
21325
|
+
...cur,
|
|
21326
|
+
status: "held",
|
|
21327
|
+
breaker: "held",
|
|
21328
|
+
result: {
|
|
21329
|
+
appliedVersion: cur.result?.appliedVersion ?? null,
|
|
21330
|
+
error: `the converge was abandoned mid-apply ${(cur.attempt + 1).toString()} times (last owner ${cur.claimedBy ?? "(unknown)"}, phase "${cur.phase ?? "(none)"}"); the updater stopped retrying to avoid re-rolling infra behind a converge that cannot finish`
|
|
21331
|
+
},
|
|
21332
|
+
updatedAt: nowIso
|
|
21333
|
+
};
|
|
21334
|
+
try {
|
|
21335
|
+
await client.updateEntity({ ...applyRequestToEntity(held), etag: cur.etag }, "Merge", { etag: cur.etag });
|
|
21336
|
+
} catch (e) {
|
|
21337
|
+
if (!hasStatus(e, 412)) throw e;
|
|
21338
|
+
}
|
|
21339
|
+
return null;
|
|
21340
|
+
}
|
|
21341
|
+
const claimed = {
|
|
21342
|
+
...cur,
|
|
21343
|
+
status: "claimed",
|
|
21344
|
+
claimedBy: executionId,
|
|
21345
|
+
leaseUntil,
|
|
21346
|
+
...leaseExpired ? { attempt: cur.attempt + 1 } : {},
|
|
21347
|
+
updatedAt: nowIso
|
|
21348
|
+
};
|
|
21323
21349
|
try {
|
|
21324
21350
|
await client.updateEntity({ ...applyRequestToEntity(claimed), etag: cur.etag }, "Merge", { etag: cur.etag });
|
|
21325
21351
|
return claimed;
|