Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions ui/e2e/group-run.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1197,3 +1197,50 @@ test('a group run whose jobs all started on a newer version than its own counts
await note.click();
await expect(page.getByText('Not used: removes the group nightly')).toHaveCount(1);
});

test('a group run names the jobs a failure held back, says on each row what held it, and its +N shows them all; idle ticks stay within budget', async ({ page }) => {
const { fake, run } = server(Array.from({ length: 20 }, (_, i) => `job_${String(i).padStart(2, '0')}`), 150);
const [failed, ...held] = run.members;
for (const k of Object.keys(failed.nodes)) failed.nodes[k] = 'success';
failed.nodes['model:job_00_10'] = 'failed';
failed.nodes['model:job_00_11'] = 'failed';
failed.failed = true;
for (const m of held) {
m.blockedBy = failed.jobKey;
for (const k of Object.keys(m.nodes)) m.nodes[k] = 'skipped';
}
await page.clock.install();
await fake.install(page);
await page.goto(`/runs/${run.id}`);

// The header names two of the 19 jobs held back and counts the rest; the failed job's row says nothing of being held.
const heldBack = page.getByTestId('held-back');
await expect(heldBack).toHaveText(/held back\s+job_01,\s*job_02\s*\+17/, { timeout: 30_000 });
const tree = page.getByTestId('run-tree');
const row = (job: string) => tree.getByRole('treeitem', { name: new RegExp(`^Open ${job}\\b`) }).first();
await expect(row('job_01')).toContainText('blocked by job_00 · job_00_10 failed (+1)');
await expect(row('job_00')).not.toContainText('blocked by');

// Clock ticks on an ended run with 19 blocked rows do no pass over its 3,000 nodes or its failures.
const settle = await countCalls(page, fake);
await page.clock.pauseAt(Date.now() + 1000);
await page.clock.runFor(4000);
await settle();
await page.clock.runFor(5000);
const idle = await settle();
expect(idle, `calls in 5 idle ticks: ${idle}`).toBeLessThan(5 * IDLE_CALLS_PER_TICK);

// +17 shows the blocked jobs in the tree: the failed job leaves it, the held ones stay.
await heldBack.getByRole('button', { name: '+17' }).click();
await page.clock.runFor(1000);
await expect(row('job_00')).toHaveCount(0);
await expect(row('job_01')).toBeVisible();
await page.screenshot({ path: test.info().outputPath('held-back-more.png') });

// A held job's panel goes from the failure upstream, through the job's own nodes it skipped, to what that left.
await row('job_01').getByRole('button', { name: 'job_01', exact: true }).click();
await page.clock.runFor(1000);
const chain = page.getByTestId('job-detail').getByTestId('job-error').getByRole('listitem');
await expect(chain).toHaveText([/^job_00\s*·\s*job_00_10 failed \(\+1\)\s*$/, /^job_01_0,\s*job_01_1\s*\+148\s*skipped$/, '150 nodes in this job skipped · 0 ran']);
await page.screenshot({ path: test.info().outputPath('held-back-panel.png') });
});
4 changes: 2 additions & 2 deletions ui/e2e/real/crash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ test("a stopped worker's unreached nodes read as not run, and the jobs that read
const afterRow = page.locator(`.line.node[data-row="n:${crashRunId}:${[...crashNodes.values()].find((n) => n.node_key.endsWith('crash_after'))!.node_key}"]`);
await expect(afterRow.locator('.sb-mark')).toHaveAttribute('data-state', 'not_run');

// The line under the title names the job that stopped and why, and that it held one job back, first.
// The line under the title names the job that stopped and why, and the job it held back, first.
const cause = page.getByTestId('root-cause').first();
await expect(cause).toContainText('crash_job');
await expect(cause).toContainText(/crash_wait failed: the worker (exited with code \d+|stopped) without reporting a result/);
await expect(cause).toContainText('held back 1 job');
await expect(cause.getByTestId('held-back')).toHaveText(/held back\s+after_crash_job\s*$/);
await expect(page.getByTestId('run-summary')).toContainText('1 not run');

// A skipped node names the unreached node in the other job, and opens it.
Expand Down
27 changes: 25 additions & 2 deletions ui/e2e/real/root-failures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,34 @@ test("a sensor gets one run_failed for the group run, naming each root failure a
['feeds_job', 'return_feed', ['return_summary_job'], ['return_summary'], 1]
]);

