-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Various prebuild fixes #20057
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
Various prebuild fixes #20057
Conversation
console.debug("fetching from streamUrl: " + streamUrl); | ||
response = await fetch(streamUrl, { | ||
method: "GET", | ||
cache: "no-cache", |
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.
using no-cache
here might've been problematic, because the browser makes a conditional request in the case there is a cache entry present for this request. The problem is that no-cache actually does cache 🙃
|
||
const decoder = new TextDecoder("utf-8"); | ||
let chunk = await reader.read(); | ||
while (!chunk.done) { | ||
if (disposables.disposed) { | ||
// stop reading when disposed |
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 means we don't have to read the whole body anymore if we dispose in the midst of it.
@@ -860,6 +860,12 @@ export class WorkspaceStarter { | |||
type: HeadlessWorkspaceEventType.Failed, | |||
workspaceID: workspace.id, | |||
}); | |||
await this.publisher.publishPrebuildUpdate({ |
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 fixes ENT-445
go func(t *task, term *terminal.Term) { | ||
state, err := term.Wait() | ||
taskLog.Info("task terminal has been closed. Waiting for watch() to finish...") | ||
taskWatchWg.Wait() |
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 makes sure that we append the 🍊 line before actually stopping the task.
This reverts commit fdc3183.
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.
There might be a case we're missing here:
gitpod/components/supervisor/pkg/supervisor/services.go
Lines 1132 to 1139 in c275510
n, err := reader.Read(buf) | |
if err == io.EOF { | |
if isClosed.Load() { | |
// We are done | |
log.Println("[prebuildlog]: closing because task state is done and we are done reading") | |
return nil | |
} | |
} |
Imagine that the task was just closed, and we have also just encountered the end of the file, but in the meantime by finishing it has written the last 🍊 line to the output, which we now didn't catch.
From the logs, the difference in a sample prebuild I did between setting the task state to closed and us closing the stream off is about 0.3 milliseconds, but I do not know on which timescale the file watcher operates.
Edit: from a quick test, it turns out that between writing to a file and getting a notification for it, it takes approximately 0.2ms, so maybe we're just too slow with the final notification.
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 think you are spot on. I tried to come up with a patch for it. @filiptronicek Is it fine if I add that on top of your PR?
Make sure we wait for the line to be written first
Here are the logs from my latest experiment with 4 clients: (could come in handy in the future) {
"alias": "505309c5-e312-4544-aa90-1bbcb319ecf8",
"file": "terminal.go:139",
"func": "doClose",
"level": "info",
"message": "closing terminal",
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"time": "2024-07-23T12:55:12.790276055Z"
}
{
"file": "export.go:84",
"func": "Error",
"level": "error",
"message": "Added kumquat line to prebuild log",
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "ERROR",
"time": "2024-07-23T12:55:12.790467795Z"
}
{
"command": "{\n./mvnw clean install -U -DskipTests\n}; exit",
"file": "tasks.go:330",
"func": "func2",
"level": "info",
"message": "task terminal has been closed. Waiting for watch() to finish...",
"pid": 58,
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"terminal": "505309c5-e312-4544-aa90-1bbcb319ecf8",
"time": "2024-07-23T12:55:12.790385835Z"
}
{
"command": "{\n./mvnw clean install -U -DskipTests\n}; exit",
"file": "tasks.go:332",
"func": "func2",
"level": "info",
"message": "watch() has finished, setting task state to closed",
"pid": 58,
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"terminal": "505309c5-e312-4544-aa90-1bbcb319ecf8",
"time": "2024-07-23T12:55:12.790609845Z"
}
{
"file": "export.go:154",
"func": "Println",
"level": "info",
"message": "[prebuildlog]: closing because task state is done and we are done reading",
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"time": "2024-07-23T12:55:12.790782805Z"
}
{
"file": "export.go:154",
"func": "Println",
"level": "info",
"message": "[prebuildlog]: closing because task state is done and we are done reading",
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"time": "2024-07-23T12:55:12.790780865Z"
}
{
"file": "export.go:154",
"func": "Println",
"level": "info",
"message": "[prebuildlog]: closing because task state is done and we are done reading",
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"time": "2024-07-23T12:55:12.790816395Z"
}
{
"file": "export.go:154",
"func": "Println",
"level": "info",
"message": "[prebuildlog]: closing because task state is done and we are done reading",
"serviceContext": {
"service": "supervisor",
"version": "commit-c275510fe58b6865ae5f5b10b85cd00a06ffc908-632948a1a049dce65aa5e2f57ce4cd64b2cb36be"
},
"severity": "INFO",
"time": "2024-07-23T12:55:12.790802255Z"
} |
components/dashboard/src/data/prebuilds/prebuild-logs-emitter.ts
Outdated
Show resolved
Hide resolved
I'm going to re-create the preview environment, as it's been GC'd over night. |
@filiptronicek Taking a closer look now. |
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.
Code LGTM, tested and works nicely, thanks! 🙏 ✔️
Description
This PR fixes a couple of prebuilds-related issues. It originally was set out to fix incomplete endings of logs, but it ended up being about so a couple of other fixes, just not about this one 🤷.
Related Issue(s)
Fixes ENT-445
Fixes the
NetworkError when attempting to fetch resource
bugHow to test
https://ft-fix-suc3e31a702ac.preview.gitpod-dev.com