-
Notifications
You must be signed in to change notification settings - Fork 936
fix: let workspace pages download partial logs for unhealthy workspaces #13761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f1f5f88
fix: get basic fix in for preventing download logs from blowing up UI
Parkreiner edd6362
fix: make sure blob units can't go out of bounds
Parkreiner 901aa39
fix: make sure timeout is cleared on component unmount
Parkreiner e1d8113
fix: reduce risk of shared cache state breaking useAgentLogs
Parkreiner 87f57aa
fix: allow partial downloading of logs
Parkreiner 5bf2baf
fix: make sure useMemo cache is used properly
Parkreiner 5c2316b
wip: commit current progress on updated logs functionality
Parkreiner edd6569
docs: rewrite comment for clarity
Parkreiner 2eb7d6e
refactor: clean up current code
Parkreiner fa06515
fix: update styles for unavailable logs
Parkreiner 8fb4496
fix: resolve linter violations
Parkreiner 6935f50
fix: update type signature of getErrorDetail
Parkreiner f74eda4
fix: revert log/enabled logic for useAgentLogs
Parkreiner 7b76eb7
fix: remove memoization from DownloadLogsDialog
Parkreiner 07ff536
fix: update name of timeout state
Parkreiner 460aa53
refactor: make log web sockets logic more clear
Parkreiner 5a449b4
docs: reword comment for clarity
Parkreiner eb4f88c
fix: commit current style update progress
Parkreiner 71692b6
fix: finish style updates
Parkreiner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: allow partial downloading of logs
- Loading branch information
commit 87f57aa970b1ae3e993982f4274f7943407fca8b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import { | |
} from "components/Dialogs/ConfirmDialog/ConfirmDialog"; | ||
import { displayError } from "components/GlobalSnackbar/utils"; | ||
import { Stack } from "components/Stack/Stack"; | ||
import { ErrorAlert } from "components/Alert/ErrorAlert"; | ||
|
||
const BLOB_SIZE_UNITS = ["B", "KB", "MB", "GB", "TB"] as const; | ||
Parkreiner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
@@ -76,9 +77,7 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({ | |
return files; | ||
}, [agentLogResults, agents, buildLogsQuery.data, workspace.name]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a problem with the previous logic: because |
||
|
||
const isLoadingFiles = downloadableFiles.some((f) => f.blob === undefined); | ||
const [isDownloading, setIsDownloading] = useState(false); | ||
|
||
const timeoutIdRef = useRef<number | undefined>(undefined); | ||
useEffect(() => { | ||
const clearTimeoutOnUnmount = () => { | ||
|
@@ -88,24 +87,37 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({ | |
return clearTimeoutOnUnmount; | ||
}, []); | ||
|
||
const isWorkspaceHealthy = workspace.health.healthy; | ||
const isLoadingFiles = downloadableFiles.some((f) => f.blob === undefined); | ||
|
||
return ( | ||
<ConfirmDialog | ||
{...dialogProps} | ||
hideCancel={false} | ||
title="Download logs" | ||
confirmText="Download" | ||
disabled={isLoadingFiles} | ||
confirmLoading={isDownloading} | ||
confirmText={ | ||
<> | ||
Download | ||
{!isWorkspaceHealthy && <> {isLoadingFiles ? "partial" : "all"}</>} | ||
</> | ||
} | ||
disabled={ | ||
isDownloading || | ||
// If a workspace isn't healthy, let the user download as many logs as | ||
// they can | ||
(isWorkspaceHealthy && isLoadingFiles) | ||
} | ||
onConfirm={async () => { | ||
try { | ||
setIsDownloading(true); | ||
const zip = new JSZip(); | ||
downloadableFiles.forEach((f) => { | ||
if (f.blob) { | ||
zip.file(f.name, f.blob); | ||
} | ||
}); | ||
setIsDownloading(true); | ||
const zip = new JSZip(); | ||
downloadableFiles.forEach((f) => { | ||
if (f.blob) { | ||
zip.file(f.name, f.blob); | ||
} | ||
}); | ||
|
||
try { | ||
const content = await zip.generateAsync({ type: "blob" }); | ||
download(content, `${workspace.name}-logs.zip`); | ||
dialogProps.onClose(); | ||
|
@@ -125,6 +137,16 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({ | |
Downloading logs will create a zip file containing all logs from all | ||
jobs in this workspace. This may take a while. | ||
</p> | ||
|
||
{!isWorkspaceHealthy && isLoadingFiles && ( | ||
<> | ||
<ErrorAlert | ||
error="Your workspace is not healthy. Some logs may not be available, but | ||
you can still download any that are." | ||
/> | ||
</> | ||
)} | ||
|
||
<ul css={styles.list}> | ||
{downloadableFiles.map((f) => ( | ||
<li key={f.name} css={styles.listItem}> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.