Skip to content

logSearch, diskUsage, containerScan do unbounded work on the Pi #96

Closed

Description

@TMHSDigital

Summary

Several tools do unbounded work on the Pi:

  • homelab_logSearch reads the full log history of every container.
  • homelab_diskUsage walks / across filesystems.
  • homelab_containerScan scans every image one after another.

On a Pi with months of logs this pegs the CPU and SD card and usually exceeds the exec timeout.

Where

  • mcp-server/src/tools/logSearch.ts:34-35: docker logs "$name" with no --since/--tail, piped to grep for every container
  • mcp-server/src/tools/serviceLogs.ts:9-26: only --tail, no time window
  • mcp-server/src/tools/diskUsage.ts:34: sudo du without -x, default path /
  • mcp-server/src/tools/containerScan.ts:40-41,83-84: Trivy over all unique images, severity fixed to HIGH,CRITICAL, table output

Impact

  • With 13 containers and long-lived logs, logSearch reads hundreds of MB.
  • du without -x descends into /proc, overlay mounts, and network mounts such as Samba targets.
  • Trivy over 13 images takes minutes.
  • All of these run into the 30s exec timeout, and the remote work keeps going after the timeout.

Suggested fix

  • Add an optional since param (for example 10m, 24h, or ISO, validated) to serviceLogs and logSearch, mapped to docker logs --since. Default logSearch to a bounded window such as 24h.
  • Use du -x in diskUsage.
  • In containerScan, default to a single image or a summary mode (--format json with per-image counts), make severity a parameter, and allow --skip-db-update when the DB is fresh.

Acceptance criteria

  • logSearch with no service finishes within the timeout on a typical Pi
  • New params are documented and covered by schema tests

Getting started

  • Relevant files: the files listed above
  • How to run tests: cd mcp-server && npm test

Filed by repo-audit/full-audit at 9cfe5e3. Severity: medium. Effort: S. audit-key: performance|mcp-server/src/tools/logSearch.ts|all-container docker logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions