fix(ci): make the lint gate fail for real and stop byparr leaking disk
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 36s
CI / tests-integration (push) Successful in 2m3s
CI / tests-unit (push) Successful in 2m18s
CI / tests-ui (push) Successful in 3m6s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 3m14s
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 36s
CI / tests-integration (push) Successful in 2m3s
CI / tests-unit (push) Successful in 2m18s
CI / tests-ui (push) Successful in 3m6s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 3m14s
The CI lint step was `biome check . || true`, so it could never fail: 14 real
violations were passing unnoticed. Drop the `|| true` and fix what it found.
Lint fixes, none of which change behaviour:
- give list items their natural identity instead of the array index
(key={c} / key={char}, key={`skeleton-${i}`})
- document the two useEffect dependency lists that must keep their
function-declaration handlers, with the reasoning that dropping them broke
the tree and save-on-Ctrl+S once already (704e3363)
- scope the remaining noArrayIndexKey / useExhaustiveDependencies exemptions to
the three files that need them, in biome.json instead of scattered comments
Storage, on a host that had grown to 81% disk:
- byparr starts a Firefox per request and never removes the profile it leaves in
the container's writable layer. With no volume mounted, nothing else reclaimed
it: 716 profiles / 6.8 GB in two days, ~1.7 GB/day. docker-prune.sh now removes
orphaned profiles, identifying live ones by the open fd in /proc/<pid>/fd rather
than by age, because browsers stay warm for ~27 hours here — longer than the
leak window, so no age threshold can be both safe and useful.
- bound the build cache properly: buildx treats --max-used-space and --filter as
mutually exclusive, so passing both silently dropped the 4 GB cap and the cache
reached 49 GB.
- escalate to the emergency prune when / drops below 8 GB free, so the bound holds
even if the schedule stops.
- clear multi-GB tmp_pack files left behind by a gc that was OOM-killed
mid-repack; git only removes those on the next successful gc.
- make setup-cron.sh append instead of replacing the crontab (`crontab -`
overwrites the whole file, which had been dropping the other scheduled jobs),
and run the prune daily rather than weekly to match the leak rate.
Volumes are still never pruned: mariadb-turbo-data is a database.
This commit is contained in:
1 parent
6bffc53779
commit
108c6ce03d
11 files changed
+180
-17
No files matched your search
+24
@@ -38,6 +38,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"includes": [
|
||||||
|
"src/components/admin/catalog-manager/sortable-tree.tsx",
|
||||||
|
"src/components/admin/studio/organize-imports-dialog/mall-helpers.tsx",
|
||||||
|
"src/app/admin/import/furni/nitro-editor-dialog.tsx"
|
||||||
|
],
|
||||||
|
"linter": {
|
||||||
|
"rules": {
|
||||||
|
"suspicious": {
|
||||||
|
"noArrayIndexKey": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"includes": ["src/components/admin/catalog-manager/sortable-tree.tsx"],
|
||||||
|
"linter": {
|
||||||
|
"rules": {
|
||||||
|
"correctness": {
|
||||||
|
"useExhaustiveDependencies": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"css": {
|
"css": {
|
||||||
|
|||||||
@@ -388,9 +388,7 @@ describe("Redis application cache", () => {
|
|||||||
const fetch = async () => ({ revision: ++fetches });
|
const fetch = async () => ({ revision: ++fetches });
|
||||||
expect(await cache.cached(key, 60_000, fetch)).toEqual({ revision: 1 });
|
expect(await cache.cached(key, 60_000, fetch)).toEqual({ revision: 1 });
|
||||||
// Second read is served from cache, so the origin is not consulted again.
|
// Second read is served from cache, so the origin is not consulted again.
|
||||||
expect(
|
expect(await cache.cached(key, 60_000, fetch)).toEqual({ revision: 1 });
|
||||||
await cache.cached(key, 60_000, fetch),
|
|
||||||
).toEqual({ revision: 1 });
|
|
||||||
expect(await appRedis?.ttl(key)).toBeGreaterThan(0);
|
expect(await appRedis?.ttl(key)).toBeGreaterThan(0);
|
||||||
cache.invalidateMemory(key);
|
cache.invalidateMemory(key);
|
||||||
expect(await cache.cached(key, 60_000, fetch)).toEqual({ revision: 1 });
|
expect(await cache.cached(key, 60_000, fetch)).toEqual({ revision: 1 });
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@
|
|||||||
"build": "pnpm assets:editor && next build --webpack",
|
"build": "pnpm assets:editor && next build --webpack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"toolchain:check": "node scripts/check-node-toolchain.mjs",
|
"toolchain:check": "node scripts/check-node-toolchain.mjs",
|
||||||
"lint": "biome check . || true",
|
"lint": "biome check .",
|
||||||
"biome:lint": "biome check . || true",
|
"biome:lint": "biome check .",
|
||||||
"format": "biome format --write .",
|
"format": "biome format --write .",
|
||||||
"diag:permissions": "tsx scripts/diagnose-permission-page.ts",
|
"diag:permissions": "tsx scripts/diagnose-permission-page.ts",
|
||||||
"jobs:worker": "node --conditions=react-server --import tsx scripts/jobs-worker.ts",
|
"jobs:worker": "node --conditions=react-server --import tsx scripts/jobs-worker.ts",
|
||||||
|
|||||||
+94
-2
File diff suppressed because it is too large.
Load diff
+28
-3
@@ -1,10 +1,35 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Setup cron jobs for maintenance
|
# Setup cron jobs for maintenance
|
||||||
|
#
|
||||||
|
# Appends to the existing crontab. `crontab -` replaces the whole file, so a
|
||||||
|
# script that pipes one job at a time silently drops every other scheduled job.
|
||||||
|
# Entries are matched by their command, so re-running this is idempotent.
|
||||||
|
set -Eeuo pipefail
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Adds one schedule line to the crontab unless its command is already present.
|
||||||
|
add_job() {
|
||||||
|
local schedule="$1" command
|
||||||
|
command="${schedule##* }"
|
||||||
|
local current
|
||||||
|
current="$(crontab -l 2>/dev/null || true)"
|
||||||
|
if grep -Fq "$command" <<<"$current"; then
|
||||||
|
echo "Already scheduled: $command"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ -z "$current" ]]; then
|
||||||
|
printf '%s\n' "$schedule" | crontab -
|
||||||
|
else
|
||||||
|
printf '%s\n%s\n' "$current" "$schedule" | crontab -
|
||||||
|
fi
|
||||||
|
echo "Scheduled: $schedule"
|
||||||
|
}
|
||||||
|
|
||||||
# Run backup every day at 03:00
|
# Run backup every day at 03:00
|
||||||
echo "0 3 * * * $SCRIPT_DIR/backup.sh" | crontab -
|
add_job "0 3 * * * $SCRIPT_DIR/backup.sh"
|
||||||
# Run prune every Sunday at 04:00
|
# Run prune every day at 04:00. Daily rather than weekly: byparr leaks roughly
|
||||||
echo "0 4 * * 0 $SCRIPT_DIR/docker-prune.sh" | crontab -
|
# 1.7 GB/day of orphaned browser profiles into its writable layer, so a weekly
|
||||||
|
# run would let ~12 GB accumulate before anything reclaimed it.
|
||||||
|
add_job "0 4 * * * $SCRIPT_DIR/docker-prune.sh"
|
||||||
|
|
||||||
echo "Cron jobs configured."
|
echo "Cron jobs configured."
|
||||||
@@ -56,6 +56,7 @@ export function PrefixDialog({
|
|||||||
if (!saving && confirmLeave()) onClose();
|
if (!saving && confirmLeave()) onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// biome-ignore lint/correctness/useExhaustiveDependencies: isOpen acts as a trigger here, not a value read in the body; removing it is a real regression, reverted once in 704e3363
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSaveError(false);
|
setSaveError(false);
|
||||||
if (editPrefix) {
|
if (editPrefix) {
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ export function PrefixesClient({ canEdit }: { canEdit: boolean }) {
|
|||||||
{"{"}
|
{"{"}
|
||||||
{[...prefix.text].map((char, i) => (
|
{[...prefix.text].map((char, i) => (
|
||||||
<span
|
<span
|
||||||
key={`char-${i}`}
|
key={char}
|
||||||
style={{
|
style={{
|
||||||
color: colors[Math.min(i, colors.length - 1)],
|
color: colors[Math.min(i, colors.length - 1)],
|
||||||
}}
|
}}
|
||||||
@@ -280,9 +280,9 @@ export function PrefixesClient({ canEdit }: { canEdit: boolean }) {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
{colors.slice(0, 5).map((c, i) => (
|
{colors.slice(0, 5).map((c) => (
|
||||||
<div
|
<div
|
||||||
key={`color-${i}`}
|
key={c}
|
||||||
className="w-4 h-4 rounded border"
|
className="w-4 h-4 rounded border"
|
||||||
style={{ backgroundColor: c }}
|
style={{ backgroundColor: c }}
|
||||||
title={c}
|
title={c}
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ export function ClientView({
|
|||||||
window.removeEventListener("touchmove", onTouchMove);
|
window.removeEventListener("touchmove", onTouchMove);
|
||||||
window.removeEventListener("touchend", onEnd);
|
window.removeEventListener("touchend", onEnd);
|
||||||
};
|
};
|
||||||
|
// biome-ignore lint/correctness/useExhaustiveDependencies: snapPos is a pure helper that reads neither state nor props, and being a function declaration its identity changes every render. Depending on it would re-bind the drag listeners on every mousemove.
|
||||||
}, [dragging, snapPos]);
|
}, [dragging, snapPos]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ function InlineEditorSession({
|
|||||||
}
|
}
|
||||||
document.addEventListener("keydown", onKeyDown);
|
document.addEventListener("keydown", onKeyDown);
|
||||||
return () => document.removeEventListener("keydown", onKeyDown);
|
return () => document.removeEventListener("keydown", onKeyDown);
|
||||||
|
// biome-ignore lint/correctness/useExhaustiveDependencies: handleSave is a function declaration, so its identity changes every render; depending on it would re-register this listener on every keystroke. Removing it from the deps instead is what broke save-on-Ctrl+S before (704e3363).
|
||||||
}, [canEdit, isDirty, saving, page, handleSave]);
|
}, [canEdit, isDirty, saving, page, handleSave]);
|
||||||
|
|
||||||
const loadPage = useCallback(
|
const loadPage = useCallback(
|
||||||
|
|||||||
@@ -1108,7 +1108,7 @@ export function SortableTree({
|
|||||||
<div className="space-y-1 p-2" aria-hidden="true">
|
<div className="space-y-1 p-2" aria-hidden="true">
|
||||||
{[...Array(8)].map((_, i) => (
|
{[...Array(8)].map((_, i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={`skeleton-${i}`}
|
||||||
className="flex items-center gap-2 rounded-md px-2 py-1.5"
|
className="flex items-center gap-2 rounded-md px-2 py-1.5"
|
||||||
style={{ marginLeft: `${(i % 3) * 14}px` }}
|
style={{ marginLeft: `${(i % 3) * 14}px` }}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ it("preserves production runtime configuration and recent cache", () => {
|
|||||||
// but never touches volumes.
|
// but never touches volumes.
|
||||||
expect(deploy).toContain('bash "$deploy_dir/scripts/docker-prune.sh"');
|
expect(deploy).toContain('bash "$deploy_dir/scripts/docker-prune.sh"');
|
||||||
const prune = readFileSync("scripts/docker-prune.sh", "utf8");
|
const prune = readFileSync("scripts/docker-prune.sh", "utf8");
|
||||||
expect(prune).toContain(
|
// The build cache is bounded by the cap alone. buildx treats --max-used-space
|
||||||
'docker builder prune -af --filter "until=72h" --max-used-space=4g',
|
// and --filter as mutually exclusive: combining them silently dropped the
|
||||||
);
|
// cap, so the cache grew unbounded (49 GB observed on this host).
|
||||||
|
expect(prune).toContain("docker builder prune -af --max-used-space=");
|
||||||
expect(prune).toContain('docker image prune -af --filter "until=168h"');
|
expect(prune).toContain('docker image prune -af --filter "until=168h"');
|
||||||
expect(prune).toContain('docker container prune -f --filter "until=24h"');
|
expect(prune).toContain('docker container prune -f --filter "until=24h"');
|
||||||
// Emergency `--force` mode drops every age window to reclaim unused bytes,
|
// Emergency `--force` mode drops every age window to reclaim unused bytes,
|
||||||
@@ -42,9 +43,29 @@ it("preserves production runtime configuration and recent cache", () => {
|
|||||||
expect(prune).toContain('== "--force" ]]');
|
expect(prune).toContain('== "--force" ]]');
|
||||||
expect(prune).toContain("FORCE=1");
|
expect(prune).toContain("FORCE=1");
|
||||||
expect(prune).toContain("(( FORCE ))");
|
expect(prune).toContain("(( FORCE ))");
|
||||||
|
// The default mode escalates on its own when the disk fills, so the bound
|
||||||
|
// holds even if this stops running on a schedule.
|
||||||
|
expect(prune).toContain("FREE_KB");
|
||||||
|
expect(prune).toMatch(/if\s*\(\(\s*FREE_KB\s*</);
|
||||||
expect(deploy).not.toContain("--force");
|
expect(deploy).not.toContain("--force");
|
||||||
expect(deploy).not.toContain("docker volume prune");
|
expect(deploy).not.toContain("docker volume prune");
|
||||||
expect(prune).not.toContain("docker volume prune");
|
expect(prune).not.toContain("docker volume prune");
|
||||||
|
// A gc killed mid-repack leaves a multi-GB tmp_pack that only a later
|
||||||
|
// successful gc clears; one held 7.7 GB while the object store was 83 MB.
|
||||||
|
expect(prune).toContain("tmp_pack");
|
||||||
|
// Age-guarded, so a gc running right now is never touched.
|
||||||
|
expect(prune).toContain("-mmin +1440");
|
||||||
|
// byparr starts a Firefox per request and never removes the profile it
|
||||||
|
// leaves in the container's writable layer: 716 profiles / 6.8 GB in two
|
||||||
|
// days, and nothing else reclaims them because the layer has no volume.
|
||||||
|
expect(prune).toContain("playwright_firefoxdev_profile");
|
||||||
|
// Deleting a profile a live browser still has open kills that job, and an
|
||||||
|
// age window alone cannot be safe: browsers stay warm for ~27 hours here,
|
||||||
|
// far longer than the leak window. Liveness comes from the open fd instead.
|
||||||
|
expect(prune).toContain("/proc/$p/fd");
|
||||||
|
expect(prune).toContain('grep -Fxq "$dir" "$live_file"');
|
||||||
|
// A profile still being written to is not an orphan yet.
|
||||||
|
expect(prune).toContain("BYPARR_TMP_MIN_AGE_MIN");
|
||||||
});
|
});
|
||||||
it("builds the checked out source without fetching a moving remote branch", () => {
|
it("builds the checked out source without fetching a moving remote branch", () => {
|
||||||
const dockerfile = readFileSync("Dockerfile", "utf8");
|
const dockerfile = readFileSync("Dockerfile", "utf8");
|
||||||
|
|||||||
Reference in new issue
Block a user