- Notifications
You must be signed in to change notification settings - Fork914
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
const lastLog = logs?.at(-1); | ||
const canSetLogId = lastLog !== undefined && lastQueriedLogId.current === 0; | ||
if (canSetLogId) { | ||
lastQueriedLogId.current = lastLog.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Previously: we were checking that the array existed, but not that it actually had data
Really do think that we need to bite the bullet and get TypeScript'snoUncheckedIndexedAccess
compiler option turned on, because it would've caught this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is a good one and would require a ticket and PR by itself.
site/src/pages/WorkspacePage/WorkspaceActions/DownloadLogsDialog.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
site/src/pages/WorkspacePage/WorkspaceActions/DownloadLogsDialog.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
files.push({ name, blob }); | ||
}); | ||
return files; | ||
}, [agentLogResults, agents, buildLogsQuery.data, workspace.name]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This was a problem with the previous logic: becauseagents
was getting redefined every render, we were also invalidating theuseMemo
dependency array every render
site/src/pages/WorkspacePage/WorkspaceActions/DownloadLogsDialog.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
setIsDownloading(true); | ||
const zip = new JSZip(); | ||
allFiles.forEach((f) => { | ||
if (f.blob) { | ||
zip.file(f.name, f.blob); | ||
} | ||
}); |
ParkreinerJul 2, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Moved this out of thetry
block, because it should be the part that shouldn't be able to fail
notAvailableText: (theme) => ({ | ||
display: "flex", | ||
flexFlow: "row nowrap", | ||
alignItems: "center", | ||
columnGap: "4px", | ||
"& > span": { | ||
maxHeight: "fit-content", | ||
display: "flex", | ||
alignItems: "center", | ||
color: theme.palette.error.light, | ||
}, | ||
"& > p": { | ||
opacity: "80%", | ||
}, | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I've been stuck in the pre-Emotion, Backstage-specific version of MUI for the past few months, so please let me know if anything looks funky
Uh oh!
There was an error while loading.Please reload this page.
// don't accidentally break the memo cache every render. We can't tuck | ||
// everything into a single memo call, because we need to set up React Query | ||
// state between processing the agents, but we can't violate rules of hooks by | ||
// putting hooks inside of hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't know, but I feel it is an over-optimization. If it is fast enough and does not impact UI usage, I don't see why we should complicate things.
ParkreinerJul 2, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, I was considering that, but didn't really have time to test out how long it would take to keep generating blobs every render
To be clear, we basically have two choices:
- Keep the clunky but functional memoization
- Remove the memoization altogether
The original memoization has worse performance than not having memoization at all, because we're still recalculating the blobs every render, but React has to compare dependencies and decide if it should re-calculate the value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, it was my fault. I usually use "useMemo" to compute a variable value but it would probably be better to be a function. I would rather remove memorization altogether to make things simple.
]; | ||
return { | ||
agents: uniqueAgents, | ||
logOptionsArray: uniqueAgents.map((agent) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why do we need to calculate the query options here and not mount it and pass it in the query? I think it is kinda far from what is used and I took some time to linklogOptionsArray
toagentQueryOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, this was an over-optimization on my part. I basically figured that since the query objects shouldn't change unless the agents do, it was safe to throw them all together
let i = 0; | ||
while (size > 1024 && i <units.length) { | ||
while (size > 1024 && i <BLOB_SIZE_UNITS.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Since theBLOB_SIZE_UNITS
is only used here, I would not move it to leave outside of the function where it is used.
.filter((a) => a !== undefined) as WorkspaceAgent[]; | ||
// The while condition can break if we accidentally exceed the bounds of the | ||
// array. Have to be extra sure we have a unit at the very end. | ||
const finalUnit = BLOB_SIZE_UNITS[i] ?? BLOB_SIZE_UNITS.at(-1) ?? "TB"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I didn't get this 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry – just updated the wording on the comment for more clarity!
site/src/pages/WorkspacePage/WorkspaceActions/DownloadLogsDialog.tsx OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Left a few comments. I'm going to QA this later today.
@BrunoQuaresma Tried implementing all your feedback, and also added some styling for handling long filenames: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Awesome job!
940afa1
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Addresses the most important parts of#13723
Changes made
useAgentLogs
to make it more resistant to data being missing, or having agent log data be updated in other parts of the appScreen.Recording.2024-07-02.at.9.52.11.AM.mov
Notes