Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ and listed with their assets on the
them with `--exec` now, as written (#597). Until this release, a link
helps: `ln -sf /root/.local/bin/devstack /usr/local/bin/devstack` in the
distribution as root.
- **A job that still runs is not counted as healthy in the dashboard.** The
overview's "healthy" count, its filter and a job's shortcut card put a
running job (a migration) there; it counts as starting now until it
completed, as the daemon and the hub's summary count it (#591).

## [0.51.0] - 2026-11-19

Expand Down
6 changes: 4 additions & 2 deletions ui/src/api/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class MockHub {
return {
id: s.entry.id,
state: attention ? 'attention' : s.entry.running ? 'ok' : 'stopped',
ready: services.filter((v) => statusBucket(v.status) === 'healthy').length,
ready: services.filter((v) => statusBucket(v) === 'healthy').length,
total: services.length,
lanes: s.entry.running ? s.startedLanes.size : 0,
};
Expand Down Expand Up @@ -1428,7 +1428,9 @@ export class MockTransport implements Transport {
const svc = s.view.services.find((x) => x.name === r);
const ctr = s.view.infra.flatMap((g) => g.containers).find((c) => c.service === r);
const state = svc ? svc.status.state : ctr ? (ctr.state === 'running' ? 'running' : ctr.state) : 'missing';
if (!ready(state)) return json(409, { error: `${name} requires ${r}, which is not ready (${state})` });
// A job that still runs is not ready (#591), as the daemon counts it.
const isReady = svc ? statusBucket(svc) === 'healthy' : ready(state);
if (!isReady) return json(409, { error: `${name} requires ${r}, which is not ready (${state})` });
}
const run = s.startRun(name, commandPlan(name));
return json(202, { run: run.id });
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/ShortcutCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const url = computed(() => {
const s = props.service;
return webUrl(s.link) || webUrl(s.url) || s.port ? serviceUrl(s) : null;
});
const bucket = computed(() => statusBucket(props.service.status));
const bucket = computed(() => statusBucket(props.service));
const tone: Record<ReturnType<typeof statusBucket>, string> = { healthy: 'ok', starting: 'accent', failed: 'danger', idle: 'neutral' };
</script>

Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ watch(
() => [stack.id, stack.lane, stack.live, stack.services] as const,
([id, lane, live, services]) => {
if (id && lane === null && live && services.length) {
mainActive.value[id] = services.some((x) => statusBucket(x.status) !== 'idle');
mainFails.value[id] = services.some((x) => statusBucket(x.status) === 'failed');
mainActive.value[id] = services.some((x) => statusBucket(x) !== 'idle');
mainFails.value[id] = services.some((x) => statusBucket(x) === 'failed');
}
},
{ immediate: true },
Expand Down Expand Up @@ -268,7 +268,7 @@ const servedBy = (s: StackEntry) => (known.value[s.id] ?? []).find((l) => l.owns
*/
function laneRuns(s: StackEntry, l: LaneView): number {
if (s.id !== stack.id || stack.lane !== l.name || !stack.live || !stack.services.length) return l.running;
return stack.services.filter((x) => statusBucket(x.status) !== 'idle').length;
return stack.services.filter((x) => statusBucket(x) !== 'idle').length;
}
/** How many of a lane's containers run, and of all: the shown lane's from its stream, as `laneRuns` does. */
function laneContainers(s: StackEntry, l: LaneView): [number, number] {
Expand All @@ -282,7 +282,7 @@ function laneDot(s: StackEntry, l: LaneView): Dot {
if (l.moving?.error) return 'err';
// The shown lane's own services, from its stream.
// (A lane not started has no stream: the one shown is the main tree's.)
if (started(l) && s.id === stack.id && stack.lane === l.name && stack.live && stack.services.some((x) => statusBucket(x.status) === 'failed')) return 'err';
if (started(l) && s.id === stack.id && stack.lane === l.name && stack.live && stack.services.some((x) => statusBucket(x) === 'failed')) return 'err';
if (started(l) && (l.node_error || l.notices?.length)) return 'warn';
if (!started(l)) return 'off';
const [cr, c] = laneContainers(s, l);
Expand Down
18 changes: 14 additions & 4 deletions ui/src/lib/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ describe('statusLook', () => {
});

it('buckets for the summary', () => {
expect(statusBucket({ state: 'running' })).toBe('healthy');
expect(statusBucket({ state: 'unhealthy', reason: '' })).toBe('failed');
expect(statusBucket({ state: 'exited', exit_code: 0 })).toBe('idle');
expect(statusBucket({ state: 'exited', exit_code: 1 })).toBe('failed');
const b = (status: Status, kind = 'service') => statusBucket({ status, kind });
expect(b({ state: 'running' })).toBe('healthy');
expect(b({ state: 'unhealthy', reason: '' })).toBe('failed');
expect(b({ state: 'exited', exit_code: 0 })).toBe('idle');
expect(b({ state: 'exited', exit_code: 1 })).toBe('failed');
});

it('counts a running job as starting, not healthy (#591)', () => {
const b = (status: Status) => statusBucket({ status, kind: 'job' });
expect(b({ state: 'running' })).toBe('starting');
expect(b({ state: 'completed', exit_code: 0 })).toBe('idle');
expect(b({ state: 'failed', reason: 'exit 1' })).toBe('failed');
// A long-running kind stays healthy while it runs.
expect(statusBucket({ status: { state: 'running' }, kind: 'devserver' })).toBe('healthy');
});
});

Expand Down
12 changes: 9 additions & 3 deletions ui/src/lib/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ export function statusLook(s: Status): StatusLook {
return { label: cap(state), tone: 'neutral', busy: false, detail: null };
}

/** Healthy/starting/failed buckets for the summary. */
export function statusBucket(s: Status): 'healthy' | 'starting' | 'failed' | 'idle' {
/**
* Healthy/starting/failed buckets for the summary. Takes the service, not its
* status alone: a job is `running` while it runs, and counts as ready only
* once it completed (#591, as the daemon's #573 and the hub's #575 count).
*/
export function statusBucket(svc: Pick<ServiceView, 'status' | 'kind'>): 'healthy' | 'starting' | 'failed' | 'idle' {
const s = svc.status;
switch (s.state) {
case 'healthy':
case 'running':
return 'healthy';
case 'running':
return svc.kind === 'job' ? 'starting' : 'healthy';
case 'starting':
case 'building':
return 'starting';
Expand Down
10 changes: 5 additions & 5 deletions ui/src/stores/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export const useStack = defineStore('stack', () => {
active: mainActive.value,
port_offset: 0,
owns_main: !(lanesOf.value === id.value && lanes.value.some((l) => l.owns_main)),
running: services.filter((x) => statusBucket(x.status) !== 'idle').length,
running: services.filter((x) => statusBucket(x) !== 'idle').length,
services: services.length,
containers_running: containers.filter((c) => c.state === 'running').length,
containers: containers.length,
Expand All @@ -319,7 +319,7 @@ export const useStack = defineStore('stack', () => {
const runningLanes = computed(() => (lanesOf.value === id.value ? lanes.value.filter((l) => l.active !== false).map((l) => l.name) : []));
/** The main tree is shown and nothing of it runs, while its daemon stays for the lanes. */
const mainIdle = computed(
() => running.value && lane.value === null && live.value && services.value.length > 0 && services.value.every((s) => statusBucket(s.status) === 'idle'),
() => running.value && lane.value === null && live.value && services.value.length > 0 && services.value.every((s) => statusBucket(s) === 'idle'),
);

/**
Expand Down Expand Up @@ -350,7 +350,7 @@ export const useStack = defineStore('stack', () => {
if (!running.value) return false;
const mv = mainView.value;
if (!mv) return true;
if (mv.services.length) return mv.services.some((x) => statusBucket(x.status) !== 'idle');
if (mv.services.length) return mv.services.some((x) => statusBucket(x) !== 'idle');
const containers = mv.infra.flatMap((g) => g.containers).filter((c) => c.managed !== false);
return !containers.length || containers.some((c) => c.state === 'running');
});
Expand Down Expand Up @@ -634,7 +634,7 @@ export const useStack = defineStore('stack', () => {
} catch {
/* the last view seen */
}
const names = list.filter((x) => statusBucket(x.status) !== 'idle' && (how === 'restart' || x.build_id)).map((x) => x.name);
const names = list.filter((x) => statusBucket(x) !== 'idle' && (how === 'restart' || x.build_id)).map((x) => x.name);
if (!names.length) {
ui.toast('info', `${what} main`, 'Nothing of it runs.');
return;
Expand Down Expand Up @@ -877,7 +877,7 @@ export const useStack = defineStore('stack', () => {
}
});
/** A service that runs, or is on its way to. */
const ran = (s: ServiceView) => !['idle', 'failed'].includes(statusBucket(s.status));
const ran = (s: ServiceView) => !['idle', 'failed'].includes(statusBucket(s));

function connect() {
if (!id.value) return;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/OverviewView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function toggle(f: Filter) {
filter.value = filter.value === f ? null : f;
}
function matches(m: Member, f: Filter): boolean {
if (m.kind === 'service') return f === 'pending' ? !!m.service.candidate : statusBucket(m.service.status) === f;
if (m.kind === 'service') return f === 'pending' ? !!m.service.candidate : statusBucket(m.service) === f;
if (m.kind === 'container') return f !== 'pending' && !!m.container && containerBucket(m.container) === f;
return false;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ const counts = computed(() => {
const c = { healthy: 0, starting: 0, failed: 0, idle: 0 };
const v = view.value;
if (!v) return c;
for (const s of v.services) c[statusBucket(s.status)]++;
for (const s of v.services) c[statusBucket(s)]++;
for (const g of v.infra) for (const x of g.containers) c[containerBucket(x)]++;
return c;
});
Expand Down