// The page's line under the title reads the same root failures: one job, its two failed nodes, two jobs held back.
// The page's line under the title reads the same root failures: one job, its two failed nodes, and the two jobs it
// held back by name.
await page.goto(`${server.uiUrl}/runs/${groupRunId}`);
const causes = page.getByTestId('root-cause');
await expect(causes).toHaveCount(1, { timeout: 30_000 });
await expect(causes).toContainText('feeds_job');
await expect(causes).toContainText('refund_feed failed (+1)');
await expect(causes).toContainText('held back 2 jobs');
await expect(causes.getByTestId('held-back')).toHaveText(/held back\s+refund_summary_job,\s*return_summary_job/);

// Each held-back job's row says which job held it back and which of its nodes failed: each waits on its own feed.
const row = (job: string) => page.locator('[data-row]').filter({ has: page.getByRole('button', { name: job, exact: true }) });
await expect(row('refund_summary_job')).toContainText('blocked by feeds_job · refund_feed failed');
await expect(row('return_summary_job')).toContainText('blocked by feeds_job · return_feed failed');
await expect(row('feeds_job')).not.toContainText('blocked by');
await page.screenshot({ path: test.info().outputPath('blocked-rows.png') });

// A held job's panel: the failure that held it, the node of its own that skipped, and what that left of the job.
await row('refund_summary_job').getByRole('button', { name: 'refund_summary_job', exact: true }).click();
const chain = page.getByTestId('job-detail').getByTestId('job-error').getByRole('listitem');
await expect(chain).toHaveText([/^feeds_job\s*·\s*refund_feed failed\s*$/, /^refund_summary\s*skipped$/, '1 node in this job skipped · 0 ran']);
await page.screenshot({ path: test.info().outputPath('blocked-panel.png') });

