Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Colour a crash-looping container's dot by its restart verdict

rcourtman4c82d303cdf6
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 26f5c2612e..f08516337d 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -5548,7 +5548,11 @@ once under the drawer's owner and reused by every rebuild of the inventory
rows, so a refresh or clock tick never recreates the button or closes its
review dialog. A container's row dot, State words and drawer header dot share
`mapDockerContainerStatus`, so a degraded container with no reported state is
-amber in all three. "Worth checking" renders through
+amber in all three. That mapper also owns the restart verdict
+(`dockerContainerRestartAttentionLabel`): a running container past five
+restarts is warning in its dot, the sort, the phone State words, the Restarts
+column and the drawer's lifted Restarts row alike, never a green dot beside an
+amber or red count. "Worth checking" renders through
`DrawerExceptionList.tsx` directly under the alerts line, above the charts:
one compact label/value line per lifted row with the shared
`detailValueToneClass` tone, not a card per section. A guest memory reading
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index cf789f9410..30fac62361 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -7039,7 +7039,15 @@ has one of those states, including an unhealthy running container. A narrow
table (under 360 pixels, most phones) has no State column: beside the shared
40 percent name it cut "Unhealthy" to "Unhe…", so the same words read under
the container name on every row, and a saved State sort waits for a layout
-that shows its header. From the
+that shows its header. A running container that Docker has restarted more
+than five times gets one verdict, from `mapDockerContainerStatus`: warning,
+"N restarts". The row dot, the drawer header dot and the attention-first sort
+read it everywhere; where the row has a Restarts column the count reads amber
+there and State keeps Docker's own word, and where it has none State says
+"N restarts". The drawer's Restarts row is amber too, and its observed state
+stays Docker's word so the restart is lifted once. Amber, not red: the
+container is running. Docker's count is a total, not a rate, as its hover
+says; the alert engine owns the windowed restart-loop alert. From the
compact layout up an Uptime column shows the current run (none for a stopped
container, whose leftover uptime is not time spent running), which marks a
container that just restarted; narrower rows keep it in the drawer. The Ports
diff --git a/frontend-modern/browser-tests/proxmox-docker-rows.cjs b/frontend-modern/browser-tests/proxmox-docker-rows.cjs
index 99250188ad..c48d9d09c4 100644
--- a/frontend-modern/browser-tests/proxmox-docker-rows.cjs
+++ b/frontend-modern/browser-tests/proxmox-docker-rows.cjs
@@ -105,6 +105,20 @@ const observations = (mode) => [
image: 'rabbitmq:3',
},
}),
+ // Running, but restarted past the attention threshold: its dot reads amber.
+ base('edge-loop', 'app-container', {
+ status: 'running',
+ metrics: { cpu: { percent: 5 }, memory: { percent: 10 } },
+ docker: {
+ agentId: 'agent-edge',
+ hostname: 'edge-long-hostname',
+ runtime: 'docker',
+ runtimeVersion: '27.5.1',
+ image: 'worker:2',
+ containerState: 'running',
+ restartCount: 12,
+ },
+ }),
base('nginx:latest', 'docker-image', {
docker: {
hostname: 'edge-long-hostname',
@@ -280,7 +294,7 @@ const observations = (mode) => [
timeout: 120000,
});
if (width === 390) await page.evaluate(() => document.documentElement.classList.add('dark'));
- await page.getByText('9 REST-mapped rows', { exact: true }).waitFor();
+ await page.getByText('10 REST-mapped rows', { exact: true }).waitFor();
await check(
'REST-first PMG counters and facets are present before any websocket hydration',
async () => {
@@ -447,6 +461,38 @@ const observations = (mode) => [
assert.ok(r > 200 && g > 120 && b < 80, JSON.stringify(colours));
});
await capture('container-degraded');
+ await check(
+ 'A crash-looping running container reads amber in its dot and drawer',
+ async () => {
+ const row = page.locator('[data-docker-container-row="edge-loop"]');
+ const rowDot = row.locator('[title="12 restarts"]').first();
+ await rowDot.waitFor();
+ const amber = (colour) => {
+ const [r, g, b] = colour.match(/\d+/g).map(Number);
+ return r > 200 && g > 120 && b < 80;
+ };
+ const dotColour = await rowDot.evaluate((el) => getComputedStyle(el).backgroundColor);
+ assert.ok(amber(dotColour), dotColour);
+ if (width === 390) {
+ // No Restarts column on a phone: the words under the name say why.
+ const words = row.locator('[data-docker-container-state]');
+ assert.equal(await words.innerText(), '12 restarts');
+ assert.equal(await words.getAttribute('data-docker-container-state'), 'warning');
+ await row.locator('td').first().tap();
+ } else {
+ await row.getByRole('button', { name: /details/i }).click();
+ }
+ const headerDot = page.getByRole('img', { name: '12 restarts' }).first();
+ await headerDot.waitFor();
+ assert.equal(
+ await headerDot.evaluate((el) => getComputedStyle(el).backgroundColor),
+ dotColour,
+ );
+ const detail = page.getByTestId('resource-drawer-exceptions');
+ await detail.getByText('Restarts', { exact: true }).waitFor();
+ },
+ );
+ await capture('container-restarts');
await select('Images');
await check('Image verdict fits; phone hidden headers and cells are symmetric', async () => {
const table = page.getByRole('region', { name: 'Image table' });
diff --git a/frontend-modern/browser-verification/04e9b4761336d325.json b/frontend-modern/browser-verification/04e9b4761336d325.json
new file mode 100644
index 0000000000..e5cb463dd1
--- /dev/null
+++ b/frontend-modern/browser-verification/04e9b4761336d325.json
@@ -0,0 +1,42 @@
+{
+ "version": 1,
+ "base_sha": "3c9d36172af91e7a448d813fca1b6d1f6a4e21ab",
+ "verified_at": "2026-10-14T15:29:47Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx",
+ "frontend-modern/src/features/docker/DockerContainersTable.tsx",
+ "frontend-modern/src/features/docker/dockerContainerStatePresentation.ts",
+ "frontend-modern/src/features/docker/dockerPageModel.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx": "616e68f379c94329fd24f7bf663abe605b6ca7d46f82cb8724bcfa10c1d25e0e",
+ "frontend-modern/src/features/docker/DockerContainersTable.tsx": "686531b273fc74682dc9bdfdccc820d5b219da339d30c91b33fe00f2a2a93950",
+ "frontend-modern/src/features/docker/dockerContainerStatePresentation.ts": "9eac65db3b59112b7ff907dab36eb485c6032eb9645fa04ac9f74050a47cbc00",
+ "frontend-modern/src/features/docker/dockerPageModel.ts": "e86356afe7f3979fc36b69b88ac93f053d1c1b6dbff40fc9cafac40fa9c3bd79"
+ },
+ "routes": [
+ "browser-tests/proxmox-docker-rows.html (production DockerContainersTable and ResourceDetailDrawer, Chromium and WebKit via Playwright 1.56.1 on pulse-dev)"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "running container with 12 restarts: row dot amber (old: green), sorted after the unhealthy row and ahead of healthy ones",
+ "desktop: State keeps \"Running\", Restarts count 12 amber (old: red)",
+ "phone: \"12 restarts\" amber under the name beside an amber dot",
+ "drawer: header dot amber matching the row; Worth checking lifts Restarts once, amber (old: red)",
+ "unhealthy, degraded and exited containers unchanged",
+ "reviewed by Sol from desktop and phone screenshots; its lifetime-count wording point is fixed here"
+ ],
+ "interactions": [
+ "row expand by pointer (desktop) and tap (phone)"
+ ]
+}
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx
index 8aa387769f..dde957331b 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailSummary.tsx
@@ -15,6 +15,10 @@ import { formatBytes, formatRelativeTime, formatUptime } from '@/utils/format';
import { useRelativeTimeNow } from '@/utils/relativeTimeClock';
import { getDockerImageRegistryLink } from '@/features/docker/dockerImageReference';
import { getDockerContainerUpdateAction } from '@/features/docker/dockerContainerUpdateAction';
+import {
+ dockerContainerRestartAttentionLabel,
+ dockerContainerRestartCountTitle,
+} from '@/features/docker/dockerPageModel';
import { UpdateButton } from '@/components/shared/ContainerUpdateBadge';
import {
getDockerContainerHealthCheckPresentation,
@@ -146,6 +150,7 @@ const ContainerUpdateNextSteps: Component<{ resource: Resource }> = (props) => {
};
const dockerSection = (
+ resource: Resource,
docker: NonNullable<Resource['docker']>,
now: number,
updateNextSteps: () => JSX.Element,
@@ -214,7 +219,9 @@ const dockerSection = (
: null,
typeof docker.restartCount === 'number'
? makeDetailRow('Restarts', formatInteger(docker.restartCount), {
- tone: docker.restartCount > 5 ? 'danger' : 'default',
+ // The row dot's restart verdict: running, but worth a look.
+ tone: dockerContainerRestartAttentionLabel(resource) ? 'warning' : 'default',
+ title: dockerContainerRestartCountTitle(docker.restartCount),
})
: null,
createdAt
@@ -416,7 +423,9 @@ export const useResourceSummarySections = (
]),
}
: null,
- props.content !== 'overview' && docker ? dockerSection(docker, now(), updateNextSteps) : null,
+ props.content !== 'overview' && docker
+ ? dockerSection(props.resource, docker, now(), updateNextSteps)
+ : null,
props.content !== 'overview' ? buildKubernetesControllerSection(props.resource, now()) : null,
props.content !== 'overview'
? {
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsx
index b15a15f6d5..04ad7f25af 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.docker-container.test.tsx
@@ -282,7 +282,8 @@ describe('ResourceDetailDrawer for Docker containers', () => {
// A worrying restart count moves in front of the charts, not repeated below.
const lifted = screen.getByTestId('resource-drawer-exceptions');
expect(within(lifted).getByText('Restarts')).toBeInTheDocument();
- expect(within(lifted).getByText('7').closest('td')).toHaveClass('text-rose-700');
+ // Amber, as its row dot reads: running, but worth a look.
+ expect(within(lifted).getByText('7').closest('td')).toHaveClass('text-amber-700');
expect(within(section).queryByText('Restarts')).not.toBeInTheDocument();
expect(within(section).getByText('Created')).toBeInTheDocument();
expect(within(section).getByText('Started')).toBeInTheDocument();
diff --git a/frontend-modern/src/features/docker/DockerContainersTable.tsx b/frontend-modern/src/features/docker/DockerContainersTable.tsx
index 0b9effbfcd..601d26a2b5 100644
--- a/frontend-modern/src/features/docker/DockerContainersTable.tsx
+++ b/frontend-modern/src/features/docker/DockerContainersTable.tsx
@@ -73,6 +73,8 @@ import {
compareDockerContainers,
dockerContainerPortsCompactSummary,
dockerContainerPortsSummary,
+ dockerContainerRestartAttentionLabel,
+ dockerContainerRestartCountTitle,
filterDockerResources,
mapDockerContainerStatus,
type DockerResourceStatusFilter,
@@ -93,7 +95,6 @@ import { DockerContainerLifecycleControls } from './DockerContainerLifecycleCont
import { CONTAINER_CPU_CAPACITY_DESCRIPTION } from './dockerCpuPresentation';
import { DockerImageReferenceText } from './DockerImageReferenceText';
import {
- DOCKER_RESTART_ATTENTION_THRESHOLD,
getDockerContainerStatePresentation,
getDockerContainerUptimeSeconds,
type DockerContainerStateTone,
@@ -533,7 +534,6 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
const memoryPercentOnly = () =>
memoryTotal() > 0 ? undefined : getPlatformTableFiniteMetric(resource.memory?.current);
const hasMemoryMetric = () => memoryTotal() > 0 || memoryPercentOnly() !== undefined;
- const restartCount = () => resource.docker?.restartCount ?? 0;
const ports = () => dockerContainerPortsSummary(resource);
const portsCompact = () => dockerContainerPortsCompactSummary(resource);
const networks = () => networksSummary(resource);
@@ -628,10 +628,11 @@ export const DockerContainersTable: Component<DockerContainersTableProps> = (pro
>
<span
class={`tabular-nums ${
- restartCount() > DOCKER_RESTART_ATTENTION_THRESHOLD
- ? 'font-medium text-red-600 dark:text-red-400'
+ dockerContainerRestartAttentionLabel(resource)
+ ? DOCKER_CONTAINER_STATE_TONE_CLASS.warning
: ''
}`}
+ title={dockerContainerRestartCountTitle(resource.docker?.restartCount ?? 0)}
>
{resource.docker?.restartCount}
</span>
diff --git a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
index 78c8fc14ec..3241ddd9f0 100644
--- a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
+++ b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx
@@ -318,9 +318,11 @@ describe('Docker native tables', () => {
expect(screen.getByText('volume:/usr/share/nginx/html (rw)')).toBeInTheDocument();
expect(screen.getByText('Available')).toBeInTheDocument();
- // A crash-looper (restarts above the v5 attention threshold) is flagged.
- expect(screen.getByText('7')).toHaveClass('text-red-600');
- expect(screen.getByText('2')).not.toHaveClass('text-red-600');
+ // A crash-looper (restarts above the v5 attention threshold) is flagged in
+ // amber, the colour its row dot shows: running, but worth a look.
+ expect(screen.getByText('7')).toHaveClass('text-amber-700');
+ expect(screen.getByText('2')).not.toHaveClass('text-amber-700');
+ expect(screen.getByTitle('7 restarts')).toBeInTheDocument();
// Both rows get a CPU cell; only the row with memory data gets a bar.
expect(screen.getAllByTestId('responsive-cpu-metric').length).toBe(2);
@@ -1123,6 +1125,8 @@ describe('Docker native tables', () => {
));
expect(screen.getByText('Restarts')).toBeInTheDocument();
expect(screen.queryByText('7 restarts')).not.toBeInTheDocument();
+ // The row dot carries the same verdict at every width.
+ expect(screen.getByTitle('7 restarts')).toBeInTheDocument();
});
it('leaves out the Uptime column when no container reports one', () => {
diff --git a/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts b/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts
index 15334326a2..b399825561 100644
--- a/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts
+++ b/frontend-modern/src/features/docker/__tests__/dockerContainerStatePresentation.test.ts
@@ -7,6 +7,7 @@ import {
getDockerContainerStatePresentation,
getDockerContainerUptimeSeconds,
} from '../dockerContainerStatePresentation';
+import { mapDockerContainerStatus } from '../dockerPageModel';
const container = (docker: NonNullable<Resource['docker']>, status = 'online'): Resource =>
({
@@ -164,7 +165,7 @@ describe('restart warning where the Restarts column is hidden', () => {
const looping = container({ containerState: 'running', health: 'healthy', restartCount: 7 });
expect(getDockerContainerStatePresentation(looping, { flagRestarts: true })).toEqual({
label: '7 restarts',
- title: 'Running, but Docker has restarted it 7 times',
+ title: 'Running. Docker has restarted it 7 times in total, not necessarily recently',
tone: 'warning',
});
expect(getDockerContainerStatePresentation(looping)).toMatchObject({ label: 'Healthy' });
@@ -176,6 +177,25 @@ describe('restart warning where the Restarts column is hidden', () => {
).toMatchObject({ label: 'Running', tone: null });
});
+ it('colours the row dot by the same restart verdict in every layout', () => {
+ const looping = container({ containerState: 'running', health: 'healthy', restartCount: 7 });
+ // The dot cannot change colour with the viewport, so it always carries
+ // the verdict; the words name it where no Restarts column does.
+ expect(mapDockerContainerStatus(looping)).toEqual({ variant: 'warning', label: '7 restarts' });
+ expect(
+ mapDockerContainerStatus(container({ containerState: 'running', restartCount: 5 })),
+ ).toEqual({ variant: 'success', label: 'Running' });
+ // A stopped container's restart history is not a running crash-loop.
+ expect(
+ mapDockerContainerStatus(container({ containerState: 'paused', restartCount: 9 })),
+ ).toMatchObject({ label: 'Paused' });
+ // The drawer shows the count on its own row, so its state stays Docker's.
+ expect(getDockerContainerRunStatePresentation(looping)).toMatchObject({
+ label: 'Running',
+ tone: null,
+ });
+ });
+
it('keeps a worse state ahead of the restart count', () => {
expect(
getDockerContainerStatePresentation(
diff --git a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
index efc0bbb8d6..225705ff29 100644
--- a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
+++ b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
@@ -709,6 +709,25 @@ describe('dockerPageModel', () => {
).toEqual(['dead', 'restarting', 'stopped', 'happy']);
});
+ it('ranks a running container past the restart threshold with the warnings', () => {
+ const container = (id: string, docker: Resource['docker']) =>
+ makeResource({ id, type: 'app-container', docker });
+ const rows = [
+ container('happy', { containerState: 'running', restartCount: 2 }),
+ container('at-threshold', { containerState: 'running', restartCount: 5 }),
+ container('looping', { containerState: 'running', restartCount: 6 }),
+ container('unhealthy', { containerState: 'running', health: 'unhealthy', restartCount: 9 }),
+ container('stopped', { containerState: 'exited', exitCode: 0, restartCount: 9 }),
+ ];
+ expect(rows.sort(compareDockerContainers).map((r) => r.id)).toEqual([
+ 'unhealthy',
+ 'looping',
+ 'stopped',
+ 'at-threshold',
+ 'happy',
+ ]);
+ });
+
it('orders Swarm services by replica health', () => {
const ok = makeResource({
id: 'svc-ok',
diff --git a/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts b/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts
index 69c63e00df..0c72049e99 100644
--- a/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts
+++ b/frontend-modern/src/features/docker/dockerContainerStatePresentation.ts
@@ -1,7 +1,12 @@
import type { Resource } from '@/types/resource';
import { asTrimmedString } from '@/utils/stringUtils';
-import { dockerContainerRunState, mapDockerContainerStatus } from './dockerPageModel';
+import {
+ dockerContainerRestartAttentionLabel,
+ dockerContainerRestartCountTitle,
+ dockerContainerRunState,
+ mapDockerContainerStatus,
+} from './dockerPageModel';
// The State column says what `docker ps` would flag beside the status: a
// failing or starting health check, a non-zero exit code, a restart. It reuses
@@ -48,31 +53,35 @@ const runStateTitle = (resource: Resource): string | undefined => {
return undefined;
};
-// v5 flagged crash-loopers in the restarts column; a container that restarted
-// more than this many times needs an operator's eye even while "running".
-export const DOCKER_RESTART_ATTENTION_THRESHOLD = 5;
+// The same container without its restart count, for a surface that shows the
+// count on its own (a Restarts column or drawer row).
+const withoutRestartCount = (resource: Resource): Resource => ({
+ ...resource,
+ docker: { ...resource.docker, restartCount: undefined },
+});
// flagRestarts: the row shows no Restarts column (narrow layouts), so a
-// running container past the restart threshold says so in its State cell.
+// running container past the restart threshold says so in its State cell, in
+// the words its row dot already uses. Where the row has a Restarts column,
+// that column carries the flag and State keeps Docker's own words.
export const getDockerContainerStatePresentation = (
resource: Resource,
options: { flagRestarts?: boolean } = {},
): DockerContainerStatePresentation => {
- const status = mapDockerContainerStatus(resource);
- const tone = presentationTone(status.variant);
- const restarts = resource.docker?.restartCount;
- if (
- options.flagRestarts &&
- tone === null &&
- typeof restarts === 'number' &&
- restarts > DOCKER_RESTART_ATTENTION_THRESHOLD
- ) {
+ const status = mapDockerContainerStatus(
+ options.flagRestarts ? resource : withoutRestartCount(resource),
+ );
+ const restartLabel = options.flagRestarts
+ ? dockerContainerRestartAttentionLabel(resource)
+ : undefined;
+ if (restartLabel && status.label === restartLabel) {
return {
- label: `${restarts} restarts`,
- title: `Running, but Docker has restarted it ${restarts} times`,
+ label: restartLabel,
+ title: `Running. ${dockerContainerRestartCountTitle(resource.docker?.restartCount ?? 0)}`,
tone: 'warning',
};
}
+ const tone = presentationTone(status.variant);
return { label: status.label, title: containerStateTitle(resource, status.label), tone };
};
@@ -81,9 +90,10 @@ export const getDockerContainerStatePresentation = (
export const getDockerContainerRunStatePresentation = (
resource: Resource,
): DockerContainerStatePresentation => {
+ // The drawer shows the restart count on its own row too.
const status = mapDockerContainerStatus({
...resource,
- docker: { ...resource.docker, health: undefined },
+ docker: { ...resource.docker, health: undefined, restartCount: undefined },
});
return {
label: status.label,
diff --git a/frontend-modern/src/features/docker/dockerPageModel.ts b/frontend-modern/src/features/docker/dockerPageModel.ts
index dda1ffa63f..c5d90c620d 100644
--- a/frontend-modern/src/features/docker/dockerPageModel.ts
+++ b/frontend-modern/src/features/docker/dockerPageModel.ts
@@ -115,6 +115,27 @@ export const dockerContainerRunState = (resource: Resource): string => {
return state === 'online' ? 'running' : state;
};
+// v5 flagged crash-loopers in the restarts column; a container that restarted
+// more than this many times needs an operator's eye even while "running".
+// Docker's restart count covers the container's life, not a recent window:
+// the alert engine owns the windowed restart-loop alert.
+export const DOCKER_RESTART_ATTENTION_THRESHOLD = 5;
+
+// "7 restarts" for a running container past the restart threshold, the one
+// restart verdict the row dot, the State words, the sort and the drawer share.
+export const dockerContainerRestartAttentionLabel = (resource: Resource): string | undefined => {
+ const restarts = resource.docker?.restartCount;
+ if (dockerContainerRunState(resource) !== 'running') return undefined;
+ if (typeof restarts !== 'number' || restarts <= DOCKER_RESTART_ATTENTION_THRESHOLD) {
+ return undefined;
+ }
+ return `${restarts} restarts`;
+};
+
+// Docker's restart count is a total, not a rate, which the hover says.
+export const dockerContainerRestartCountTitle = (restarts: number): string =>
+ `Docker has restarted it ${restarts} times in total, not necessarily recently`;
+
export function mapDockerContainerStatus(resource: Resource): StatusIndicator {
const state = dockerContainerRunState(resource);
const health = normalizeDockerToken(resource.docker?.health);
@@ -136,6 +157,8 @@ export function mapDockerContainerStatus(resource: Resource): StatusIndicator {
if (state === 'running' && health === 'starting') {
return { variant: 'warning', label: 'Starting' };
}
+ const restartLabel = dockerContainerRestartAttentionLabel(resource);
+ if (restartLabel) return { variant: 'warning', label: restartLabel };
if (state === 'running') {
return { variant: 'success', label: health === 'healthy' ? 'Healthy' : 'Running' };
}