Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Make Docker troubleshooting account-specific and bounded

pulse-triage[bot]14c489921e4f
diff --git a/docs/UNIFIED_AGENT.md b/docs/UNIFIED_AGENT.md
index 4ef1f23ae1..86ee75dcc3 100644
--- a/docs/UNIFIED_AGENT.md
+++ b/docs/UNIFIED_AGENT.md
@@ -968,11 +968,74 @@ keep the bounded, redacted error for diagnosis; do not delete tokens, re-enrol
blindly or remove the original host's record.
### Permission Denied (Docker)
-Ensure the agent can access the Docker socket:
+
+Check the account that actually runs the agent, not your interactive `$USER`.
+For a systemd installation, these read-only checks show the service account and
+the default socket's ownership; they do not print service environments or tokens:
+
+```bash
+systemctl show pulse-agent.service --property=User --property=Group --property=SupplementaryGroups
+ls -l /var/run/docker.sock
+```
+
+A blank systemd `User` means the service runs as root. Adding your login user to
+the `docker` group does not change a different agent service account. Access to
+a rootful Docker socket, including membership of its `docker` group, is
+root-equivalent; do not make the socket world-writable or expose the daemon over
+unauthenticated TCP to clear an error.
+
+Use the [supported collector profile](AGENT_SECURITY.md#safe-profile-support-and-qualification-matrix)
+for that service account. The least-privilege profile intentionally limits a
+rootful runtime to typed-helper summary inventory; full collection needs a
+collector-owned rootless socket or an explicitly chosen full-telemetry profile.
+Keep that distinction when diagnosing missing statistics, Swarm data or actions:
+summary-only collection is not a socket-permission defect.
+
+### Docker visible in one LXC but missing in another
+
+Proxmox-side discovery uses the **owning node's** connected command-capable
+agent, not the agent on whichever node hosts Pulse. Check **Discover Docker in
+LXC guests** in Settings → System → General and any configured
+`PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` allowlist. Collection skips stopped
+guests and guests already linked to an online guest-local agent. In the latter
+case, check that guest agent's Docker monitoring instead.
+
+The host-side path requires the guest's `docker` executable and
+`/var/run/docker.sock` in the root `pct exec` context. A working Docker CLI in a
+user's login session does not prove that this context can reach the daemon;
+rootless or non-default sockets may need guest-local agent monitoring. Different
+Debian or Docker versions alone do not establish the cause.
+
+If the Proxmox node and guest are healthy, run this **once** on the owning node
+as root, replacing `123` with the affected LXC's VMID:
+
```bash
-sudo usermod -aG docker $USER
+timeout --kill-after=2s 15s pct exec 123 -- sh -c '
+ command -v docker || exit
+ if test -S /var/run/docker.sock; then
+ printf "default_socket=present\n"
+ else
+ printf "default_socket=absent\n"
+ fi
+ docker version --format "server={{.Server.Version}}" || exit
+ docker ps -a --format "{{.State}}"
+'
```
+This checks guest entry, the default socket, daemon access and container listing
+without printing container names, images, environment values or credentials.
+`default_socket=absent` explains why the host-side probe skips that guest even if
+another Docker context works. A CLI/daemon error is different from a successful
+empty list. If these checks pass but Pulse still omits the guest, keep the
+bounded error from the existing collection logs and whether the working and
+missing guests share the same PVE node; do not enable debug logging for the whole
+server just to collect this distinction.
+
+Exit `124` means the check timed out; stop rather than loop or restart the host.
+Review output before posting and redact any private endpoint in an error. Do not
+change LXC privilege, `keyctl`, socket permissions or Docker versions merely to
+test a guess.
+
### Check Status
```bash
# Linux
@@ -1004,10 +1067,10 @@ If your Docker Swarm cluster isn't being detected:
# Should show "Swarm: active"
```
-4. **Check socket permissions**: The agent needs access to the Docker socket:
- ```bash
- ls -la /var/run/docker.sock
- ```
+4. **Check the service account and collector profile**: follow
+ [Permission Denied (Docker)](#permission-denied-docker). A rootful
+ typed-helper summary does not include Swarm inventory; granting broader
+ socket access is a security decision, not a routine permission repair.
5. **Enable debug logging**: For more detail:
```bash
diff --git a/frontend-modern/public/docs/UNIFIED_AGENT.md b/frontend-modern/public/docs/UNIFIED_AGENT.md
index 4ef1f23ae1..86ee75dcc3 100644
--- a/frontend-modern/public/docs/UNIFIED_AGENT.md
+++ b/frontend-modern/public/docs/UNIFIED_AGENT.md
@@ -968,11 +968,74 @@ keep the bounded, redacted error for diagnosis; do not delete tokens, re-enrol
blindly or remove the original host's record.
### Permission Denied (Docker)
-Ensure the agent can access the Docker socket:
+
+Check the account that actually runs the agent, not your interactive `$USER`.
+For a systemd installation, these read-only checks show the service account and
+the default socket's ownership; they do not print service environments or tokens:
+
+```bash
+systemctl show pulse-agent.service --property=User --property=Group --property=SupplementaryGroups
+ls -l /var/run/docker.sock
+```
+
+A blank systemd `User` means the service runs as root. Adding your login user to
+the `docker` group does not change a different agent service account. Access to
+a rootful Docker socket, including membership of its `docker` group, is
+root-equivalent; do not make the socket world-writable or expose the daemon over
+unauthenticated TCP to clear an error.
+
+Use the [supported collector profile](AGENT_SECURITY.md#safe-profile-support-and-qualification-matrix)
+for that service account. The least-privilege profile intentionally limits a
+rootful runtime to typed-helper summary inventory; full collection needs a
+collector-owned rootless socket or an explicitly chosen full-telemetry profile.
+Keep that distinction when diagnosing missing statistics, Swarm data or actions:
+summary-only collection is not a socket-permission defect.
+
+### Docker visible in one LXC but missing in another
+
+Proxmox-side discovery uses the **owning node's** connected command-capable
+agent, not the agent on whichever node hosts Pulse. Check **Discover Docker in
+LXC guests** in Settings → System → General and any configured
+`PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` allowlist. Collection skips stopped
+guests and guests already linked to an online guest-local agent. In the latter
+case, check that guest agent's Docker monitoring instead.
+
+The host-side path requires the guest's `docker` executable and
+`/var/run/docker.sock` in the root `pct exec` context. A working Docker CLI in a
+user's login session does not prove that this context can reach the daemon;
+rootless or non-default sockets may need guest-local agent monitoring. Different
+Debian or Docker versions alone do not establish the cause.
+
+If the Proxmox node and guest are healthy, run this **once** on the owning node
+as root, replacing `123` with the affected LXC's VMID:
+
```bash
-sudo usermod -aG docker $USER
+timeout --kill-after=2s 15s pct exec 123 -- sh -c '
+ command -v docker || exit
+ if test -S /var/run/docker.sock; then
+ printf "default_socket=present\n"
+ else
+ printf "default_socket=absent\n"
+ fi
+ docker version --format "server={{.Server.Version}}" || exit
+ docker ps -a --format "{{.State}}"
+'
```
+This checks guest entry, the default socket, daemon access and container listing
+without printing container names, images, environment values or credentials.
+`default_socket=absent` explains why the host-side probe skips that guest even if
+another Docker context works. A CLI/daemon error is different from a successful
+empty list. If these checks pass but Pulse still omits the guest, keep the
+bounded error from the existing collection logs and whether the working and
+missing guests share the same PVE node; do not enable debug logging for the whole
+server just to collect this distinction.
+
+Exit `124` means the check timed out; stop rather than loop or restart the host.
+Review output before posting and redact any private endpoint in an error. Do not
+change LXC privilege, `keyctl`, socket permissions or Docker versions merely to
+test a guess.
+
### Check Status
```bash
# Linux
@@ -1004,10 +1067,10 @@ If your Docker Swarm cluster isn't being detected:
# Should show "Swarm: active"
```
-4. **Check socket permissions**: The agent needs access to the Docker socket:
- ```bash
- ls -la /var/run/docker.sock
- ```
+4. **Check the service account and collector profile**: follow
+ [Permission Denied (Docker)](#permission-denied-docker). A rootful
+ typed-helper summary does not include Swarm inventory; granting broader
+ socket access is a security decision, not a routine permission repair.
5. **Enable debug logging**: For more detail:
```bash
diff --git a/scripts/tests/test_docker_troubleshooting_docs.py b/scripts/tests/test_docker_troubleshooting_docs.py
new file mode 100644
index 0000000000..3041dd1470
--- /dev/null
+++ b/scripts/tests/test_docker_troubleshooting_docs.py
@@ -0,0 +1,186 @@
+#!/usr/bin/env python3
+"""Execute the shipped Docker diagnosis against bounded synthetic tools.
+
+This proves command syntax, disclosure and failure handling, not native PVE or
+Docker compatibility. No real service, socket or container is touched.
+"""
+
+import json
+import os
+from pathlib import Path
+import re
+import subprocess
+import tempfile
+import unittest
+
+
+ROOT = Path(__file__).resolve().parents[2]
+SECRET = "synthetic-docker-docs-secret"
+
+
+def section(heading):
+ guide = (ROOT / "docs/UNIFIED_AGENT.md").read_text()
+ return guide.split("### " + heading + "\n", 1)[1].split("\n### ", 1)[0]
+
+
+def command(heading):
+ blocks = re.findall(r"```bash\n(.*?)```", section(heading), re.DOTALL)
+ if len(blocks) != 1:
+ raise AssertionError("expected one diagnostic recipe")
+ return blocks[0]
+
+
+PCT = r'''#!/usr/bin/python3
+import json, os, sys
+from pathlib import Path
+args = sys.argv[1:]
+assert args[:4] == ["exec", "123", "--", "sh"]
+assert len(args) == 6 and args[4] == "-c"
+Path(os.environ["PCT_RECEIPT"]).write_text(json.dumps(args))
+mode = os.environ["PCT_MODE"]
+if mode == "locked":
+ print("pct: guest is locked", file=sys.stderr)
+ sys.exit(255)
+if mode == "hang":
+ import time
+ time.sleep(25)
+env = dict(os.environ, PATH=os.environ["GUEST_BIN"])
+# Model only the socket-presence builtin. The documented sh program and its
+# Docker invocations otherwise execute unchanged, with no host socket access.
+probe = """test() {
+ [ "$#" = 2 ] && [ "$1" = -S ] && [ "$2" = /var/run/docker.sock ] || exit 91
+ [ "$SOCKET_STATE" = present ]
+}
+"""
+os.execve("/bin/sh", ["sh", "-c", probe + args[5]], env)
+'''
+
+DOCKER = r'''#!/usr/bin/python3
+import json, os, sys
+from pathlib import Path
+args = sys.argv[1:]
+with Path(os.environ["DOCKER_RECEIPT"]).open("a") as output:
+ output.write(json.dumps(args) + "\n")
+if args == ["version", "--format", "server={{.Server.Version}}"]:
+ if os.environ["DOCKER_MODE"] == "daemon-error":
+ print("Cannot connect to the Docker daemon", file=sys.stderr)
+ sys.exit(1)
+ print("server=29.8.2")
+elif args == ["ps", "-a", "--format", "{{.State}}"]:
+ if os.environ["DOCKER_MODE"] == "list-error":
+ print("container listing failed", file=sys.stderr)
+ sys.exit(1)
+ if os.environ["DOCKER_MODE"] != "empty":
+ print("running\nexited")
+else:
+ raise AssertionError("unexpected diagnostic operation")
+'''
+
+
+class DockerTroubleshootingDocsTest(unittest.TestCase):
+ def test_service_account_guidance_does_not_grant_socket_access(self):
+ text = section("Permission Denied (Docker)")
+ self.assertNotIn("usermod", text)
+ self.assertNotRegex(text, r"chmod\s+(?:666|777)|--property=Environment")
+ for required in ("root-equivalent", "interactive `$USER`", "summary-only",
+ "collector-owned rootless socket", "unauthenticated TCP"):
+ self.assertIn(required, text)
+ recipe = command("Permission Denied (Docker)")
+ self.assertEqual(recipe.strip().splitlines(), [
+ "systemctl show pulse-agent.service --property=User --property=Group --property=SupplementaryGroups",
+ "ls -l /var/run/docker.sock",
+ ])
+
+ def test_guest_guidance_preserves_opt_in_and_avoids_speculative_mutations(self):
+ text = section("Docker visible in one LXC but missing in another")
+ for required in ("owning node", "command-capable", "allowlist", "online guest-local agent",
+ "root `pct exec` context", "run this **once**", "Exit `124`",
+ "do not enable debug", "Do not\nchange LXC privilege, `keyctl`"):
+ self.assertIn(required, text)
+ recipe = command("Docker visible in one LXC but missing in another")
+ self.assertNotRegex(recipe, r"(?i)inspect|printenv|usermod|chmod|systemctl|restart|--token|https?://")
+ self.assertIn("timeout --kill-after=2s 15s", recipe)
+ self.assertNotIn("2>/dev/null", recipe)
+ source = (ROOT / "internal/monitoring/docker_detection.go").read_text()
+ for operation in ("test -S /var/run/docker.sock", "docker version --format", "docker ps -a"):
+ self.assertIn(operation, recipe)
+ self.assertIn(operation, source)
+
+ def run_guest(self, *, socket="present", docker="ok", pct="ok", cli=True):
+ with tempfile.TemporaryDirectory() as temporary:
+ root = Path(temporary)
+ host_bin = root / "host"
+ guest_bin = root / "guest"
+ host_bin.mkdir()
+ guest_bin.mkdir()
+ (host_bin / "pct").write_text(PCT)
+ (host_bin / "pct").chmod(0o700)
+ if cli:
+ (guest_bin / "docker").write_text(DOCKER)
+ (guest_bin / "docker").chmod(0o700)
+ env = dict(os.environ, PATH=f"{host_bin}:{os.environ['PATH']}",
+ GUEST_BIN=str(guest_bin), SOCKET_STATE=socket,
+ DOCKER_MODE=docker, PCT_MODE=pct,
+ PCT_RECEIPT=str(root / "pct.json"),
+ DOCKER_RECEIPT=str(root / "docker.jsonl"),
+ SYNTHETIC_SECRET=SECRET)
+ result = subprocess.run(["bash", "-c", command("Docker visible in one LXC but missing in another")],
+ env=env, capture_output=True, text=True, timeout=22)
+ self.assertNotIn(SECRET, result.stdout + result.stderr)
+ self.assertEqual(json.loads((root / "pct.json").read_text())[:4], ["exec", "123", "--", "sh"])
+ path = root / "docker.jsonl"
+ operations = [json.loads(line) for line in path.read_text().splitlines()] if path.exists() else []
+ return result, operations
+
+ def test_working_guest_reports_only_socket_daemon_and_states(self):
+ result, operations = self.run_guest()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertRegex(result.stdout, r"/guest/docker\ndefault_socket=present\nserver=29\.8\.2\nrunning\nexited\n$")
+ self.assertEqual(len(operations), 2)
+
+ def test_nondefault_context_does_not_hide_absent_default_socket(self):
+ result, _ = self.run_guest(socket="absent")
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertIn("default_socket=absent\nserver=29.8.2", result.stdout)
+
+ def test_empty_inventory_is_success_not_daemon_failure(self):
+ result, operations = self.run_guest(docker="empty")
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertTrue(result.stdout.endswith("server=29.8.2\n"))
+ self.assertEqual(len(operations), 2)
+
+ def test_daemon_failure_is_visible_and_stops_listing(self):
+ result, operations = self.run_guest(docker="daemon-error")
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("Cannot connect", result.stderr)
+ self.assertEqual(len(operations), 1)
+
+ def test_listing_failure_is_visible_and_nonzero(self):
+ result, _ = self.run_guest(docker="list-error")
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("container listing failed", result.stderr)
+
+ def test_missing_cli_stops_before_socket_or_daemon_claim(self):
+ result, operations = self.run_guest(cli=False)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertNotIn("default_socket=", result.stdout)
+ self.assertEqual(operations, [])
+
+ def test_pct_failure_is_not_reported_as_empty_inventory(self):
+ result, operations = self.run_guest(pct="locked")
+ self.assertEqual(result.returncode, 255)
+ self.assertIn("guest is locked", result.stderr)
+ self.assertEqual(operations, [])
+
+ def test_hung_guest_is_stopped_by_actual_timeout(self):
+ result, operations = self.run_guest(pct="hang")
+ self.assertEqual(result.returncode, 124)
+ self.assertEqual(operations, [])
+
+ def test_shipped_guide_matches_the_tested_source(self):
+ self.assertEqual((ROOT / "docs/UNIFIED_AGENT.md").read_bytes(),
+ (ROOT / "frontend-modern/public/docs/UNIFIED_AGENT.md").read_bytes())
+
+
+if __name__ == "__main__":
+ unittest.main()