Skip to content

feat: implement podtemplate details endpoint for workspace overlay#1119

Open
Snehadas2005 wants to merge 1 commit into
kubeflow:notebooks-v2from
Snehadas2005:task-get-podtemplate
Open

feat: implement podtemplate details endpoint for workspace overlay#1119
Snehadas2005 wants to merge 1 commit into
kubeflow:notebooks-v2from
Snehadas2005:task-get-podtemplate

Conversation

@Snehadas2005
Copy link
Copy Markdown

@Snehadas2005 Snehadas2005 commented May 22, 2026

Description
This PR implements a dedicated details endpoint (GET /api/v1/workspaces/{namespace}/{name}/podtemplate/details) for the workspace details overlay. This decouples the frontend overlay layout from the generic workspace list endpoint, allowing richer data to be fetched efficiently on-demand.

Key Changes:

  • Constants: Added route path constants for the new endpoint in api/constants/paths.go.
  • Models: Defined response schemas and implemented the clean CR-to-Model transformation mapping in types_details.go and funcs_details.go (including conditional null mapping for paused workspaces).
  • Repository: Extended WorkspaceRepository with a GetWorkspaceDetails method fetching both the core Workspace CR and its associated WorkspaceKind.
  • API Handler: Implemented GetWorkspaceDetailsHandler with strict RBAC authentication (requireAuth) and namespace/name path verification.
  • Testing: Added isolated handler unit tests verifying running/paused states and validation paths.

Related Issue
Closes #1029

Verification Results

  • Ran go fmt ./... and go vet ./... successfully (no syntax/static analysis errors).
  • Isolated handler unit tests passed successfully:
    go test ./api -run TestGetWorkspaceDetailsHandler -v
    

AI Policy Compliance
Assisted-by: Gemini gemini@google.com
Co-authored-by: Claude claude@anthropic.com

Note: AI assistance was utilized specifically to debug Windows-vs-Linux environment line-ending constraints in the auto-generated Swagger schema pipeline, as well as to accelerate the test-suite refactoring from traditional tables to the native Ginkgo/Gomega syntax structure.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Kubeflow Notebooks May 22, 2026
@Snehadas2005 Snehadas2005 changed the title chore(frontend): update ts-jest to 29.4.9 feat: implement podtemplate details endpoint for workspace overlay May 22, 2026
@google-oss-prow
Copy link
Copy Markdown

[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 andyatmiami for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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 size/L area/backend area - related to backend components labels May 22, 2026
@google-oss-prow google-oss-prow Bot added the area/v2 area - version - kubeflow notebooks v2 label May 22, 2026
@Snehadas2005 Snehadas2005 force-pushed the task-get-podtemplate branch 2 times, most recently from af21305 to 4398ca0 Compare May 22, 2026 13:39
Copy link
Copy Markdown
Contributor

@christian-heusel christian-heusel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution, I have left you a few review comments below! 🤗

Also did you use AI in any capacity while creating this contribution? I see that your commit does not carry any Assisted-By: <...> / Co-authored-by: <...> tags, so I wanted to make sure that you're aware of the Kubeflow AI Policy. 🤗 🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll also need to generate the new relevant swagger files for this endpoint:

$ make -C workspaces/backend/ swag

Comment on lines +31 to +41
type WorkspaceDetailVolume struct {
PVCName string `json:"pvcName"`
MountPath string `json:"mountPath"`
ReadOnly bool `json:"readOnly"`
}

type WorkspaceDetailSecret struct {
SecretName string `json:"secretName"`
MountPath string `json:"mountPath"`
DefaultMode int32 `json:"defaultMode,omitempty"`
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have models for those datatypes that we could potentially reuse for these implementations instead of defining new types inline.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not introduce a new testing framework and reuse the pre-existing infrastructure around gomega

Comment on lines +55 to +58
readOnly := false
if v.ReadOnly != nil {
readOnly = *v.ReadOnly
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use ptr.Deref(volume.ReadOnly, false) for something like this:

Suggested change
readOnly := false
if v.ReadOnly != nil {
readOnly = *v.ReadOnly
}
readOnly := ptr.Deref(volume.ReadOnly, false)

Comment on lines +32 to +33
WorkspacePodTemplatePath = WorkspacesByNamePath + "/podtemplate"
WorkspacePodTemplateDetailsPath = WorkspacePodTemplatePath + "/details"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a unused exported variable, you can just fold those two declarations into one.

type WorkspaceDetailVolumes struct {
Home *WorkspaceDetailVolume `json:"home"`
Data []WorkspaceDetailVolume `json:"data"`
Secrets []WorkspaceDetailSecret `json:"secrets"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not consistent with the Secrets API contract, the other one uses omitempty.

PodSecretInfo in types.go has omitempty on the slice. WorkspaceDetailSecret.Data and WorkspaceDetailSecret.Secrets (in WorkspaceDetailVolumes) omit this tag, which means the JSON response always includes "data": [] and "secrets": [] even when empty, unlike the rest of the API.

Comment on lines +66 to +74
// secret volumes — DefaultMode is int32 (not *int32), use directly
secretVolumes := make([]WorkspaceDetailSecret, len(ws.Spec.PodTemplate.Volumes.Secrets))
for i, s := range ws.Spec.PodTemplate.Volumes.Secrets {
secretVolumes[i] = WorkspaceDetailSecret{
SecretName: s.SecretName,
MountPath: s.MountPath,
DefaultMode: s.DefaultMode, // int32 directly, no dereference needed
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments around int32 don't make sense to me, why did you add them? 😅

@google-oss-prow google-oss-prow Bot added size/XXL and removed size/L labels May 26, 2026
@Snehadas2005 Snehadas2005 marked this pull request as draft May 26, 2026 15:23
@Snehadas2005 Snehadas2005 force-pushed the task-get-podtemplate branch 6 times, most recently from 1ee8a36 to 78eb914 Compare May 27, 2026 16:48
@Snehadas2005 Snehadas2005 marked this pull request as ready for review May 27, 2026 17:30
@Snehadas2005 Snehadas2005 force-pushed the task-get-podtemplate branch from 3d38c1b to eee1f2a Compare May 27, 2026 17:35
Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
@Snehadas2005 Snehadas2005 force-pushed the task-get-podtemplate branch from eee1f2a to 2fc9aac Compare May 27, 2026 17:38
@Snehadas2005
Copy link
Copy Markdown
Author

Hi @christian-heusel! Thank you for your feedback. I have addressed your comments and refactored the branch into a clean commit.

Key updates include:

  1. Added Assisted-by: Gemini and Co-authored-by: Claude tags for AI policy compliance.
  2. Removed redundant structs in types_details.go, reusing standard models.
  3. Added ,omitempty tags for API contract consistency.
  4. Refactored the test suite to use Ginkgo and Gomega properly.
  5. Cleaned up code with standard utilities and removed unnecessary comments.
  6. Regenerated OpenAPI spec configurations.

Ready for your review! 🤗

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/XXL

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants