fix(mesh): name the teapot in the boot log a later 404 points back to
A route the absent teapot would have exported 404s, and that is the right status: nothing was ever registered for a manifest that never arrived, so there is no path to serve. But a bare 404 is indistinguishable from a typo in the path, and the boot log is the only place the two are told apart. It could not tell them apart either. The give-up warning relied on the error's own message to identify the teapot, which holds for a refusal -- `mesh handshake failed: <url>` -- but not for an unreachable one, where the error is a socket error that may carry no url at all. So the url is passed in now, and every line of the boot-connect story names it: the retries, the refusal, and the give-up. The give-up line also says no manifest was ever exchanged, which is the fact that explains the 404. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
2 files changed
+44
-7
No files matched your search
+9
-7
@@ -775,6 +775,7 @@ async function connectUntilDeadline(
|
|||||||
mesh: MeshConfig,
|
mesh: MeshConfig,
|
||||||
bus: Bus,
|
bus: Bus,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
|
url: string,
|
||||||
attempt: () => Promise<Link>,
|
attempt: () => Promise<Link>,
|
||||||
): Promise<Link | undefined> {
|
): Promise<Link | undefined> {
|
||||||
const budgetMs = mesh.bootTimeoutMs ?? mesh.timeoutMs ?? 30_000;
|
const budgetMs = mesh.bootTimeoutMs ?? mesh.timeoutMs ?? 30_000;
|
||||||
@@ -793,7 +794,7 @@ async function connectUntilDeadline(
|
|||||||
// thirty seconds. Retrying a wrong secret only spends the deploy's patience to reach the
|
// thirty seconds. Retrying a wrong secret only spends the deploy's patience to reach the
|
||||||
// identical error, so it fails now.
|
// identical error, so it fails now.
|
||||||
if (isPermanentRefusal(error)) {
|
if (isPermanentRefusal(error)) {
|
||||||
logger.error(`mesh: the teapot refused this peer, which retrying cannot fix — ${(error as Error).message}`);
|
logger.error(`mesh: teapot ${url} refused this peer, which retrying cannot fix — ${(error as Error).message}`);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -804,17 +805,18 @@ async function connectUntilDeadline(
|
|||||||
// at all — its routes 404 and a local `needs` on its tokens still fails in finalize().
|
// at all — its routes 404 and a local `needs` on its tokens still fails in finalize().
|
||||||
if (remaining <= 0) {
|
if (remaining <= 0) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`mesh: teapot unreachable after ${attempts} attempt(s) over ${budgetMs}ms ` +
|
`mesh: teapot ${url} unreachable after ${attempts} attempt(s) over ${budgetMs}ms ` +
|
||||||
`(${(error as Error).message}) — starting without it. It sent no manifest, so none of ` +
|
`(${(error as Error).message}) — starting without it. No manifest was ever exchanged, ` +
|
||||||
`its steps or routes are in this graph: its routes 404, and the boot still fails if ` +
|
`so none of its steps or routes are in this graph: its routes 404 like any path that ` +
|
||||||
`anything local needs one of its tokens.`,
|
`was never registered, and the boot still fails if anything local needs one of its ` +
|
||||||
|
`tokens. This line is what a later 404 on one of its routes points back to.`,
|
||||||
);
|
);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus.emit('mesh:boot:retry', { name: `attempt ${attempts}`, error });
|
bus.emit('mesh:boot:retry', { name: `attempt ${attempts}`, error });
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`mesh: teapot unreachable (${(error as Error).message}) — retrying, ${remaining}ms of boot budget left`,
|
`mesh: teapot ${url} unreachable (${(error as Error).message}) — retrying, ${remaining}ms of boot budget left`,
|
||||||
);
|
);
|
||||||
await new Promise((resolve) => setTimeout(resolve, Math.min(delay, Math.max(0, remaining))));
|
await new Promise((resolve) => setTimeout(resolve, Math.min(delay, Math.max(0, remaining))));
|
||||||
delay = Math.min(delay * 2, 5_000);
|
delay = Math.min(delay * 2, 5_000);
|
||||||
@@ -857,7 +859,7 @@ async function spliceRemoteScopes(
|
|||||||
try {
|
try {
|
||||||
for (const teapot of mesh.teapots ?? []) {
|
for (const teapot of mesh.teapots ?? []) {
|
||||||
warnIfCleartext(teapot.url, logger);
|
warnIfCleartext(teapot.url, logger);
|
||||||
const link = await connectUntilDeadline(mesh, bus, logger, () =>
|
const link = await connectUntilDeadline(mesh, bus, logger, teapot.url, () =>
|
||||||
connectLink({
|
connectLink({
|
||||||
url: teapot.url,
|
url: teapot.url,
|
||||||
secret: teapot.secret,
|
secret: teapot.secret,
|
||||||
|
|||||||
@@ -191,6 +191,41 @@ describe('mesh boot retry', () => {
|
|||||||
}
|
}
|
||||||
}, 15_000);
|
}, 15_000);
|
||||||
|
|
||||||
|
it('names the teapot in the log a later 404 points back to', async () => {
|
||||||
|
// A route the absent teapot would have exported 404s, because nothing was ever registered for a
|
||||||
|
// manifest that never arrived. That is the right status — you cannot serve what was never
|
||||||
|
// declared — but a bare 404 is indistinguishable from a typo in the path. The boot log is the
|
||||||
|
// only place the two are told apart, so it has to name *which* teapot and say that no manifest
|
||||||
|
// was exchanged. The unreachable error itself is a socket error and does not reliably carry
|
||||||
|
// the url, so the url is passed in rather than scraped out of the message.
|
||||||
|
const { lines, logger } = collect();
|
||||||
|
const teacup = createApp({
|
||||||
|
modules: [LocalOnlyModule],
|
||||||
|
experimental: true,
|
||||||
|
logger,
|
||||||
|
mesh: {
|
||||||
|
teapots: [{ url: 'ws://127.0.0.1:9/x', secret: 's' }],
|
||||||
|
secret: 's',
|
||||||
|
bootTimeoutMs: 300,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await teacup.ready();
|
||||||
|
const gaveUp = lines.find((line) => line.includes('starting without it'));
|
||||||
|
|
||||||
|
expect(gaveUp).toBeDefined();
|
||||||
|
expect(gaveUp).toContain('ws://127.0.0.1:9/x');
|
||||||
|
expect(gaveUp).toMatch(/no manifest was ever exchanged/i);
|
||||||
|
expect(gaveUp).toMatch(/404/);
|
||||||
|
|
||||||
|
// and the retry lines on the way there name it too, so a deploy tailing logs sees which one
|
||||||
|
expect(lines.some((line) => /retrying/.test(line) && line.includes('ws://127.0.0.1:9/x'))).toBe(true);
|
||||||
|
} finally {
|
||||||
|
await teacup.close();
|
||||||
|
}
|
||||||
|
}, 15_000);
|
||||||
|
|
||||||
it('still fails the boot when a local step needs a token the absent teapot owned', async () => {
|
it('still fails the boot when a local step needs a token the absent teapot owned', async () => {
|
||||||
const teacup = createApp({
|
const teacup = createApp({
|
||||||
modules: [NeedsAuthModule], // a step with needs: ['auth']
|
modules: [NeedsAuthModule], // a step with needs: ['auth']
|
||||||
|
|||||||
Reference in new issue
Block a user