From d71aa732a377b416516c46c953d9e19973818d7e Mon Sep 17 00:00:00 2001 From: Jan Vorcak Date: Sat, 16 Nov 2024 14:13:32 +0100 Subject: [PATCH] Adds support for debug bundle error state --- .../pages/admin/Admin.DebugBundle.tsx | 14 ++++-- .../pages/admin/Admin.DebugBundleProgress.tsx | 44 +++++++++---------- .../pages/overview/ClusterHealthOverview.tsx | 2 +- frontend/src/state/backendApi.ts | 12 +++-- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/pages/admin/Admin.DebugBundle.tsx b/frontend/src/components/pages/admin/Admin.DebugBundle.tsx index 8a10806ba..a5fa082cd 100644 --- a/frontend/src/components/pages/admin/Admin.DebugBundle.tsx +++ b/frontend/src/components/pages/admin/Admin.DebugBundle.tsx @@ -82,9 +82,14 @@ export class AdminDebugBundle extends Component<{}> { return (
- {(api.canDownloadDebugBundle || api.isDebugBundleExpired) && Latest debug bundle:} - {api.isDebugBundleExpired ? Your previous bundle has expired and cannot be downloaded. : } - {api.debugBundleStatuses.length === 0 && No debug bundle available for download.} + + {(api.isDebugBundleSuccess || api.isDebugBundleExpired) && Latest debug bundle:} + {api.isDebugBundleExpired && Your previous bundle has expired and cannot be downloaded.} + {api.isDebugBundleError && This debug bundle was cancelled by the user and is not available for download.} + {api.isDebugBundleSuccess && } + + {api.debugBundleStatuses.length===0 && No debug bundle available for download.} + @@ -97,7 +102,8 @@ export class AdminDebugBundle extends Component<{}> { onSubmit={(data: CreateDebugBundleRequest) => { this.submitInProgress = true; this.createBundleError = undefined; - api.createDebugBundle(data).then(result => { + api.createDebugBundle(data).then(async result => { + await api.refreshDebugBundleStatuses(); appGlobal.history.push(`/admin/debug-bundle/progress/${result.jobId}`); }).catch((err: ErrorResponse) => { this.createBundleError = err; diff --git a/frontend/src/components/pages/admin/Admin.DebugBundleProgress.tsx b/frontend/src/components/pages/admin/Admin.DebugBundleProgress.tsx index 968a48761..76e0d677f 100644 --- a/frontend/src/components/pages/admin/Admin.DebugBundleProgress.tsx +++ b/frontend/src/components/pages/admin/Admin.DebugBundleProgress.tsx @@ -54,31 +54,31 @@ export default class AdminPageDebugBundleProgress extends PageComponent<{}> { Collect environment data that can help debug and diagnose issues with a Redpanda cluster, a broker, or the machine it’s running on. This will bundle the collected data into a ZIP file. - {api.isDebugBundleInProgress && - Generating bundle... - } + + {api.isDebugBundleInProgress && Generating bundle...} + {api.isDebugBundleExpired && Your previous bundle has expired and cannot be downloaded.} + {api.isDebugBundleError && This debug bundle was cancelled by the user and is not available for download.} + {api.isDebugBundleSuccess && + + Debug bundle complete: + + + } + - {api.isDebugBundleExpired && Your previous bundle has expired and cannot be downloaded.} + {!api.isDebugBundleExpired && + {api.debugBundleStatuses && } - {!api.isDebugBundleInProgress && !api.isDebugBundleExpired && - - Debug bundle complete: - {api.canDownloadDebugBundle && - } - + + {api.isDebugBundleInProgress ? :} + } - - {api.debugBundleStatuses && } - - - {api.isDebugBundleInProgress ? :} - ); } diff --git a/frontend/src/components/pages/overview/ClusterHealthOverview.tsx b/frontend/src/components/pages/overview/ClusterHealthOverview.tsx index 78df48e4c..2056a9228 100644 --- a/frontend/src/components/pages/overview/ClusterHealthOverview.tsx +++ b/frontend/src/components/pages/overview/ClusterHealthOverview.tsx @@ -76,7 +76,7 @@ const ClusterHealthOverview = () => { Debug bundle {api.isDebugBundleInProgress && } - {api.isDebugBundleReady && !api.isDebugBundleExpired && } + {api.isDebugBundleSuccess && } {!api.isDebugBundleInProgress && } diff --git a/frontend/src/state/backendApi.ts b/frontend/src/state/backendApi.ts index 02eeffe39..8d242a195 100644 --- a/frontend/src/state/backendApi.ts +++ b/frontend/src/state/backendApi.ts @@ -1619,7 +1619,7 @@ const apiStore = { throw new Error('Debug bundle client is not initialized'); } - client.getDebugBundleStatus({ + await client.getDebugBundleStatus({ }).then(response => { this.debugBundleStatuses = response.brokerStatuses this.hasDebugProcess = response.hasDebugProcess @@ -1634,12 +1634,16 @@ const apiStore = { return api.debugBundleStatuses.length > 0 && !this.isDebugBundleInProgress }, - get canDownloadDebugBundle() { - return this.isDebugBundleReady && this.debugBundleStatuses.filter(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.SUCCESS).length > 0 + get isDebugBundleSuccess() { + return this.isDebugBundleReady && this.debugBundleStatuses.some(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.SUCCESS); + }, + + get isDebugBundleError() { + return this.isDebugBundleReady && this.debugBundleStatuses.some(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.ERROR); }, get isDebugBundleExpired() { - return this.isDebugBundleReady && this.debugBundleStatuses.filter(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.EXPIRED).length > 0 + return this.isDebugBundleReady && this.debugBundleStatuses.some(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.EXPIRED); }, get isDebugBundleInProgress() {