Skip to content

feat(ws): Implement DELETE endpoint for WorkspaceKind #480

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

Open
wants to merge 1 commit into
base: notebooks-v2
Choose a base branch
from

Conversation

andyatmiami
Copy link
Contributor

⚠️ No GH Issue ⚠️

  • Added the ability to delete a specific WorkspaceKind via a new DELETE API endpoint.
    • DELETE /workspacekinds/{name}
  • Updated the README to include the new endpoint details and added corresponding tests to ensure proper functionality and error handling for various scenarios, including validation and authorization checks.
  • Swagger files regenerated

The implementation is more or less a "carbon copy" of how it is implemented for Workspaces with the exception of the need to handle the Conflict that can be returned by the admission webhook. While there is basic handling of this condition in the PR - I'm not necessarily happy with it.

First off, there is an error message prefix inserted by kubernetes itself:

curl -X 'DELETE'   'http://localhost:4001/api/v1/workspacekinds/jupyterlab'   -H 'accept: application/json'
{
	"error": {
		"code": "409",
		"message": "admission webhook \"vworkspacekind.kb.io\" denied the request: Operation cannot be fulfilled on WorkspaceKind.kubeflow.org \"jupyterlab\": WorkspaceKind is used by 2 workspace(s)"
	}
}

The admission webhook \"vworkspacekind.kb.io\" denied the request: is appended on the error message returned from workspacekind_webhook.go and not easily able to be omitted (without falling back to brittle string parsing). I personally don't think that is appropriate details to put in an error message that could be surfaced in the UI. And while a Conflict error today is the only surfaced from the workspacekind webhook code if a workspace is using it - I'm not confident that condition would hold in the future... and there is no other information I can reliably act on to distinguish this particular cause (to simply provide a more succinct error message in repo.go)

Furthermore, our testing framework does not currently run with webhooks - so I have deliberately NOT added a test case for this behavior.

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign thesuperzapper for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot added the area/backend area - related to backend components label Jul 11, 2025
@google-oss-prow google-oss-prow bot added area/v2 area - version - kubeflow notebooks v2 size/L labels Jul 11, 2025
@andyatmiami andyatmiami force-pushed the feat/workspacekind-delete branch from 49f77ed to 3613aaf Compare July 11, 2025 20:22
- Added the ability to delete a specific WorkspaceKind via a new DELETE API endpoint.
    - `DELETE /workspacekinds/{name}`
- Updated the README to include the new endpoint details and added corresponding tests to ensure proper functionality and error handling for various scenarios, including validation and authorization checks.
- Swagger files regenerated

The implementation is more or less a "carbon copy" of how it is implemented for Workspaces _with the exception_ of the need to handle the `Conflict` that can be returned by the admission webhook.  While there is basic handling of this condition in the PR - I'm not necessarily happy with it.

First off, there is an error message prefix inserted by kubernetes itself:

```
curl -X 'DELETE'   'http://localhost:4001/api/v1/workspacekinds/jupyterlab'   -H 'accept: application/json'
{
	"error": {
		"code": "409",
		"message": "admission webhook \"vworkspacekind.kb.io\" denied the request: Operation cannot be fulfilled on WorkspaceKind.kubeflow.org \"jupyterlab\": WorkspaceKind is used by 2 workspace(s)"
	}
}
```

The `admission webhook \"vworkspacekind.kb.io\" denied the request:` is appended on the error message returned from `workspacekind_webhook.go` and not easily able to be omitted (without falling back to brittle string parsing).  I personally don't think that is appropriate details to put in an error message that could be surfaced in the UI.  And while a `Conflict` error today is the only surfaced from the workspacekind webhook code if a workspace is using it - I'm not confident that condition would hold in the future... and there is no other information I can reliably act on to distinguish this particular cause (to simply provide a more succinct error message in `repo.go`)

Furthermore, our testing framework does not currently run with webhooks - so I have deliberately **NOT** added a test case for this behavior.

Signed-off-by: Andy Stoneberg <[email protected]>
@andyatmiami andyatmiami force-pushed the feat/workspacekind-delete branch from 3613aaf to 4d9e835 Compare July 11, 2025 21:20
@caponetto
Copy link

@paulovmr we'll need a frontend counterpart for this new endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend area - related to backend components area/v2 area - version - kubeflow notebooks v2 size/L
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

2 participants