-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow restarting workspaces with forceDefaultImage=true even when another instance is already running #3993
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
@csweichel Could you please take a careful look? (I really don't want to introduce new bugs in the workspace start logic.) Note: This change seems to work well / as expected. However, I get no Docker build logs in core-dev -- not sure why. |
/werft run 👍 started the job as gitpod-build-jx-restart-w-default-image.1 |
/werft run 👍 started the job as gitpod-build-jx-restart-w-default-image.2 |
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.
Adding review comments from a call with @csweichel here for the record (many thanks Chris!)
// We already have a running workspace. This may happen if we're forcing the default image. | ||
// In that case, we stop the previous first. | ||
await this.internalStopWorkspace({ span }, workspaceId, workspace.ownerId).catch(err => { | ||
log.error(logCtx, "stopWorkspace error: ", err); | ||
}); |
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 call only blocks until the stop request is sent.
In order to completely prevent multiple instances from running at the same time, we should probably also listen for instance updates here (e.g. via messageBusIntegration.listenForWorkspaceInstanceUpdates()) and only move on when the previous instance is definitely stopped.
There is also a case where the previous instance was in a different region, in which case to be fully pedantic we should also poll the DB, but it's probably okay to not do that here.
f477ac3
to
27056fe
Compare
Code review feedback from @csweichel implemented ✅ and still works as expected. 🎉 Two questions:
gitpod/components/server/src/workspace/gitpod-server-impl.ts Lines 426 to 427 in 27056fe
given that the previously running instance is only stopped afterwards? gitpod/components/server/src/workspace/gitpod-server-impl.ts Lines 440 to 446 in 27056fe
Prettified error stack:
Unsure if related or serious. (Could it be that's because we have no GCP region information in core-dev?) |
No. It only checks if the user has the permission to execute that operation, but not if the operation makes sense.
The problem here is that the instance wasn't actually started yet, i.e. it didn't go through |
…prevent restart spam
… when another instance is already running Fixes #3777
27056fe
to
de1eff9
Compare
Aha, that makes sense. Thanks!
Thanks for the pointer! Looking into gitpod/components/server/src/workspace/workspace-starter.ts Lines 132 to 133 in 2e7cba9
happens before: gitpod/components/server/src/workspace/workspace-starter.ts Lines 156 to 159 in 2e7cba9
So in our case (long-running Docker build that we want to interrupt/skip), we should expect not to have a How should we stop "preparing" instances that don't have a |
After discussing this further, we've decided to not make Docker builds interruptible just yet, and instead remove the button when builds are in progress (to align with the previous dashboard design). Superseded by #4104 |
Fixes #3777
How to test:
sleep 1h