-
Notifications
You must be signed in to change notification settings - Fork 887
feat: Enable workspace debug logging #6838
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
Conversation
coderd/workspacebuilds_test.go
Outdated
t.Parallel() | ||
|
||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) | ||
user := coderdtest.CreateFirstUser(t, client) |
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.
Blocking: instead of running this as the "admin" user, we should instead do as above and create another user with template admin permissions. This would more properly test that the template author has the correct permissions to create this sort of job.
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.
Thank you for the hint! Refactored.
@@ -59,6 +65,8 @@ type CreateWorkspaceBuildRequest struct { | |||
// This will not delete old params not included in this list. | |||
ParameterValues []CreateParameterRequest `json:"parameter_values,omitempty"` | |||
RichParameterValues []WorkspaceBuildParameter `json:"rich_parameter_values,omitempty"` | |||
|
|||
LogLevel ProvisionerLogLevel `json:"log_level,omitempty" validate:"omitempty,oneof=debug"` |
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.
suggestion: Add a comment so this gets documented in the API doc
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.
Fixed!
return response, true | ||
} | ||
|
||
provisionerLogLevel := proto.LogLevel_value[strings.ToUpper(config.ProvisionerLogLevel)] |
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.
Is there a way to avoid having to upper/lowercase this? Not blocking, just curious.
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 suppose that the only way to do this is to switch to log_level: DEBUG
, so that it's upper-case everywhere. Not sure if it's worth it.
coderd/workspacebuilds_test.go
Outdated
for { | ||
log, ok := <-logs | ||
if !ok { | ||
break | ||
} | ||
|
||
if log.Output == "dont-want-it" { | ||
require.Failf(t, "unexpected log message", "%s log message shouldn't be logged: %s", log.Level, log.Output) | ||
} | ||
|
||
if log.Output == "done" { | ||
return | ||
} | ||
} |
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.
review: although it's in a naked for, this shouldn't hang forever as WorkspaceBuildLogsAfter
exits on <-ctx.Done()
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.
Good catch! Refactored.
Related: #6186
Related: #4767
This PR enables workspace debug logging on the backend side.
TODO:
Tested:
mind the
"log_level":"debug"
parameterFollow-up: