Skip to content

feat: slim down GET /workspaces payload and remove unused types - #1253

Open
Snehadas2005 wants to merge 4 commits into
kubeflow:notebooks-v2from
Snehadas2005:task-slim-down-workspaces
Open

feat: slim down GET /workspaces payload and remove unused types#1253
Snehadas2005 wants to merge 4 commits into
kubeflow:notebooks-v2from
Snehadas2005:task-slim-down-workspaces

Conversation

@Snehadas2005

Copy link
Copy Markdown
Member

This PR slims down the payload returned by the workspace list API endpoint (GET /workspaces) by removing fields that are now served on-demand by the /podtemplate/details endpoint. This reduces payload size and establishes a clean separation between list views and details overlays.

Specifically:

  • Removes pendingRestart from WorkspaceListItem.
  • Removes podMetadata and volumes from the PodTemplate property in the list responses.
  • Cleans up and removes unused types/functions in the workspaces common packages.

Warning

This is a breaking API change for the frontend. The frontend must migrate to retrieve details metadata via GET /podtemplate/details and compute pendingRestart client-side from the options redirect chains.

Key Changes

  1. Workspace List Schema Slimming:
    • Removed PendingRestart field from WorkspaceListItem (internal/models/workspaces/types.go).
    • Removed PodMetadata and Volumes fields from PodTemplate (internal/models/workspaces/types.go).
    • Deleted PodVolumes struct.
  2. Details Isolation:
    • Localized the definitions of PodVolumeInfo and PodSecretInfo to internal/models/workspaces/podtemplate/details/types.go.
    • Relocated helper functions BuildHomeVolume(), BuildDataVolumes(), and BuildSecretVolumes() from common/funcs.go to details/funcs.go to prevent any reference from list endpoint modules.
  3. OpenAPI Documentation:
    • Regenerated Swagger/OpenAPI specifications (swagger.json and docs.go) to reflect the new models.
  4. Test Maintenance:
    • Updated workspaces_handler_test.go to remove outdated list payload assertions.

Verification

  • Code Build: Ran successfully with go build -o tmp_build_bin ./cmd/main.go.
  • Unit Tests: Ran go test ./... and verified that all 124 API test specifications passed.
  • Spec Integrity: Validated changes to swagger.json and docs.go schema.

closes: #1030
related: #885

@github-project-automation github-project-automation Bot moved this to Needs Triage in Kubeflow Notebooks Jul 15, 2026
@google-oss-prow google-oss-prow Bot added the area/backend area - related to backend components label Jul 15, 2026
@google-oss-prow google-oss-prow Bot added area/v2 area - version - kubeflow notebooks v2 size/L labels Jul 15, 2026
Name string `json:"name"`
}

const UnknownHomeMountPath = "__UNKNOWN_HOME_MOUNT_PATH__"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we move this to a const def at the top of this file like other constants.

@Snehadas2005

Copy link
Copy Markdown
Member Author

Hi @thesuperzapper! I have updated the file by moving the constant to the top for better clarity. If there are any other adjustments or enhancements needed, please let me know.

@andyatmiami andyatmiami left a comment

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.

@Snehadas2005

this is looking really good - some minor cleanup/alignment issues - hopefully straightforward! let me know if you have questions!

and, out of curiosity - while this absolutely is technically a breaking API change - i'm wondering if you actually tried spinning up a Tilt cluster on this codebase to see if anything in the UI actually/noticably breaks?

I know we removed the "collapsible drawer" from the UI prior to this work - so it could very well be that nothing is relying on the functionality we are breaking. I would appreciate if you could comment on the PR if/where we see breaking behavior in the frontend - so I can coordinate with @thaorell if/as necessary to stage some additional changes so we can cleanly merge this PR.

Thanks!

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.

I think with the introduction of these types in podtemplate/details - we can now actually REMOVE the types we had originally added to common/

  • admittedly it was a weird dance - but the right one to ensure at any given time code was optimal!

So I think the following can be cleaned up from common/types.go (can't directly comment on it since that file isn't presently included in this PR):

  • const UnknownHomeMountPath
  • type PodVolumeInfo struct
  • type PodSecretInfo struct

PodMetadata SHOULD REMAIN in common/types.go

package details

