-
Notifications
You must be signed in to change notification settings - Fork 881
feat: Integrate workspace agent into coderd #398
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
// This command isn't useful for users, and seems | ||
// more likely to confuse. | ||
Hidden: true, |
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.
Makes sense to me 👍
Codecov Report
@@ Coverage Diff @@
## main #398 +/- ##
==========================================
- Coverage 67.87% 66.10% -1.77%
==========================================
Files 150 71 -79
Lines 8482 773 -7709
Branches 72 72
==========================================
- Hits 5757 511 -5246
+ Misses 2148 248 -1900
+ Partials 577 14 -563
Continue to review full report at Codecov.
|
|
||
func workspaceAgent() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "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.
Having the coder agent
command is a huge step!
api.websocketWaitGroup.Add(1) | ||
defer api.websocketWaitGroup.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.
Glad we have this to hook into now to ensure that the websockets get cleaned up properly
return r(req) | ||
} | ||
|
||
// Create's a new Google metadata client to authenticate. |
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.
// Create's a new Google metadata client to authenticate. | |
// Creates a new Google metadata client to authenticate. |
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.
Just noticed this extra apostrophe!
}) | ||
} | ||
|
||
// Create's a signed JWT with a randomly generated private key. |
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.
// Create's a signed JWT with a randomly generated private key. | |
// Creates a signed JWT with a randomly generated private key. |
return signedKey, keyID, privateKey | ||
} | ||
|
||
// Create's a validator that verifies against the provided private key. |
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.
// Create's a validator that verifies against the provided private key. | |
// Creates a validator that verifies against the provided private key. |
|
||
type workspaceResourceParamContextKey struct{} | ||
|
||
// ProvisionerJobParam returns the project from the ExtractProjectParam handler. |
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.
// ProvisionerJobParam returns the project from the ExtractProjectParam handler. | |
// WorkspaceResourceParam returns the provisioner job resource from the handler. |
job := coderdtest.CreateProjectImportJob(t, client, user.Organization, &echo.Responses{ | ||
Parse: echo.ParseComplete, | ||
Parse: echo.ParseComplete, | ||
ProvisionDryRun: echo.ProvisionComplete, |
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.
Neat 👍
@@ -94,11 +94,9 @@ func TestAgent(t *testing.T) { | |||
|
|||
func setup(t *testing.T) proto.DRPCPeerBrokerClient { | |||
client, server := provisionersdk.TransportPipe() | |||
closer := agent.New(func(ctx context.Context) (*peerbroker.Listener, error) { | |||
return peerbroker.Listen(server, &peer.ConnOptions{ | |||
Logger: slogtest.Make(t, nil), |
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.
If I understand correctly, it seems like the log level for this has changed - I wonder if that could be related to the test failure here: https://github.com/coder/coder/runs/5416391323?check_suite_focus=true#step:7:168
(thinking maybe this change increases the verbosity of logs, and one of those more-verbose logs is what gets emitted after the test is complete).
Unfortunately I saw this error in the CI run:
https://github.com/coder/coder/runs/5416391323?check_suite_focus=true#step:7:168 I was thinking maybe one of two possibilities:
We currently wait for the session, ie:
But wondering if it needs to be closed too as part of cleanup:
|
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.
Looks good to me - just some minor nits on the comments, and was thinking around the test failure I observed in the latest commit.
Congrats on getting the agent integrated into coderd
🍾
Superseded by #401 |
A lot of this code is kinda crummy. I'd like to refactor some of the API handler names for resources, but that can come in a later PR.