fix: report storage usage and reclaim archived workspaces (#1813)

This commit is contained in:
Carlos Florêncio
2026-07-20 09:35:57 +01:00
committed by GitHub
parent 89dc8d1938
commit 110c2efcb1
20 changed files with 545 additions and 71 deletions
@@ -60,11 +60,50 @@ describe("StorageOverviewCard", () => {
it("renders unavailable Docker resources without inventing zero usage", () => {
render(<StorageOverviewCard overview={degradedOverview} onRunGoCache={vi.fn()} />);
const dockerResourceIds = ["managed-containers", "docker-build-cache", "docker-unused-images"];
const dockerResourceIds = [
"managed-containers",
"docker-image-layers",
"docker-build-cache",
"docker-unused-images",
];
for (const resourceId of dockerResourceIds) {
const trigger = screen.getByTestId(`storage-resource-${resourceId}-trigger`);
expect(trigger.textContent).toContain("Unavailable");
expect(trigger.textContent).not.toContain("0 B");
}
});
it("renders total workspace, unmanaged Go cache, and Docker layer usage", () => {
const overview = {
...degradedOverview,
summary: {
...degradedOverview.summary,
workspaces: {
total_bytes: 8 * 1024 ** 3,
active_bytes: 2 * 1024 ** 3,
candidate_bytes: 5 * 1024 ** 3,
},
go_cache: {
...degradedOverview.summary.go_cache,
unmanaged_path: "/root/.cache/go-build",
unmanaged_size_bytes: 25 * 1024 ** 3,
},
docker: {
...degradedOverview.summary.docker,
available: true,
image_layer_bytes: 14 * 1024 ** 3,
},
},
} satisfies StorageOverviewResponse;
render(<StorageOverviewCard overview={overview} onRunGoCache={vi.fn()} />);
expect(screen.getByTestId("storage-resource-workspaces-trigger").textContent).toContain("8 GB");
expect(screen.getByTestId("storage-resource-unmanaged-go-cache-trigger").textContent).toContain(
"25 GB",
);
expect(
screen.getByTestId("storage-resource-docker-image-layers-trigger").textContent,
).toContain("14 GB");
});
});
@@ -67,8 +67,8 @@ function storageResources(overview: StorageOverviewResponse): StorageResource[]
{
id: "workspaces",
label: "Task workspaces",
value: formatGigabytes(summary.workspaces.candidate_bytes ?? 0),
detail: `Active workspaces use ${formatGigabytes(summary.workspaces.active_bytes ?? 0)}`,
value: formatGigabytes(summary.workspaces.total_bytes ?? 0),
detail: `${formatGigabytes(summary.workspaces.candidate_bytes ?? 0)} reclaimable after the grace period · ${formatGigabytes(summary.workspaces.active_bytes ?? 0)} active`,
warning: summary.workspaces.warning,
},
quarantineResource(summary.quarantine),
@@ -89,6 +89,26 @@ function storageResources(overview: StorageOverviewResponse): StorageResource[]
detail: summary.go_cache.path ?? overview.capabilities.managed_go_cache_path,
warning: summary.go_cache.warning,
},
...(summary.go_cache.unmanaged_path
? [
{
id: "unmanaged-go-cache",
label: "User Go build cache",
value: formatGigabytes(summary.go_cache.unmanaged_size_bytes ?? 0),
detail: summary.go_cache.unmanaged_path,
},
]
: []),
{
id: "docker-image-layers",
label: "Docker image layers",
...dockerMeasurement(
summary.docker.available,
formatGigabytes(summary.docker.image_layer_bytes ?? 0),
overview.capabilities.docker_host || "Default Docker host",
),
warning: dockerWarning,
},
{
id: "docker-build-cache",
label: "Docker build cache",