feat(ui): download a task attempt's log, and stop blaming a setting for it
The attempt-log panel offered no way to get a log out of the dashboard, and its failure copy asserted that task logging was not enabled for the run. The first is the feature: the panel now links to the download route for the attempt it is showing, so the browser owns the filename the server sets and streams the body to disk rather than the client holding a whole log in memory. The second is the honesty fix. "No log recorded for this attempt" is a fact about the attempt; "this dashboard cannot read task logs" is a fact about the deployment, and only the second is worth sending an operator to a setting for. The panel renders them differently off the response's found/disabled markers. Rebuilds ui/dist, which is a committed asset.
This commit is contained in:
1 parent
cf7cc9d891
commit
3cb3cf7e62
8 files changed
+137
-23
No files matched your search
@@ -112,6 +112,11 @@ export const api = {
|
||||
configReset: (key) => request("/api/config/reset", { method: "POST", body: { key } }),
|
||||
logs: (params) => request("/api/logs" + qs(params)),
|
||||
taskLogs: (id, params) => request(`/api/tasks/${id}/logs` + qs(params)),
|
||||
// A download is a navigation, not a fetch: the browser must own the
|
||||
// Content-Disposition filename and stream the body to disk rather than hold
|
||||
// a whole log in memory. The URL builder is the client-side contract, and
|
||||
// base/log-row's sibling module keeps it beside the panel that uses it.
|
||||
taskLogDownloadURL: (id, attempt) => `/api/tasks/${id}/logs/download` + (attempt == null ? "" : `?attempt=${attempt}`),
|
||||
captures: (limit) => request("/api/captures" + qs({ limit })),
|
||||
mappings: () => request("/api/mappings"),
|
||||
mappingCreate: (mapping) => request("/api/mappings", { method: "POST", body: mapping }),
|
||||
|
||||
@@ -10,7 +10,14 @@ function LogRowNode({ entry }) {
|
||||
return <div ref={ref} style={{ display: 'contents' }} />;
|
||||
}
|
||||
|
||||
export function TaskLogPanel({ state, onRetry }) {
|
||||
// Task-log download URL. The attempt is named explicitly so a download matches
|
||||
// the attempt the panel is showing rather than whatever is current by the time
|
||||
// the operator clicks.
|
||||
export function taskLogDownloadURL(id, attempt) {
|
||||
return `/api/tasks/${id}/logs/download` + (attempt == null ? "" : `?attempt=${attempt}`);
|
||||
}
|
||||
|
||||
export function TaskLogPanel({ state, onRetry, taskId }) {
|
||||
if (state === undefined) {
|
||||
return <div className="task-log-loading">Loading attempt log…</div>;
|
||||
}
|
||||
@@ -22,28 +29,54 @@ export function TaskLogPanel({ state, onRetry }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// A reader exists in this process but the attempt has no log file. That is a
|
||||
// fact about the attempt, and saying "logging was not enabled" here (which
|
||||
// this panel used to do) told the operator to go and change a setting that
|
||||
// was already correct.
|
||||
if (state.found === false && !state.disabled) {
|
||||
return (
|
||||
<div className="empty">
|
||||
<div className="empty-title">No log recorded for this attempt</div>
|
||||
<div>This attempt produced no output, or it has not started writing yet.</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// This process cannot read task logs at all. That IS about the deployment,
|
||||
// and it is the only case where the panel may say so.
|
||||
if (state.disabled) {
|
||||
return (
|
||||
<div className="empty">
|
||||
<div className="empty-title">No persisted log for this attempt</div>
|
||||
<div>Task logging is optional and was not enabled for this run.</div>
|
||||
<div>This dashboard cannot read task logs. The service that owns the log files is not reporting a log reader.</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const entries = state.entries || [];
|
||||
const download = taskId != null ? taskLogDownloadURL(taskId, state.attempt) : null;
|
||||
const footer = download ? (
|
||||
<a className="btn btn-small task-log-download" href={download} download>Download log</a>
|
||||
) : null;
|
||||
|
||||
if (!entries.length) {
|
||||
return (
|
||||
<div className="empty">
|
||||
<div className="empty-title">Nothing recorded</div>
|
||||
<div>This attempt's log file has no entries matching the current filter.</div>
|
||||
{footer}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="log-list task-log-list">
|
||||
{entries.map((entry, i) => (
|
||||
<LogRowNode key={i} entry={entry} />
|
||||
))}
|
||||
</div>
|
||||
<>
|
||||
<div className="log-list task-log-list">
|
||||
{entries.map((entry, i) => (
|
||||
<LogRowNode key={i} entry={entry} />
|
||||
))}
|
||||
</div>
|
||||
{footer}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -359,7 +359,7 @@ function TasksApp({ query }) {
|
||||
</button>
|
||||
</div>
|
||||
{logsExpandedForTask && (
|
||||
<TaskLogPanel state={logCache.get(t.id)} onRetry={() => loadTaskLogs(t.id)} />
|
||||
<TaskLogPanel state={logCache.get(t.id)} taskId={t.id} onRetry={() => loadTaskLogs(t.id)} />
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
Reference in new issue
Block a user