From 64fa9639079dda96c41a82f0fc3a2ac3d1a80939 Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 9 Sep 2026 08:47:37 -0700 Subject: [PATCH] feat(cri-shim): Improve debug report to collect containerd logs --- README.md | 3 ++ edera-debug-report | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/README.md b/README.md index 151d804..3d8f8f2 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,8 @@ The archive may include: - Network configuration (interfaces, routes, iptables rules) - Edera Protect daemon configuration (`/var/lib/edera/protect/daemon.toml`) - Edera Protect zone list and per-zone logs (`protect-ctl zone list`, `protect-ctl zone logs`) +- containerd/containerd-shim state: shim daemon log (`/tmp/edera-shim-daemon.log`), + containerd config, and a live snapshot of containers/tasks (`ctr`, `crictl`) **Please inspect the ZIP contents yourself** to ensure you are comfortable with the data before sending it to Edera. You can open it with any ZIP tool. @@ -48,6 +50,7 @@ Optional Privacy Flags You may exclude certain data if desired: --no-acpi Skip ACPI tables + --no-containerd Skip containerd/containerd-shim state (shim log, config, container/task listing) --no-dmi Skip DMI/SMBIOS data --no-journal Skip systemd journal logs for the whole system --no-network Skip all network configuration diff --git a/edera-debug-report b/edera-debug-report index bb8b2b5..e8baa9f 100644 --- a/edera-debug-report +++ b/edera-debug-report @@ -38,6 +38,7 @@ class Config: network: bool = True systemctl: bool = True protect_zone_logs: bool = True + containerd: bool = True # ------------------------ env / basics ------------------------ @@ -1012,6 +1013,80 @@ def collect_protect_zone_logs( log.append(f"FAIL({rc}): protect-ctl zone logs {zone}") +def collect_containerd( + log: List[str], + aw: ZipArchiveWriter, + top_name: str, +) -> None: + arc_dir = f"{top_name}/containerd" + + shim_log = Path("/tmp/edera-shim-daemon.log") + if shim_log.exists(): + copy_file(log, aw, shim_log, f"{arc_dir}/edera-shim-daemon.log") + else: + log.append("INFO: /tmp/edera-shim-daemon.log not present; skipping shim log") + + copy_file(log, aw, Path("/etc/containerd/config.toml"), f"{arc_dir}/config.toml") + + containerd_bin = which("containerd") + if containerd_bin: + run_and_write( + log, + aw, + f"{arc_dir}/containerd_version.txt", + [containerd_bin, "--version"], + ) + run_and_write( + log, + aw, + f"{arc_dir}/containerd_config_dump.toml", + [containerd_bin, "config", "dump"], + timeout_s=30.0, + ) + else: + log.append("INFO: containerd not found in PATH; skipping version/config dump") + + ctr_bin = which("ctr") + if ctr_bin: + for ns in ("k8s.io", "default"): + run_and_write( + log, + aw, + f"{arc_dir}/ctr_{ns}_containers.txt", + [ctr_bin, "-n", ns, "containers", "list"], + timeout_s=15.0, + ) + run_and_write( + log, + aw, + f"{arc_dir}/ctr_{ns}_tasks.txt", + [ctr_bin, "-n", ns, "tasks", "list"], + timeout_s=15.0, + ) + else: + log.append( + "INFO: ctr not found in PATH; skipping containerd container/task listing" + ) + + crictl_bin = which("crictl") + if crictl_bin: + run_and_write( + log, aw, f"{arc_dir}/crictl_info.txt", [crictl_bin, "info"], timeout_s=15.0 + ) + run_and_write( + log, aw, f"{arc_dir}/crictl_pods.txt", [crictl_bin, "pods"], timeout_s=15.0 + ) + run_and_write( + log, + aw, + f"{arc_dir}/crictl_ps.txt", + [crictl_bin, "ps", "-a"], + timeout_s=15.0, + ) + else: + log.append("INFO: crictl not found in PATH; skipping CRI listing") + + # ------------------------ high-level collection ------------------------ @@ -1043,6 +1118,11 @@ def collect_all( else: log.append("SKIP: protect zone logs skipped at user request") + if cfg.containerd: + collect_containerd(log, aw, top_name) + else: + log.append("SKIP: containerd information skipped at user request") + if which("journalctl"): use_zstd = bool(which("zstd")) if cfg.journal: @@ -1356,6 +1436,12 @@ def main(argv: Optional[List[str]] = None) -> int: action="store_true", default=False, ) + ap.add_argument( + "--no-containerd", + help="Do not include containerd/containerd-shim state (shim log, config, container/task listing) in the debug report", + action="store_true", + default=False, + ) ap.add_argument( "--name", help="Top-level directory name inside archive (defaults to archive base name).", @@ -1376,6 +1462,7 @@ def main(argv: Optional[List[str]] = None) -> int: network=not args.no_network, systemctl=not args.no_systemd_units, protect_zone_logs=not args.no_protect_zone_logs, + containerd=not args.no_containerd, ) set_environment()