Skip to content

Instead of relying on the reactive state query parameter with .refetch(), fetch the YAML dynamically#281

Open
aniket866 wants to merge 1 commit into
volcano-sh:mainfrom
aniket866:fix/query-parameter
Open

Instead of relying on the reactive state query parameter with .refetch(), fetch the YAML dynamically#281
aniket866 wants to merge 1 commit into
volcano-sh:mainfrom
aniket866:fix/query-parameter

Conversation

@aniket866
Copy link
Copy Markdown

Closes #280

Brief Solution

Instead of relying on the reactive state query parameter with .refetch(), fetch the YAML dynamically on demand using the tRPC context/client cache or by calling fetch directly with the clicked row's details in the handler:

const handleJobClick = useCallback(async (job: JobStatus) => {
  setError(null);
  try {
    const yaml = await utils.jobsRouter.getJobYaml.fetch({
      namespace: job.namespace,
      name: job.name
    });
    setSelectedJob({ ...job, yaml: yaml || "" });
    setShowJobDetails(true);
  } catch (err) {
    setError("Failed to fetch job YAML");
  }
}, [utils]);

Why it happens

  1. When you click on a job or pod, the website is supposed to tell the server: "Give me the details for Job X."
  2. But because of how the code is written, it triggers the request to the server before it updates the active selection in its memory.
  3. So, the website sends a request to the server asking for details about "" (nothing / empty text).
  4. The server gets confused, returns an error, and the details window either fails to open or shows an error.

Simple Solution

Update the code so it first remembers exactly which job you clicked, and then immediately asks the server for that specific job's details instead of asking for "whatever is currently selected."

@de6p
/review

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @aniket866! It looks like this is your first PR to volcano-sh/dashboard 🎉

Copy link
Copy Markdown

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

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 refactors the fetching of YAML configurations for jobs, pods, and queues by replacing the useQuery hooks with direct fetch calls via TRPC utils inside the row click handlers. It also updates several dependencies in package-lock.json. The reviewer identified usability and potential race condition issues across all three management components (jobs-management.tsx, pod-management.tsx, and queue-management.tsx). Specifically, fetching the YAML before opening the details modal causes UI delays and allows concurrent requests. The reviewer suggested opening the modals immediately with basic details and fetching the YAML in the background.

Comment thread apps/web/src/components/(dashboard)/jobs/jobs-management.tsx
Comment thread apps/web/src/components/(dashboard)/pods/pod-management.tsx
Comment thread apps/web/src/components/(dashboard)/queues/queue-management.tsx
Signed-off-by: aniket866 <iamaniketkumarmaner@gmail.com>
@aniket866 aniket866 force-pushed the fix/query-parameter branch from c4f2e16 to b91b0d0 Compare May 26, 2026 19:42
@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 jessestutler 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

@aniket866
Copy link
Copy Markdown
Author

@de6p Please review

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.

Instead of relying on the reactive state query parameter with .refetch(), fetch the YAML dynamically

2 participants