fix(gc): fail docker deletes on revalidation errors and read the mount table byte-safe
CI / quality (push) Skipped
CI / lint-python (push) Failing after 0s
CodeQL Advanced / Check security (none, actions) (push) Waiting to run
CI / security-codeql (push) Waiting to run
CodeQL Advanced / Check security (none, python) (push) Waiting to run
Test Units / test-unit (push) Waiting to run
CI / test-unit (push) Waiting to run
Test Code Integration / test-integration (push) Waiting to run
CI / test-integration (push) Waiting to run
Test OS Containers / test-env-virtual (arch) (push) Waiting to run
CI / test-env-virtual (push) Waiting to run
Test OS Containers / test-env-virtual (centos) (push) Waiting to run
CI / test-env-nix (push) Waiting to run
Test OS Containers / test-env-virtual (debian) (push) Waiting to run
CI / test-e2e (push) Waiting to run
Test OS Containers / test-env-virtual (fedora) (push) Waiting to run
CI / test-virgin-user (push) Waiting to run
Test OS Containers / test-env-virtual (ubuntu) (push) Waiting to run
CI / test-virgin-root (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (arch) (push) Waiting to run
CI / lint-shell (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (centos) (push) Waiting to run
CI / lint-docker (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (debian) (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (fedora) (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (ubuntu) (push) Waiting to run
Test End-To-End / test-e2e (arch) (push) Waiting to run
Test End-To-End / test-e2e (centos) (push) Waiting to run
Test End-To-End / test-e2e (debian) (push) Waiting to run
Test End-To-End / test-e2e (fedora) (push) Waiting to run
Test End-To-End / test-e2e (ubuntu) (push) Waiting to run
Test Virgin User / test-virgin-user (arch) (push) Waiting to run
Test Virgin User / test-virgin-user (centos) (push) Waiting to run
Test Virgin User / test-virgin-user (debian) (push) Waiting to run
Test Virgin User / test-virgin-user (fedora) (push) Waiting to run
Test Virgin User / test-virgin-user (ubuntu) (push) Waiting to run
Test Virgin Root / test-virgin-root (arch) (push) Waiting to run
Test Virgin Root / test-virgin-root (centos) (push) Waiting to run
Test Virgin Root / test-virgin-root (debian) (push) Waiting to run
Test Virgin Root / test-virgin-root (fedora) (push) Waiting to run
Test Virgin Root / test-virgin-root (ubuntu) (push) Waiting to run
ShellCheck / lint-shell (push) Waiting to run
Ruff (Python code sniffer) / lint-python (push) Failing after 0s
Docker Linter / Lint Dockerfile (push) Waiting to run
CI / quality (push) Skipped
CI / lint-python (push) Failing after 0s
CodeQL Advanced / Check security (none, actions) (push) Waiting to run
CI / security-codeql (push) Waiting to run
CodeQL Advanced / Check security (none, python) (push) Waiting to run
Test Units / test-unit (push) Waiting to run
CI / test-unit (push) Waiting to run
Test Code Integration / test-integration (push) Waiting to run
CI / test-integration (push) Waiting to run
Test OS Containers / test-env-virtual (arch) (push) Waiting to run
CI / test-env-virtual (push) Waiting to run
Test OS Containers / test-env-virtual (centos) (push) Waiting to run
CI / test-env-nix (push) Waiting to run
Test OS Containers / test-env-virtual (debian) (push) Waiting to run
CI / test-e2e (push) Waiting to run
Test OS Containers / test-env-virtual (fedora) (push) Waiting to run
CI / test-virgin-user (push) Waiting to run
Test OS Containers / test-env-virtual (ubuntu) (push) Waiting to run
CI / test-virgin-root (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (arch) (push) Waiting to run
CI / lint-shell (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (centos) (push) Waiting to run
CI / lint-docker (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (debian) (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (fedora) (push) Waiting to run
Test Virgin Nix (flake only) / test-env-nix (ubuntu) (push) Waiting to run
Test End-To-End / test-e2e (arch) (push) Waiting to run
Test End-To-End / test-e2e (centos) (push) Waiting to run
Test End-To-End / test-e2e (debian) (push) Waiting to run
Test End-To-End / test-e2e (fedora) (push) Waiting to run
Test End-To-End / test-e2e (ubuntu) (push) Waiting to run
Test Virgin User / test-virgin-user (arch) (push) Waiting to run
Test Virgin User / test-virgin-user (centos) (push) Waiting to run
Test Virgin User / test-virgin-user (debian) (push) Waiting to run
Test Virgin User / test-virgin-user (fedora) (push) Waiting to run
Test Virgin User / test-virgin-user (ubuntu) (push) Waiting to run
Test Virgin Root / test-virgin-root (arch) (push) Waiting to run
Test Virgin Root / test-virgin-root (centos) (push) Waiting to run
Test Virgin Root / test-virgin-root (debian) (push) Waiting to run
Test Virgin Root / test-virgin-root (fedora) (push) Waiting to run
Test Virgin Root / test-virgin-root (ubuntu) (push) Waiting to run
ShellCheck / lint-shell (push) Waiting to run
Ruff (Python code sniffer) / lint-python (push) Failing after 0s
Docker Linter / Lint Dockerfile (push) Waiting to run
CodeRabbit on PR 21: an unreadable docker after the plan was reported as a skip and the run exited 0, and a non-UTF-8 mount path in /proc/self/mountinfo aborted the plan. A revalidation warning now fails the item; the mount table is read with surrogateescape. PR: https://github.com/kevinveenbirkenbach/package-manager/pull/21 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
43a3f9f73d
commit
236649cbdf
3 files changed
+34
-2
No files matched your search
@@ -172,9 +172,12 @@ def delete_docker(entry: dict, now: float) -> str:
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
subprocess.CalledProcessError: when docker refuses the delete.
|
subprocess.CalledProcessError: when docker refuses the delete.
|
||||||
|
RuntimeError: when docker cannot be read again before the delete.
|
||||||
"""
|
"""
|
||||||
name = entry["name"]
|
name = entry["name"]
|
||||||
fresh, _ = docker_items(now)
|
fresh, warnings = docker_items(now)
|
||||||
|
if warnings:
|
||||||
|
raise RuntimeError(f"revalidation failed: {'; '.join(warnings)}")
|
||||||
if not any(
|
if not any(
|
||||||
i["kind"] == entry["kind"] and i["name"] == name and i["risk"] == LOW
|
i["kind"] == entry["kind"] and i["name"] == name and i["risk"] == LOW
|
||||||
for i in fresh
|
for i in fresh
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def _measure(path: str, st: os.stat_result) -> tuple[TreeStats | None, int, floa
|
|||||||
|
|
||||||
def _mount_hold(path: str) -> tuple[str, str] | None:
|
def _mount_hold(path: str) -> tuple[str, str] | None:
|
||||||
try:
|
try:
|
||||||
with open(MOUNTINFO, encoding="utf-8") as fh:
|
with open(MOUNTINFO, encoding="utf-8", errors="surrogateescape") as fh:
|
||||||
points = [OCTAL.sub(_char, line.split()[4]) for line in fh]
|
points = [OCTAL.sub(_char, line.split()[4]) for line in fh]
|
||||||
except (OSError, IndexError):
|
except (OSError, IndexError):
|
||||||
return MEDIUM, "mount table unreadable"
|
return MEDIUM, "mount table unreadable"
|
||||||
|
|||||||
@@ -172,6 +172,35 @@ class TestApplyLow(RiskPlanFixture, unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(self.docker.writes(), [["image", "rm", DANGLING_ID]])
|
self.assertEqual(self.docker.writes(), [["image", "rm", DANGLING_ID]])
|
||||||
|
|
||||||
|
def test_docker_unreadable_after_plan_fails_and_deletes_nothing(self) -> None:
|
||||||
|
def docker_gone() -> None:
|
||||||
|
self.docker.df = "not json"
|
||||||
|
self.docker.calls.clear()
|
||||||
|
|
||||||
|
code, printed = self._after_plan(docker_gone)
|
||||||
|
results = [
|
||||||
|
e["result"]
|
||||||
|
for e in printed["items"]
|
||||||
|
if e["kind"] in ("image", "build-cache", "container")
|
||||||
|
]
|
||||||
|
|
||||||
|
self.assertEqual(code, 1)
|
||||||
|
self.assertTrue(results)
|
||||||
|
for result in results:
|
||||||
|
self.assertTrue(result.startswith("failed: revalidation failed"), result)
|
||||||
|
self.assertEqual(self.docker.writes(), [])
|
||||||
|
|
||||||
|
def test_non_utf8_mount_elsewhere_keeps_the_plan_working(self) -> None:
|
||||||
|
table = os.path.join(self.root, "mountinfo")
|
||||||
|
with open(table, "wb") as fh:
|
||||||
|
fh.write(b"36 35 98:0 / /mnt/\xff rw - ext4 /dev/x rw\n")
|
||||||
|
|
||||||
|
with patch.object(tmp_items, "MOUNTINFO", table):
|
||||||
|
code, printed, _ = self.run_gc(level="low")
|
||||||
|
|
||||||
|
self.assertEqual(code, 0)
|
||||||
|
self.assertEqual(self.risks(printed).get(self.t["old-stopped"]), "low")
|
||||||
|
|
||||||
def test_mount_at_or_below_scratch_is_never_low(self) -> None:
|
def test_mount_at_or_below_scratch_is_never_low(self) -> None:
|
||||||
stopped = self.t["old-stopped"]
|
stopped = self.t["old-stopped"]
|
||||||
table = os.path.join(self.root, "mountinfo")
|
table = os.path.join(self.root, "mountinfo")
|
||||||
|
|||||||
Reference in new issue
Block a user