import (
ptr "k8s.io/utils/ptr"

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.

Every other file in the backend imports this package without an alias since the package name is already ptr. The explicit alias is redundant and inconsistent with codebase convention.

@google-oss-prow google-oss-prow Bot added area/controller area - related to controller components size/XXL and removed size/L labels Jul 21, 2026
Snehadas2005 and others added 4 commits July 21, 2026 18:34
Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
Co-authored-by: Andy Stoneberg <astonebe@redhat.com>
Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
…meInfo, and PodSecretInfo

Signed-off-by: Sneha Das <154408198+Snehadas2005@users.noreply.github.com>
@Snehadas2005
Snehadas2005 force-pushed the task-slim-down-workspaces branch from 0cd46bd to 813f996 Compare July 21, 2026 13:04
@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 ask for approval from andyatmiami. 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 and removed size/XXL labels Jul 21, 2026
@Snehadas2005

Copy link
Copy Markdown
Member Author

/remove-label area/controller

@google-oss-prow

Copy link
Copy Markdown

@Snehadas2005: The label(s) `/remove-label area/controller

cannot be applied. These labels are supported:tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, lifecycle/needs-triage, needs-triage. Is this label configured under labels -> additional_labelsorlabels -> restricted_labelsinplugin.yaml`?

Details

In response to this:

/remove-label area/controller

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Snehadas2005

Copy link
Copy Markdown
Member Author

Hi @andyatmiami!

I have updated the PR with the requested cleanups:

  1. Removed the redundant ptr import alias in podtemplate/details/funcs.go.
  2. Cleaned up and removed UnknownHomeMountPath, PodVolumeInfo, and PodSecretInfo from common/types.go (leaving only PodMetadata).
  3. Cleaned up the Git history and force-pushed to remove the duplicate commits from other authors.

Regarding the area/controller label:
The area/controller label was added because duplicate controller-related commits from upstream were temporarily merged during a previous rebase. I've requested the bot to remove it so this PR remains focused solely on the backend.

Regarding Tilt & Frontend Testing:
I am currently spinning up the Tilt cluster to verify whether any frontend UI breaks as a result of this change. I will post a final update here once the validation is complete!

@andyatmiami

andyatmiami commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

/hold

i'm going to get a frontend PR raised to ensure merging this doesn't break frontend

(but note I have reviewed/tested this PR and will be ready to "sign off" once we get frontend appropriately staged and ready for these changes)

update:
#1278 is the PR I will be looking to merge ASAP so we can then rebase this PR on top of it and get it merged as well 💯

andyatmiami added a commit to andyatmiami/kubeflow-notebooks that referenced this pull request Jul 27, 2026
Migrate the workspace details drawer to fetch volumes, labels, and
annotations from the dedicated GET /workspaces/{ns}/{name}/podtemplate/details
endpoint (PR kubeflow#1119) instead of reading them from the list-item payload.
This prepares the frontend for PR kubeflow#1253, which removes pendingRestart,
podTemplate.podMetadata, and podTemplate.volumes from the list response.

New hook — useWorkspaceDetails:
- Follows the established useFetchState pattern (useCallback → useFetchState)
- Fetches DetailsWorkspaceDetails on-demand when a workspace is selected
- Returns [data, loaded, error, refresh] matching the standard tuple

Overview tab — labels from details endpoint:
- WorkspaceDetailsOverview now receives details/detailsLoaded props
- Labels read from details?.podMetadata.labels instead of the list item
- Shows a Spinner while the details request is in-flight

Resources tab — volumes from details endpoint:
- WorkspaceResources now receives details/detailsLoaded props
- Home volume and data volumes read from details?.volumes instead of
  the list item, with Spinner placeholders during loading

Activity tab — pendingRestart computed from redirect chains:
- Removes direct use of workspace.pendingRestart (will be dropped by kubeflow#1253)
- Derives the same boolean from redirectChain length on podConfig and
  imageConfig, which is semantically equivalent

Start/Stop modals — drop pendingRestart guard:
- workspacePendingUpdate condition simplified from
  `workspace?.pendingRestart && (redirectChain checks)` to
  `!!workspace && (redirectChain checks)`
- The !!workspace guard provides explicit null narrowing for TypeScript

Mock builders — backward-compatible refactoring:
- buildMockWorkspaceUpdateFromWorkspace accepts optional podMetadata
  and volumes args, falling back to list-item fields when not provided,
  so existing callers are unaffected
- New buildMockWorkspaceDetails builder for the details endpoint response
- mockNotebookApis details mock derives data from the workspace list
  item for consistency with other mock endpoints

Cypress tests — details endpoint intercepts:
- Add interceptApi type overload for the podtemplate/details route
- Add details endpoint intercepts in setupWorkspaceActionTest and the
  multi-workspace drawer switching test to prevent unhandled requests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
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/controller area - related to controller components area/v2 area - version - kubeflow notebooks v2 do-not-merge/hold size/L

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

3 participants