Skip to content

Commit

Permalink
Merge pull request #1520 from redpanda-data/feature/debug-bundle-expi…
Browse files Browse the repository at this point in the history
…ration

Adds support for debug bundle expiration
  • Loading branch information
jvorcak authored Nov 19, 2024
2 parents d061507 + a390ef8 commit 8a65264
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 36 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/debugBundle/DebugBundleLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { DebugBundleStatus, GetDebugBundleStatusResponse_DebugBundleBrokerStatus } from '../../protogen/redpanda/api/console/v1alpha1/debug_bundle_pb';
import { config } from '../../config';
import { api } from '../../state/backendApi';
import { Box, Text, IconButton, Link } from '@redpanda-data/ui';
import { Box, Text, IconButton, Link, Flex, Tooltip } from '@redpanda-data/ui';
import { MdDeleteOutline } from 'react-icons/md';

const DebugBundleLink = ({ statuses, showDeleteButton = false, showDatetime = true }: { statuses: GetDebugBundleStatusResponse_DebugBundleBrokerStatus[], showDeleteButton?: boolean, showDatetime?: boolean }) => {
Expand All @@ -19,7 +19,7 @@ const DebugBundleLink = ({ statuses, showDeleteButton = false, showDatetime = tr

return (
<Box>
<Box>
<Flex alignItems="center" gap={1}>
<Link
role="button"
onClick={() => {
Expand Down Expand Up @@ -50,15 +50,15 @@ const DebugBundleLink = ({ statuses, showDeleteButton = false, showDatetime = tr
>
{downloadFilename}
</Link>
{showDeleteButton && <IconButton
{showDeleteButton && <Tooltip placement="top" label="Delete bundle" hasArrow><IconButton
variant="ghost"
icon={<MdDeleteOutline/>}
aria-label="Delete file"
onClick={() => {
void api.deleteDebugBundleFile();
}}
/>}
</Box>
/></Tooltip>}
</Flex>
{showDatetime && <Text>
Generated {statusWithFilename.createdAt?.toDate().toLocaleString()}
</Text>}
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/pages/admin/Admin.DebugBundle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ export class AdminDebugBundle extends Component<{}> {
return (
<Box>
<Header />
{api.canDownloadDebugBundle && <Text mt={4} fontWeight="bold">Latest debug bundle:</Text>}
<DebugBundleLink statuses={api.debugBundleStatuses} showDeleteButton />
{api.debugBundleStatuses.length === 0 && <Text>No debug bundle available for download.</Text>}
<Box mt={4}>
{(api.canDownloadDebugBundle || api.isDebugBundleExpired) && <Text fontWeight="bold">Latest debug bundle:</Text>}
{api.isDebugBundleExpired && <Text>Your previous bundle has expired and cannot be downloaded.</Text>}
{api.isDebugBundleError && <Text fontWeight="bold">Your debug bundle was not generated. Try again.</Text>}
{api.canDownloadDebugBundle && <DebugBundleLink statuses={api.debugBundleStatuses} showDeleteButton />}

{api.debugBundleStatuses.length === 0 && <Text>No debug bundle available for download.</Text>}
</Box>



Expand All @@ -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;
Expand Down Expand Up @@ -503,7 +509,7 @@ const NewDebugBundleForm: FC<{ onSubmit: (data: CreateDebugBundleRequest) => voi
</Alert>}

<Flex gap={2} mt={4}>
{debugBundleExists ? <ConfirmModal trigger={advancedForm ? 'Generate':'Generate default'} heading="Generate new debug bundle" onConfirm={() => {
{(debugBundleExists && !api.isDebugBundleExpired && !api.isDebugBundleError) ? <ConfirmModal trigger={advancedForm ? 'Generate':'Generate default'} heading="Generate new debug bundle" onConfirm={() => {
generateNewDebugBundle();
}}>
You have an existing debug bundle; generating a new one will delete the previous one. Are you sure?
Expand Down
44 changes: 23 additions & 21 deletions frontend/src/components/pages/admin/Admin.DebugBundleProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,31 @@ export default class AdminPageDebugBundleProgress extends PageComponent<{}> {
<Box>
<Text>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.</Text>

{api.isDebugBundleInProgress && <Box mt={6}>
<Text>Generating bundle...</Text>
</Box>}

{!api.isDebugBundleInProgress && <Box>
<Flex gap={2} my={2}>
<Text fontWeight="bold">Debug bundle complete:</Text>
{api.canDownloadDebugBundle &&
<DebugBundleLink statuses={api.debugBundleStatuses} showDatetime={false} />}
</Flex>
</Box>}
<Box mt={4}>
{api.isDebugBundleInProgress && <Text>Generating bundle...</Text>}
{api.isDebugBundleExpired && <Text fontWeight="bold">Your previous bundle has expired and cannot be downloaded.</Text>}
{api.isDebugBundleError && <Text>Your debug bundle was not generated. Try again.</Text>}
{api.canDownloadDebugBundle && <Box>
<Flex gap={2}>
<Text fontWeight="bold">Debug bundle complete:</Text>
<DebugBundleLink statuses={api.debugBundleStatuses} showDatetime={false}/>
</Flex>
</Box>}
</Box>

{api.debugBundleStatuses && <DebugBundleOverview statuses={api.debugBundleStatuses} />}
{!api.isDebugBundleExpired && <Box mt={2}>
{api.debugBundleStatuses && <DebugBundleOverview statuses={api.debugBundleStatuses} />}

<Box my={2}>
{api.isDebugBundleInProgress ? <Button variant="outline" onClick={() => {
api.debugBundleStatuses.forEach(status => {
if (status.value.case==='bundleStatus') {
void api.cancelDebugBundleProcess({jobId: status.value.value.jobId});
}
});
}}>Stop</Button>:<Button variant="outline" as={ReactRouterLink} to="/admin">Done</Button>}
</Box>
<Box my={2}>
{api.isDebugBundleInProgress ? <Button variant="outline" onClick={() => {
api.debugBundleStatuses.forEach(status => {
if (status.value.case==='bundleStatus') {
void api.cancelDebugBundleProcess({jobId: status.value.value.jobId});
}
});
}}>Stop</Button>:<Button variant="outline" as={ReactRouterLink} to="/admin/debug-bundle">Done</Button>}
</Box>
</Box>}
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const ClusterHealthOverview = () => {
<Box fontWeight="bold">Debug bundle</Box>
<Flex gap={2}>
{api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to={`/admin/debug-bundle/progress/${api.debugBundleStatus?.jobId}`}>Bundle generation in progress...</Button>}
{api.isDebugBundleReady && <DebugBundleLink statuses={api.debugBundleStatuses} showDatetime={false}/>}
{!api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to="/admin/debug-bundle/new">Generate new</Button>}
{api.canDownloadDebugBundle && <DebugBundleLink statuses={api.debugBundleStatuses} showDatetime={false}/>}
{!api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to="/admin/debug-bundle/">Generate new</Button>}
</Flex>
</Grid>
</ListItem>
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/state/backendApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ import { Features } from './supportedFeatures';
import { TransformMetadata } from '../protogen/redpanda/api/dataplane/v1alpha1/transform_pb';
import { Pipeline, PipelineCreate, PipelineUpdate } from '../protogen/redpanda/api/dataplane/v1alpha2/pipeline_pb';
import { License, ListEnterpriseFeaturesResponse_Feature, SetLicenseRequest, SetLicenseResponse } from '../protogen/redpanda/api/console/v1alpha1/license_pb';
import { CreateDebugBundleRequest, CreateDebugBundleResponse, DebugBundleStatus, DebugBundleStatus_Status, GetClusterHealthResponse, GetDebugBundleStatusResponse_DebugBundleBrokerStatus } from '../protogen/redpanda/api/console/v1alpha1/debug_bundle_pb';
import { CreateDebugBundleRequest, CreateDebugBundleResponse, DebugBundleStatus, DebugBundleStatus_Status, GetDebugBundleStatusResponse_DebugBundleBrokerStatus } from '../protogen/redpanda/api/console/v1alpha1/debug_bundle_pb';

const REST_TIMEOUT_SEC = 25;
export const REST_CACHE_DURATION_SEC = 20;
Expand Down Expand Up @@ -1615,7 +1615,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
Expand All @@ -1631,7 +1631,15 @@ const apiStore = {
},

get canDownloadDebugBundle() {
return this.isDebugBundleReady && this.debugBundleStatuses.filter(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.SUCCESS).length > 0
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.all(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.ERROR);
},

get isDebugBundleExpired() {
return this.isDebugBundleReady && this.debugBundleStatuses.some(status => status.value.case === 'bundleStatus' && status.value.value.status === DebugBundleStatus_Status.EXPIRED);
},

get isDebugBundleInProgress() {
Expand Down

0 comments on commit 8a65264

Please sign in to comment.