// The tree as its own column, too narrow for the sentence, says "blocked" where "N failed" goes, and why on hover.
await page.evaluate(() => localStorage.setItem('sqlbuild.run.treeColumn', '1'));
await page.reload();
const column = page.getByTestId('tree-column');
const refund = column.locator('[data-row]').filter({ hasText: 'refund_summary_job' });
await expect(refund.getByText('blocked', { exact: true })).toHaveAttribute('title', 'blocked by feeds_job · refund_feed failed', { timeout: 30_000 });
await expect(column.locator('[data-row]').filter({ hasText: 'feeds_job' }).first().getByText('blocked', { exact: true })).toHaveCount(0);
await page.screenshot({ path: test.info().outputPath('blocked-rows-column.png') });
});
9 changes: 6 additions & 3 deletions ui/e2e/support/fake-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export type FakeMemberRun = {
replaced?: boolean;
/** The job run has ended failed. */
failed?: boolean;
/** The job run has ended blocked, held back by this job's failed run; the server lists it under that job's root failures. */
blockedBy?: string;
/** Nodes it read that an earlier job built on an older version and that changed since, as the server sends them. */
staleReads?: { node_key: string; built_on_generation: number; changed_in_generation: number; built_by_run_id: string }[];
/** Rows a running node has written so far, as the server reports them, by node key. */
Expand Down Expand Up @@ -364,7 +366,8 @@ export class FakeControl {
.filter((m) => m.failed && !m.replaced)
.flatMap((m) => {
const failed = Object.keys(m.nodes).filter((key) => m.nodes[key] === 'failed').sort();
return (failed.length ? failed : [null]).map((node_key) => ({ job_key: m.jobKey, node_key, blocked_jobs: [], blocked_nodes: [], blocked_node_count: 0 }));
const blocked_jobs = live.members.filter((b) => b.blockedBy === m.jobKey).map((b) => b.jobKey);
return (failed.length ? failed : [null]).map((node_key) => ({ job_key: m.jobKey, node_key, blocked_jobs, blocked_nodes: [], blocked_node_count: 0 }));
})
.sort((a, b) => a.job_key.localeCompare(b.job_key) || (a.node_key ?? '').localeCompare(b.node_key ?? ''));
// As the server: every node without `since` or from a version it never gave, else each run moved past `since`, whole.
Expand Down Expand Up @@ -449,8 +452,8 @@ export class FakeControl {
return {
run_id: run.id, location_id: LOCATIONS.shop, target: 'dev', snapshot_id: SNAPSHOT, snapshot_generation: (member && run.generation) || 1, git_revision: null, git_dirty: false, sqb_version: '0.0.0', image_id: null,
job_key: run.jobKey, kind: member ? 'job' : 'group', origin: 'manual', parent_run_id: member ? live.id : null, root_run_id: live.id, trigger_id: null, trigger_name: null, tick_id: null, rerun_of_run_id: (member && run.retry?.of) || null,
requested_by: member && run.retry?.automatic ? 'system:retry' : 'principal:tester', requester_name: member && run.retry?.automatic ? null : 'tester', priority: 0, rewrite_history: false, status: member && run.replaced ? 'cancelled' : queued ? 'queued' : member && run.failed ? 'failed' : 'running', status_reason: null,
queued_at: at, launched_at: queued ? null : at, started_at: queued ? null : at, ended_at: member && run.failed ? at : null, cancel_requested_at: member ? null : (live.cancelRequestedAt ?? null), node_counts_json: counts,
requested_by: member && run.retry?.automatic ? 'system:retry' : 'principal:tester', requester_name: member && run.retry?.automatic ? null : 'tester', priority: 0, rewrite_history: false, status: member && run.replaced ? 'cancelled' : queued ? 'queued' : member && run.failed ? 'failed' : member && run.blockedBy ? 'blocked' : 'running', status_reason: null,
queued_at: at, launched_at: queued ? null : at, started_at: queued ? null : at, ended_at: member && (run.failed || run.blockedBy) ? at : null, cancel_requested_at: member ? null : (live.cancelRequestedAt ?? null), node_counts_json: counts,
ignored_audit_failures: 0, last_event_storage_id: member ? run.cursor : 1, narrowing: null, member_attempt: (member && run.retry?.attempt) || null,
version_policy: member ? null : (live.versionPolicy ?? 'newest'), skipped_versions: member ? [] : (live.skippedVersions ?? []), stale_reads: (member && run.staleReads) || []
};
Expand Down
77 changes: 73 additions & 4 deletions ui/src/routes/runs/[id]/job-drawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { RunNode } from '$lib/api';
import { formatAgo, formatDuration, formatStamp } from '$lib/format/time';
import { nodeLabel, outcomeCounts, shortRunId } from '$lib/operate/labels';
import { groupedCount } from '$lib/format/plural';
import { to } from '$lib/paths';
import { app } from '$lib/state/app.svelte';
import { createResource } from '$lib/state/resource.svelte';
Expand All @@ -12,6 +13,7 @@
import RunDrawer from './run-drawer.svelte';
import type { RunDetailState } from './state.svelte';
import { countsText, type TreeRow } from './utils/run-tree';
import { heldBy, rootFailed } from './utils/job-outcomes';
import { attemptFailure, failureLine } from '$lib/run/failure';

// A group run's job in the right-hand panel: how it went in this run (its nodes as a bar, what builds
Expand Down Expand Up @@ -114,8 +116,30 @@
{#if run?.statusReason && nodes.some((n) => n.status === 'not_run')}<p class="said" data-testid="job-stopped">Stopped: {run.statusReason}</p>{/if}
</div>
{:else if outcome === 'blocked'}
<!-- Nothing of its own failed, so what stopped it is upstream, in another job. -->
<p class="blocked" data-testid="job-error">Blocked: {blocker ?? 'an upstream node failed'}</p>
<!-- Nothing of its own failed, so what stopped it is upstream: the failure that held it, the nodes of its own that
skipped because of it, and what that left of the job. -->
{@const held = heldBy(jobKey, view.detail?.rootFailures ?? [])}
{@const skipped = nodes.filter((n) => n.status === 'skipped')}
{@const ran = job.counts.built + job.counts.running + job.counts.failed}
<ol class="chain" data-testid="job-error">
<li class="root">
{#if held}
<span class="from">{held.root.jobKey}</span> ·
{#if held.root.nodeKey}<!-- raw-button: opens the failed node in the panel --><button class="failed-node" onclick={() => view.clickNode(held.root.nodeKey!)} title="Open {nodeLabel(held.root.nodeKey)}">{rootFailed(held)}</button>{:else}{rootFailed(held)}{/if}
{#if held.moreJobs}<span class="faint"> · and {held.moreJobs} more {held.moreJobs === 1 ? 'job' : 'jobs'}</span>{/if}
{:else}
{blocker ?? 'an upstream node failed'}
{/if}
</li>
{#if skipped.length}
<li class="skipped">
{#each skipped.slice(0, 2) as n, i (n.nodeKey)}{#if i}<span>,&nbsp;</span>{/if}<!-- raw-button: opens the skipped node in the panel --><button class="node-link" onclick={() => view.clickNode(n.nodeKey)}>{nodeLabel(n.nodeKey)}</button>{/each}
{#if skipped.length > 2}<span class="faint"> +{groupedCount(skipped.length - 2)}</span>{/if}
<span class="faint"> skipped</span>
</li>
{/if}
<li class="here">{groupedCount(job.counts.skipped)} {job.counts.skipped === 1 ? 'node' : 'nodes'} in this job skipped · {groupedCount(ran)} ran</li>
</ol>
{/if}
{#if run?.staleReads.length}
<div class="stale" data-testid="job-stale-reads">
Expand Down Expand Up @@ -258,7 +282,7 @@
white-space: nowrap;
}
.error,
.blocked {
.chain {
margin: 0 0 10px;
font-size: 12.5px;
overflow-wrap: anywhere;
Expand All @@ -281,8 +305,53 @@
font-size: 12px;
overflow-wrap: anywhere;
}
.blocked {
/* What held a blocked job back, as steps down a thin rule: the failure upstream, the job's own nodes it skipped,
and what that left of the job. */
.chain {
padding: 0;
list-style: none;
color: var(--muted-foreground);
line-height: 18px;
}
.chain li {
position: relative;
padding: 0 0 8px 16px;
}
.chain li:last-child {
padding-bottom: 0;
}
.chain li::before {
position: absolute;
top: 6px;
left: 0;
box-sizing: border-box;
width: 7px;
height: 7px;
border: 1px solid var(--sb-text-faint);
border-radius: 50%;
content: '';
}
.chain li:not(:last-child)::after {
position: absolute;
top: 15px;
bottom: 1px;
left: 3px;
border-left: 1px solid var(--border);
content: '';
}
.chain .root::before {
border-color: var(--sb-error);
background: var(--sb-error);
}
.chain .root .failed-node {
color: var(--sb-error);
}
.chain .from,
.chain .here {
color: var(--foreground);
}
.chain .from {
font-family: var(--font-mono);
}
.faint {
color: var(--sb-text-faint);
Expand Down
21 changes: 17 additions & 4 deletions ui/src/routes/runs/[id]/root-causes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import { causeLine, type RootCause } from './utils/job-outcomes';

// A group run's root causes under its title, one line: the job that failed on its own account, what
// failed or why its run stopped, and how many jobs it held back. A job's name opens it in the panel;
// past two causes the rest are a count, which shows the failed jobs in the tree.
let { causes, onopen, onmore }: { causes: RootCause[]; onopen: (runId: string) => void; onmore: () => void } = $props();
// failed or why its run stopped, and the jobs it held back. A job's name opens it in the panel; past two
// causes the rest are a count, which shows the failed jobs in the tree, and past two held jobs the rest are a
// count, which shows the blocked jobs.
let { causes, onopen, onmore, onblocked }: { causes: RootCause[]; onopen: (runId: string) => void; onmore: () => void; onblocked: () => void } = $props();

const SHOWN = 2;
const HELD_SHOWN = 2;
</script>

{#if causes.length}
Expand All @@ -23,7 +25,13 @@
<button class="job" onclick={() => onopen(c.run.id)} title="Open {c.run.jobKey} in the panel">{c.run.jobKey ?? c.run.id}</button>
<span class="what">{causeLine(c)}</span>
{#if c.run.endedAt}<span class="faint" title={formatStamp(c.run.endedAt)}>at {formatClock(c.run.endedAt, app.now)}</span>{/if}
{#if c.heldBack}<span class="faint">· held back {c.heldBack === 1 ? '1 job' : `${c.heldBack} jobs`}</span>{/if}
{#if c.held.length}
<span class="faint held" data-testid="held-back">· held back
{#each c.held.slice(0, HELD_SHOWN) as h, j (h.id)}{#if j}<span>,&nbsp;</span>{/if}<!-- raw-button: opens the held-back job in the panel --><button class="job held-job" onclick={() => onopen(h.id)} title="Open {h.jobKey} in the panel">{h.jobKey ?? h.id}</button>{/each}
<!-- raw-button: shows the blocked jobs in the tree -->
{#if c.held.length > HELD_SHOWN}<button class="more" onclick={onblocked} title="Show the blocked jobs in the tree">+{c.held.length - HELD_SHOWN}</button>{/if}
</span>
{/if}
</span>
{/each}
</span>
Expand Down Expand Up @@ -63,6 +71,11 @@
font-family: var(--font-mono);
font-weight: 500;
}
/* A job held back failed nothing of its own: named quietly, beside the cause that held it. */
.held-job {
color: var(--foreground);
font-weight: 400;
}
.job:hover,
.more:hover {
text-decoration: underline;
Expand Down
Loading
Loading