Catalog: collect support diagnostics from admin Settings - #5168
Catalog: collect support diagnostics from admin Settings#5168sir-sigurd wants to merge 4 commits into
Conversation
Adds a Support Diagnostics section to the admin Settings page: one button that runs the stack's diagnostics collector through the registry and downloads the bundle it returns, so an admin with no AWS access can attach diagnostics to a support request. No capability probe exists, so the section renders unconditionally and reports whatever the endpoint says. Severity follows the status rather than always being red: a stack whose template predates the collector (503) and a collection already in flight (409) are not malfunctions. The filename comes from Content-Disposition, which carries the collection's run id, with a fallback for deployments whose registry does not expose that header to a cross-origin fetch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5168 +/- ##
==========================================
+ Coverage 48.22% 48.28% +0.05%
==========================================
Files 827 828 +1
Lines 34120 34165 +45
Branches 5837 5848 +11
==========================================
+ Hits 16455 16497 +42
- Misses 15781 15784 +3
Partials 1884 1884
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| endpoint: '/admin/support-diagnostics', | ||
| method: 'POST', | ||
| // The response is an archive, and there is no request body to encode. | ||
| json: false, | ||
| }) |
There was a problem hiding this comment.
Navigation does not cancel collection
When an administrator leaves Settings before the request completes, the application-level API saga continues the POST and the success path still calls saveAs, causing the archive to download on another page despite the UI stating that navigation cancels collection.
Knowledge Base Used: Catalog Frontend (catalog/app)
The API request runs in an app-root redux saga with no AbortController, so leaving Settings does not cancel it -- the archive still downloads. Suppressing that would discard a finished bundle with no way to fetch it again, so the copy changes instead: closing the tab is what loses the download. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Confirmed and fixed in d234547 — thanks, this was a real defect. Checked the mechanism rather than the symptom: I fixed the copy rather than the behaviour. Making navigation actually cancel would mean discarding a bundle the collection already produced, and there is deliberately no fetch-by-run endpoint to get it back — a lost download costs a fresh collection against the cluster being diagnosed, which is the thing worth avoiding. So navigating away is fine and the download still arrives; the message now says closing the tab is what loses it. |
|
@greptileai please re-review — the copy fix in d234547 landed after your pass. |
There was a problem hiding this comment.
Pull request overview
Adds an admin-facing Support Diagnostics section to Catalog’s Admin Settings, enabling admins to trigger a registry diagnostics collection and download the resulting archive directly in the browser for support/debug workflows.
Changes:
- Adds a new Support Diagnostics UI on the Admin Settings page that POSTs to
/admin/support-diagnosticsand downloads the returned ZIP. - Extracts the download filename from
Content-Dispositionwith a fallback name, and surfaces status-specific alert severities. - Adds unit tests for download + error cases and documents the feature in the catalog changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| catalog/app/containers/Admin/Settings/SupportDiagnostics.tsx | New UI component that triggers diagnostics collection and downloads the archive. |
| catalog/app/containers/Admin/Settings/SupportDiagnostics.spec.tsx | Unit tests for successful download, fallback naming, and error severity handling. |
| catalog/app/containers/Admin/Settings/Settings.tsx | Wires the new Support Diagnostics section into the Admin Settings page layout. |
| catalog/CHANGELOG.md | Changelog entry announcing the new Support Diagnostics workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| it('surfaces an unexpected failure as an error', async () => { | ||
| mocks.req.mockRejectedValue( | ||
| new mocks.HTTPError(502, 'The diagnostics collector failed.'), | ||
| ) | ||
| const { container, getByText } = renderComponent() | ||
|
|
||
| fireEvent.click(getByText('Collect diagnostics')) | ||
|
|
||
| await waitFor(() => expect(getByText(/collector failed/)).toBeTruthy()) | ||
| expect(container.querySelector('.MuiAlert-standardError')).not.toBeNull() | ||
| }) | ||
| }) |
| const collect = React.useCallback(async () => { | ||
| setCollecting(true) | ||
| setFailure(null) | ||
| try { | ||
| const response: Response = await req({ | ||
| endpoint: '/admin/support-diagnostics', | ||
| method: 'POST', | ||
| // The response is an archive, and there is no request body to encode. | ||
| json: false, | ||
| }) | ||
| saveAs(await response.blob(), getFilename(response)) | ||
| } catch (e) { | ||
| if (e instanceof APIConnector.HTTPError) { | ||
| setFailure({ | ||
| severity: SEVERITIES[e.status] || 'error', | ||
| message: e.json?.message || e.message, | ||
| }) | ||
| } else { | ||
| Sentry.captureException(e) | ||
| setFailure({ severity: 'error', message: `Could not collect diagnostics: ${e}` }) | ||
| } | ||
| } finally { | ||
| setCollecting(false) | ||
| } | ||
| }, [req]) |
The registry answers 503 when a stack has no collector. An ALB, or the nginx sidecar, answers 503 when the registry is merely cycling -- with an HTML body. Keying severity on the status alone reported the second as calmly as the first, which is the reading that sends nobody to look; and the body was rendered verbatim, so an error page landed in the alert box. Severity now comes from the response's error_code. Anything without one -- every error raised before the endpoint is reached, including the 404 from a registry that predates it -- gets the red alert and a generic message, and the raw body never reaches the DOM. Also stop revoking the blob URL on the line after click(): clicking only queues the download, and revoking before the browser has read the blob cancels it in some of them, which the UI would have reported as success. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Description
Adds a Support Diagnostics section to the admin Settings page. One button runs the stack's diagnostics collector and downloads the bundle it produces — search-cluster and infrastructure state for debugging a deployment — so an admin with no AWS access can attach diagnostics to a support request instead of working through a multi-step cloud procedure.
The button POSTs to an admin-only registry endpoint, which invokes the collector and streams the archive straight back; the catalog turns the response into a blob and saves it. Nothing is presigned, and the bundle goes to the admin's browser rather than anywhere else — the
manifest.jsoninside it states what was collected, so the admin reviews before sending anything to support.Three decisions worth surfacing:
Content-Disposition, which carries the collection's run id — what support asks for when several bundles are in flight. There is a generic fallback for any deployment whose registry does not expose that header to a cross-origin fetch.The endpoint and the collector behind it ship in paired changes outside this repo. On a stack without them the section is inert and says so.
End-user documentation is deliberately not here: it publishes from
master, so it lands with the release that ships the whole flow rather than describing a feature nobody has yet.TODO
docs/imgs/admin-settings.png) is refreshed with the deferred markdown rather than twiceGreptile Summary
Adds an admin Settings control that requests a support-diagnostics archive from the registry and downloads it in the browser.
Confidence Score: 4/5
The PR is not yet safe to merge because an in-flight diagnostics request can still trigger an archive download after the administrator leaves Settings.
The collection promise remains active after SupportDiagnostics unmounts, and its successful completion unconditionally invokes the browser download side effect.
Files Needing Attention: catalog/app/containers/Admin/Settings/SupportDiagnostics.tsx
Important Files Changed
Sequence Diagram
Reviews (2): Last reviewed commit: "Say what navigating away actually does" | Re-trigger Greptile
Context used: