-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix(serve): connect to Cloud if process is started outside of project dir #4822
Conversation
b9fcf44
to
9ff15fd
Compare
@eysi09 is this ready to do? LGTM, but I might miss some context. |
I'm not sure. Maybe I'm missing something, but when we connect to Cloud we need to do that in the context of some specific project. What would that be in the case where Garden is started outside of a given project? |
9ff15fd
to
e74353d
Compare
e74353d
to
2fc311f
Compare
@eysi09 and I just verified this works now for Desktop. So LGTM! 👍 |
There's actually one issue here with the The original intent was for it to only be set for the With this change it looks like we're setting the port for non-server commands and that breaks that behaviour. Maybe the fix is just to not set it for this particular code path but I'm not entirely sure if that makes sense or not. In any case it's not clear from the code as is why it should be omitted in this context. I flagged the PR as a draft until we fix that. |
Just to follow up. I think we just need to make sure we only set the This hasn't been an issue until the change in this issue was introduced. Basically the added |
… dir This came up in the Desktop client because it'd start the serve command outside of any project root, and thus not connect to Cloud at all for the live view etc. to work.
a172678
to
379d53a
Compare
core/src/server/instance-manager.ts
Outdated
@@ -403,7 +403,8 @@ export class GardenInstanceManager { | |||
// Use the process (i.e. parent command) session ID for the serve/dev command session | |||
sessionId: this.sessionId, | |||
commandInfo: garden.commandInfo, | |||
localServerPort: this.serveCommand.server.port, | |||
// set localServerPort only for dev/serve commands | |||
localServerPort: ["dev", "serve"].includes(garden.commandInfo.name) ? this.serveCommand.server.port : undefined, |
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 called in more places and we need to update it all of them.
Can I also suggest that in the registerSession
function we set the localServerPort
type to number | null
so that it's explicit and we won't forget to add it at other call sites.
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 we don't need to update other places. We basically have 3 calls of registerSession
including this one. The other 2 calls are in base.ts
and serve.ts
.
The base.ts
call already has a check and skips the registration in case of dev/serve.
garden/core/src/commands/base.ts
Lines 311 to 315 in 8490aac
const skipRegistration = | |
!["dev", "serve"].includes(this.name) && this.maybePersistent(params) && !params.parentCommand | |
if (!skipRegistration && garden.cloudApi && garden.projectId && this.streamEvents) { | |
cloudSession = await garden.cloudApi.registerSession({ |
And in serve.ts
, we do not need this check as it only registers session for dev/serve.
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.
Aha ok. Makes sense.
This came up in the Desktop client because it'd start the serve command outside of any project root, and thus not connect to Cloud at all for the live view etc. to work.
cc @eysi09