Skip to content

fix: respect namespace selection when fetching jobs#294

Open
A69SHUBHAM wants to merge 1 commit into
volcano-sh:mainfrom
A69SHUBHAM:fix-jobs-namespace-selection
Open

fix: respect namespace selection when fetching jobs#294
A69SHUBHAM wants to merge 1 commit into
volcano-sh:mainfrom
A69SHUBHAM:fix-jobs-namespace-selection

Conversation

@A69SHUBHAM

Copy link
Copy Markdown

Summary

This PR fixes namespace filtering on the Jobs page.

Previously, selecting a namespace only filtered jobs from the currently loaded page of results. Jobs that existed in the selected namespace but were not present in the current paginated dataset would not be displayed.

Changes

  • Added optional namespace support to the jobs query input.
  • Passed the selected namespace through the Jobs page query flow.
  • Added namespace-scoped job retrieval when a namespace is selected.
  • Preserved existing cluster-wide behavior when no namespace is selected.

Verification

  • Verified the application builds successfully.
  • Verified TypeScript type checking passes.
  • Confirmed existing behavior remains unchanged when no namespace is selected.
  • Confirmed namespace selection now uses namespace-scoped job retrieval logic.

Fixes #159

Signed-off-by: A69SHUBHAM <spacekrai0@gmail.com>
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[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 william-wang 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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements server-side namespace filtering for jobs, updating the UI columns, management component, tRPC router, schemas, and Kubernetes API fetch helper to support querying namespaced custom objects. The reviewer identified a critical issue where filtering jobs on the server side causes the list of available namespaces to shrink to only the selected one, making it impossible to switch namespaces without resetting. A state-based accumulation solution was suggested to preserve the full list of namespaces.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.


const utils = trpc.useUtils()

const [namespaceFilter, setNamespaceFilter] = useState<string | undefined>()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Issue: Since jobs are now filtered on the server side, once a namespace is selected, the jobs state will only contain jobs from that specific namespace. Because availableNamespaces (defined at line 82) is derived directly from the current jobs list, it will shrink to only contain the selected namespace. This makes it impossible for the user to switch to any other namespace from the dropdown without first selecting "All" to reset the list.

Solution: To preserve the list of all available namespaces, we can accumulate namespaces in a state variable as they are loaded.

Please apply the suggestion below to add the state and accumulation logic, and then update the createColumns call (around line 161) to pass accumulatedNamespaces instead of availableNamespaces.

  const [namespaceFilter, setNamespaceFilter] = useState<string | undefined>()
  const [accumulatedNamespaces, setAccumulatedNamespaces] = useState<string[]>([])

  useEffect(() => {
    if (jobs) {
      const namespaces = jobs.map(job => job.namespace).filter(Boolean)
      setAccumulatedNamespaces(prev => {
        const next = Array.from(new Set([...prev, ...namespaces])).sort()
        if (next.length === prev.length && next.every((v, i) => v === prev[i])) {
          return prev
        }
        return next
      })
    }
  }, [jobs])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jobs tab namespace selection broken

2 participants