-
Notifications
You must be signed in to change notification settings - Fork 50
feat(ws): Implement workspace start + pause as backend APIs #340
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
base: notebooks-v2
Are you sure you want to change the base?
feat(ws): Implement workspace start + pause as backend APIs #340
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/ok-to-test |
fb2e2fb
to
f22b3d3
Compare
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.
f22b3d3
to
8d5e467
Compare
related: kubeflow#298 - Added StartWorkspaceHandler + PauseWorkspaceHandler to handle the respective workspace actions - Introduced new routes for starting and pausing workspaces in the API. - `api/v1/workspaces/{namespace}/{name}/actions/start` - `api/v1/workspaces/{namespace}/{name}/actions/pause` - Created a new PauseStateEnvelope type for successful responses. - Added tests for the new APIs, including success and error cases. - Updated README/OpenAPI documentation to include the new endpoints. Signed-off-by: Andy Stoneberg <[email protected]>
8d5e467
to
3237336
Compare
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.
Some questions inline.
return | ||
} | ||
|
||
// Get the workspace to check its paused state |
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 believe this comment is outdated.
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.
yes, sorry.. its not doing a "check" here - moreso querying the workspace to return its actual/persisted state.
|
||
// Get the workspace to check its paused state | ||
workspace, err := a.repositories.Workspace.GetWorkspace(r.Context(), namespace, workspaceName) | ||
if err != 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.
On this call, we are not checking anything, are we?
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 our intention check this based on the. action?
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.
(and lets not forget about the async especially on start)
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.
perhaps the phrase "checking" is misleading here - but we do interact with this queried workspace
to return this value:
Does this warrant/justify a "read" operation when the backend could potentially simply "infer" this value? I think its still better to reflect actual state after operation by querying the resource..
But, I don't really follow your comments about "async" here... as mentioned in other comment... setting the .spec.paused
attribute IS instantaneous (which is all we are concerned about in this function)
admittedly the State
of the workspace resource is subject to eventual consistency - but that isn't (in my view) a focus/concern of this API
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.
Andy, thanks for the clarification on the chat. let's fup here!
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.
So, for transparency here.. I was slightly incorrect in my comments above...
It seems the RawPatch
command leveraged in the application code is itself asynchronously applied by k8s... so there is a race condition present here in this version of the code...
At the time we call this GetWorkspace
function - we cannot guarantee that the Patch
has been applied.. and as such the .spec.paused
attribute might not have been updated yet...
I'm honestly not sure how to handle this...
Blocking and waiting seems kinda gross (to me) - but I also feel dirty hard-coding the .data.paused
value we return in the PausedState response struct...
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.
We should definitely not block it. For the UI, maybe we can use the status to notify user that something is being processed.
I would not hardcode the value, because, for instance, on start, things can fail, and if we hardcode, it could be inconsistent.
Why don't return 202 and something like
{data:
"status": "accepted",
"message": "bla",
"
}
} | ||
|
||
// Return 200 OK with pause state | ||
err = a.WriteJSON(w, http.StatusOK, PauseStateEnvelope{ |
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.
One question here. I assume Pause/Start actions are not instantaneous, shall we just return a 202 accepted?
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.
well... setting the spec.paused
property itself is instantaneous...
I generally think of 202
meaning the API request itself has not been processed...
whereas this case is "the backend k8s state is now churning to reach a state of eventual consistency"
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.
Andy, thanks for the clarification on the chat. let's fup here!
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.
see comment above: #340 (comment)
202
might be the safer option - but still need to then answer/determine if/how we want to return the paused
attribute in the response
related: #298
api/v1/workspaces/{namespace}/{name}/actions/start
api/v1/workspaces/{namespace}/{name}/actions/pause
Functionality tested/verified via generated Swagger client: