Repository navigation
Add scheduler config management UI - #303
volcano-sh-bot merged 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new Scheduler configuration page to the Volcano dashboard, allowing users to view, edit, and save scheduler policies directly from the UI. It includes drag-and-drop action pipeline reordering, plugin tier management, and a YAML diff preview, supported by new tRPC endpoints and updated RBAC permissions. The review feedback highlights several key areas for improvement: resolving focus loss and reordering issues in the action configuration editor by using array indices as React keys; ensuring plugin enable flags can be explicitly set to true rather than deleted; improving browser compatibility for the unsaved changes warning by setting event.returnValue; and switching to index-based sortable IDs in the action pipeline editor to prevent glitches when duplicate actions are present.
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.
| {Object.entries(config.arguments).map(([key, value]) => ( | ||
| <div key={key} className="flex gap-2"> | ||
| <Input | ||
| className="flex-1" | ||
| value={key} | ||
| onChange={(e) => { | ||
| const nextArgs = { ...config.arguments }; | ||
| delete nextArgs[key]; | ||
| nextArgs[e.target.value] = value; | ||
| updateConfiguration(index, { | ||
| ...config, | ||
| arguments: nextArgs, | ||
| }); | ||
| }} | ||
| placeholder="key" | ||
| /> | ||
| <Input | ||
| className="flex-1" | ||
| value={String(value)} | ||
| onChange={(e) => | ||
| updateConfiguration(index, { | ||
| ...config, | ||
| arguments: { | ||
| ...config.arguments, | ||
| [key]: e.target.value, | ||
| }, | ||
| }) | ||
| } | ||
| placeholder="value" | ||
| /> | ||
| </div> | ||
| ))} |
There was a problem hiding this comment.
Using the argument key as the React key prop causes the input to lose focus on every keystroke when editing the key itself. Additionally, deleting and re-adding the key in onChange changes the insertion order, causing the edited row to jump to the bottom of the list.
To fix both issues and provide a better user experience, use the array index as the React key prop, preserve the key order when updating, and add a delete button so users can remove individual arguments.
{Object.entries(config.arguments).map(([key, value], argIndex) => (
<div key={argIndex} className="flex items-center gap-2">
<Input
className="flex-1"
value={key}
onChange={(e) => {
const nextArgs: Record<string, typeof value> = {};
for (const [k, v] of Object.entries(config.arguments)) {
if (k === key) {
nextArgs[e.target.value] = value;
} else {
nextArgs[k] = v;
}
}
updateConfiguration(index, {
...config,
arguments: nextArgs,
});
}}
placeholder="key"
/>
<Input
className="flex-1"
value={String(value)}
onChange={(e) =>
updateConfiguration(index, {
...config,
arguments: {
...config.arguments,
[key]: e.target.value,
},
})
}
placeholder="value"
/>
<Button
type="button"
variant="ghost"
size="icon"
className="text-muted-foreground hover:text-destructive shrink-0"
onClick={() => {
const nextArgs = { ...config.arguments };
delete nextArgs[key];
updateConfiguration(index, {
...config,
arguments: nextArgs,
});
}}
title="Delete argument"
>
<Trash2 className="h-4 w-4" />
</Button>
</div>
))}
| onCheckedChange={(value) => { | ||
| if (value === "indeterminate") return; | ||
| onChange( | ||
| setEnableFlag( | ||
| plugin, | ||
| flag, | ||
| value ? undefined : false | ||
| ) | ||
| ); | ||
| }} |
There was a problem hiding this comment.
When a checkbox is checked, passing undefined to setEnableFlag deletes the key from the plugin object. While this keeps the YAML clean for flags that default to true, it makes it impossible to explicitly enable any flag that defaults to false in Volcano.
To ensure correct behavior across all Volcano versions and allow explicit configuration, set the flag value to true when checked.
| onCheckedChange={(value) => { | |
| if (value === "indeterminate") return; | |
| onChange( | |
| setEnableFlag( | |
| plugin, | |
| flag, | |
| value ? undefined : false | |
| ) | |
| ); | |
| }} | |
| onCheckedChange={(value) => { | |
| if (value === "indeterminate") return; | |
| onChange( | |
| setEnableFlag( | |
| plugin, | |
| flag, | |
| value ? true : false | |
| ) | |
| ); | |
| }} |
| const handler = (event: BeforeUnloadEvent) => { | ||
| event.preventDefault(); | ||
| }; |
There was a problem hiding this comment.
In many modern browsers (such as Chrome and Firefox), calling event.preventDefault() alone is not sufficient to trigger the unsaved changes confirmation dialog on tab close or reload. Setting event.returnValue to an empty string is required for broad browser compatibility.
| const handler = (event: BeforeUnloadEvent) => { | |
| event.preventDefault(); | |
| }; | |
| const handler = (event: BeforeUnloadEvent) => { | |
| event.preventDefault(); | |
| event.returnValue = ""; | |
| }; |
| const { attributes, listeners, setNodeRef, transform, transition, isDragging } = | ||
| useSortable({ id: action }); |
There was a problem hiding this comment.
Using the action name as the @dnd-kit sortable id will cause drag-and-drop glitches or crashes if the pipeline contains duplicate actions (which is valid and supported in Volcano). Using the array index as the sortable id ensures uniqueness and correct drag-and-drop behavior.
| const { attributes, listeners, setNodeRef, transform, transition, isDragging } = | |
| useSortable({ id: action }); | |
| const { attributes, listeners, setNodeRef, transform, transition, isDragging } = | |
| useSortable({ id: index }); |
| const oldIndex = actions.indexOf(String(active.id)); | ||
| const newIndex = actions.indexOf(String(over.id)); | ||
| if (oldIndex === -1 || newIndex === -1) return; |
There was a problem hiding this comment.
Update handleDragEnd to retrieve indices directly from the active.id and over.id when using index-based sortable IDs.
| const oldIndex = actions.indexOf(String(active.id)); | |
| const newIndex = actions.indexOf(String(over.id)); | |
| if (oldIndex === -1 || newIndex === -1) return; | |
| const oldIndex = Number(active.id); | |
| const newIndex = Number(over.id); | |
| if (isNaN(oldIndex) || isNaN(newIndex)) return; |
| collisionDetection={closestCenter} | ||
| onDragEnd={handleDragEnd} | ||
| > | ||
| <SortableContext items={actions} strategy={verticalListSortingStrategy}> |
There was a problem hiding this comment.
| if (seenPlugins.has(plugin.name)) { | ||
| warnings.push(`Plugin "${plugin.name}" appears in multiple tiers`); | ||
| } | ||
| seenPlugins.add(plugin.name); |
There was a problem hiding this comment.
Duplicate plugin names within the same tier still produce "appears in multiple tiers", which is wrong and can hide a real misconfiguration.
| onChange={(e) => { | ||
| const raw = e.target.value; | ||
| const parsed = | ||
| field.type === "number" | ||
| ? raw === "" | ||
| ? undefined | ||
| : Number(raw) | ||
| : raw; | ||
| onChange( | ||
| setArgument( | ||
| plugin, | ||
| field.key, | ||
| parsed | ||
| ) | ||
| ); |
There was a problem hiding this comment.
Typing a half-finished number (like - or 5e) can get saved as NaN. The scheduler won’t treat that as a real number — so the setting may be ignored or break the config.
| import { z } from "zod"; | ||
| import { PLUGIN_ENABLE_FLAG_KEYS } from "./metadata"; | ||
|
|
||
| const argumentValueSchema = z.union([z.string(), z.number(), z.boolean()]); |
There was a problem hiding this comment.
| const argumentValueSchema = z.union([z.string(), z.number(), z.boolean()]); | |
| const argumentValueSchema = z.union([ | |
| z.string(), | |
| z.number().finite(), | |
| z.boolean(), | |
| ]); |
| for (const action of config.actions) { | ||
| if (!isKnownAction(action)) { | ||
| warnings.push( | ||
| `Action "${action}" is not in the built-in registry (custom action or different Volcano version?)` | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
A typo in an action name (like enqueu) only shows a warning, but save still works. Volcano then rejects that config and may stop reloading — scheduling can get stuck.
| onChange={(e) => { | ||
| const nextArgs: Record<string, typeof value> = {}; | ||
| for (const [k, v] of Object.entries(config.arguments)) { | ||
| if (k === key) { | ||
| nextArgs[e.target.value] = value; | ||
| } else { | ||
| nextArgs[k] = v; | ||
| } | ||
| } | ||
| updateConfiguration(index, { | ||
| ...config, | ||
| arguments: nextArgs, |
There was a problem hiding this comment.
If you rename an argument key to one that already exists, one of the two values disappears with no error - last one wins.
| onChange={(e) => { | |
| const nextArgs: Record<string, typeof value> = {}; | |
| for (const [k, v] of Object.entries(config.arguments)) { | |
| if (k === key) { | |
| nextArgs[e.target.value] = value; | |
| } else { | |
| nextArgs[k] = v; | |
| } | |
| } | |
| updateConfiguration(index, { | |
| ...config, | |
| arguments: nextArgs, | |
| onChange={(e) => { | |
| const newKey = e.target.value; | |
| if (newKey !== key && Object.prototype.hasOwnProperty.call(config.arguments, newKey)) { | |
| return; // or set an inline error — do not clobber | |
| } | |
| const nextArgs: Record<string, typeof value> = {}; | |
| for (const [k, v] of Object.entries(config.arguments)) { | |
| if (k === key) nextArgs[newKey] = value; | |
| else nextArgs[k] = v; | |
| } | |
| updateConfiguration(index, { ...config, arguments: nextArgs }); | |
| }} |
|
please fix the CI, and commits . |
Add scheduler ConfigMap API, validation, management page, and Chinese translations. Linearize history onto main to drop merge commits blocked by do-not-merge/contains-merge-commits. Signed-off-by: Shive <shiverse94@gmail.com>
fbd0e5d to
6121d1c
Compare
|
it’s fixed now. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: de6p The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
/schedulerdashboard page for editingvolcano-scheduler-configmapas structured scheduler policy.What changed
Test plan
npm run test --workspace packages/trpcnpx tsc --noEmit -p apps/web/tsconfig.jsonnpm run build --workspace apps/web