@astrofoundry/pi-astro 0.37.4 → 0.37.5
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
CHANGED
|
@@ -11,7 +11,7 @@ import { containerFacts, deploymentChecks, listRows, parseDeploymentArgs, syncFa
|
|
|
11
11
|
import { ServiceError, UsageError } from "../lib/errors.ts";
|
|
12
12
|
import { withLock } from "../lib/lock.ts";
|
|
13
13
|
import { main } from "../lib/main.ts";
|
|
14
|
-
import { buildUpdateReport, parseTag, resolveRef, stackServices, type CheckEntry, type UpdateRow } from "../lib/image-updates.ts";
|
|
14
|
+
import { buildUpdateReport, checkEntries, parseTag, rateLimited, resolveRef, stackServices, type CheckEntry, type UpdateRow } from "../lib/image-updates.ts";
|
|
15
15
|
import { printJson, printRaw } from "../lib/output.ts";
|
|
16
16
|
import { auditLogPath, specialistsHome } from "../lib/paths.ts";
|
|
17
17
|
import { run, type RunResult } from "../lib/proc.ts";
|
|
@@ -104,7 +104,8 @@ ${Object.entries(HOST_COMMANDS)
|
|
|
104
104
|
.join("\n")}
|
|
105
105
|
update-report [--all] fresh image update check for every stack, with running and latest release versions
|
|
106
106
|
from the registries; JSON with a ready table (--all also lists up-to-date services) and
|
|
107
|
-
the held stacks of ${HOLDS_FILE}.
|
|
107
|
+
the held stacks of ${HOLDS_FILE}. Images the registry throttled (toomanyrequests) are
|
|
108
|
+
checked again after 5 and 20 seconds. Checks only: never pulls images or redeploys.
|
|
108
109
|
stack-update <stack> [--confirm]
|
|
109
110
|
apply every pending update of one stack: pinned tags and digests move in the stack's
|
|
110
111
|
Compose file (commit, push, start the sync and wait for it), then the stack is redeployed
|
|
@@ -217,6 +218,9 @@ async function cliJson(cli: Cli, args: string[]): Promise<unknown> {
|
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
|
|
221
|
+
/** Pauses before each new check of the images the registry throttled. */
|
|
222
|
+
const THROTTLE_RETRY_WAITS_MS = [5000, 20000];
|
|
223
|
+
|
|
220
224
|
/** A fresh registry check first, then the stack list, so every result the report uses is from this run. */
|
|
221
225
|
async function updateReport(config: ArcaneConfig, args: string[]): Promise<number> {
|
|
222
226
|
const extra = args.filter((a) => a !== "--all");
|
|
@@ -224,7 +228,17 @@ async function updateReport(config: ArcaneConfig, args: string[]): Promise<numbe
|
|
|
224
228
|
const startedAt = Date.now();
|
|
225
229
|
const holds = await holdsFromOrigin(config);
|
|
226
230
|
return withCli(config, async (cli) => {
|
|
227
|
-
const check = await cliJson(cli, ["images", "updates", "check", "--all"]);
|
|
231
|
+
const check = checkEntries(await cliJson(cli, ["images", "updates", "check", "--all"]));
|
|
232
|
+
for (const wait of THROTTLE_RETRY_WAITS_MS) {
|
|
233
|
+
const limited = rateLimited(check);
|
|
234
|
+
if (limited.length === 0) break;
|
|
235
|
+
await new Promise((r) => setTimeout(r, wait));
|
|
236
|
+
for (const ref of limited) {
|
|
237
|
+
// A retry that fails again keeps the throttled entry for the next round or the report.
|
|
238
|
+
const again = await cliJson(cli, ["images", "updates", "check", ref]).catch(() => null);
|
|
239
|
+
if (again && typeof again === "object" && "hasUpdate" in again) check[ref] = again as CheckEntry;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
228
242
|
const projects = await cliJson(cli, ["projects", "list", "--all"]);
|
|
229
243
|
const report = await buildUpdateReport({ check, projects, registry: new HttpRegistry(), startedAt, all: args.includes("--all") });
|
|
230
244
|
printJson({ ...report, holds: holds.holds, ...(holds.error ? { holdsError: holds.error } : {}) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { buildUpdateReport, cachingRegistry, checkEntries, classify, compareVersions, parseTag, releaseCandidates, resolveRef, stackServices, type CheckEntry } from "./image-updates.ts";
|
|
2
|
+
import { buildUpdateReport, cachingRegistry, checkEntries, classify, compareVersions, parseTag, rateLimited, releaseCandidates, resolveRef, stackServices, type CheckEntry } from "./image-updates.ts";
|
|
3
3
|
import { HttpRegistry, nextLink, parseChallenge, parseImageRef, RegistryError, type ImageRef, type Registry } from "./registry.ts";
|
|
4
4
|
import { capTotal, condenseNotes, githubRepo, releaseNotesFor, releasesBetween, type GithubRelease } from "./releases.ts";
|
|
5
5
|
|
|
@@ -160,6 +160,8 @@ describe("buildUpdateReport", () => {
|
|
|
160
160
|
it("reads Arcane's envelopes", () => {
|
|
161
161
|
expect(Object.keys(checkEntries({ data: { "a:1": { hasUpdate: false } } }))).toEqual(["a:1"]);
|
|
162
162
|
expect(Object.keys(checkEntries({ "a:1": { hasUpdate: true }, success: true }))).toEqual(["a:1"]);
|
|
163
|
+
const throttled = "distribution inspect of lscr.io/linuxserver/sonarr:latest failed: Error response from daemon: toomanyrequests: retry-after: 1.24222ms, allowed: 44000/minute";
|
|
164
|
+
expect(rateLimited({ "lscr.io/linuxserver/sonarr:latest": { hasUpdate: false, error: throttled }, "b:1": { hasUpdate: false, error: "manifest unknown" }, "c:1": { hasUpdate: true } })).toEqual(["lscr.io/linuxserver/sonarr:latest"]);
|
|
163
165
|
expect(stackServices({ data: "nope" })).toEqual([]);
|
|
164
166
|
});
|
|
165
167
|
});
|
|
@@ -276,6 +276,17 @@ export function checkEntries(raw: unknown): Record<string, CheckEntry> {
|
|
|
276
276
|
return out;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Images whose check the registry throttled. lscr.io answers bursts with
|
|
281
|
+
* `toomanyrequests` and a retry-after of a millisecond or two, more often when
|
|
282
|
+
* our check overlaps Arcane's hourly one; a single check a little later passes.
|
|
283
|
+
*/
|
|
284
|
+
export function rateLimited(entries: Record<string, CheckEntry>): string[] {
|
|
285
|
+
return Object.entries(entries)
|
|
286
|
+
.filter(([, e]) => typeof e.error === "string" && /toomanyrequests/i.test(e.error))
|
|
287
|
+
.map(([ref]) => ref);
|
|
288
|
+
}
|
|
289
|
+
|
|
279
290
|
interface StackService {
|
|
280
291
|
stack: string;
|
|
281
292
|
service: string;
|