Commit 8edae66
feat(logs): derive default log sources from agent capabilities (#116)
* feat(logs): derive default log sources from agent capabilities (#112)
APILogSourcesHandler returned a hardcoded [haproxy, system] pair
whenever no explicit per-box settings existed. On a box whose agent
has no `logs` (journalctl) or `access-log` gear — e.g. mjolnir's
distroless container agent — the Logs page would still load both
defaults and then trip every fetch against the agent, which has
nothing to serve. Combined with the plain-text 5xx error responses
(see #112 / sibling PR #114) this produced the user-visible
"Error loading logs: Unexpected token 'F'" toast.
Drive the no-settings default off the agent's probe table:
* `haproxy` is offered when either access-log OR logs gear is
available (access-log streams directly from /var/log/haproxy; the
logs gear can serve it via journalctl/file too).
* `system` is offered only when the `logs` gear is available (it
needs journalctl/tail).
* If the agent has neither, return an empty source list — the JS
renders an empty dropdown and skips the immediate fetch instead
of 5xx-storming.
* If capabilities aren't reachable at all (agent down, older agent
that pre-dates probing) fall back to the legacy pair so existing
deployments still work through transient outages.
Phase 2 slice of #112.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(logs): address Copilot review on capability presence vs availability (#112)
Copilot pointed out that defaultLogSourcesForBox conflated two
distinct cases:
1. The agent doesn't surface a gear name at all (older agent that
pre-dates the gear).
2. The agent reports the gear as unavailable.
Both used IsAvailable() and collapsed into "return empty list",
which violates the function comment's fail-open promise: a
forward-compatibility gap would silently strip the source list.
Use caps.Has() to distinguish presence from availability:
- If the agent surfaces neither access-log nor logs by name → fail
open to the legacy [haproxy, system] pair (older-agent path).
- If the agent surfaces at least one and reports both unavailable →
return empty (the only case where the JS shows an empty dropdown).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 852cb98 commit 8edae66
1 file changed
Lines changed: 77 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
| |||
64 | 79 | | |
65 | 80 | | |
66 | 81 | | |
67 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
68 | 85 | | |
69 | 86 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 87 | + | |
| 88 | + | |
75 | 89 | | |
76 | 90 | | |
77 | 91 | | |
| |||
92 | 106 | | |
93 | 107 | | |
94 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
0 commit comments