fix: use correct JSON Patch add/remove/replace ops in updateQueue - #367
abhishekKokadwar wants to merge 1 commit into
Conversation
updateQueue built every patch operation as op:"replace", regardless of whether the target field currently exists on the live queue. Per RFC 6902, "replace" requires the target path to already exist, so adding a spec field (e.g. guarantee) to a queue that never had one previously caused the k8s API server to reject the whole patch, even though client-side validation had already passed. Separately, fields the user cleared in the edit form (making them absent from the submitted spec) generated no patch operation at all, so they silently remained on the live queue - the UI implied the field was removed but the API left it untouched. This fixes both by diffing the current queue spec against the submitted spec: fields new to the spec use "add", fields present in both use "replace", and fields dropped from the submitted spec use "remove". The existing getClusterCustomObject call (previously used only to check the queue exists) is reused to fetch the current spec, avoiding an extra API round trip. Note: in the queue edit form's Form mode, only weight/priority/ reclaimable/guarantee/capability/deserved are represented, so a spec field set outside that set (e.g. via a prior raw YAML edit) would be treated as removed if the queue is later saved via Form mode. YAML mode is unaffected since it round-trips the full spec. This matches the set of fields Volcano queues are documented to support and is a pre-existing gap in the form's field coverage, not something this patch-semantics fix introduces. Signed-off-by: Abhishek <abhikokadwar2@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
C:/Program Files/Git/assign @JesseStutler Hi JesseStutler, this has been open a few days with green CI and DCO signed — would appreciate a review when you have a chance. Happy to make any changes needed. |
|
Note: my earlier /assign comment on this PR was mangled by a local shell path-expansion issue and didn't register as a real command — apologies for the noise. This is still open after ~3 weeks with green CI and DCO signed. Would appreciate a review whenever you have bandwidth. |
Summary
Fixes #366
updateQueuebuilt every JSON Patch operation asop: "replace", regardless of whether the target field currently exists on the live queue. This caused two distinct problems:replacerequires the target path to already exist. Adding a spec field (e.g.guarantee) to a queue that never had one previously caused the Kubernetes API server to reject the whole patch, even though client-side validation had already passed.buildSpecFromForminqueue-form-shared.tsx), so no patch operation was generated for them at all — they silently remained on the live queue, contradicting what the UI implied happened.Fix
Diff the current live queue spec against the submitted spec:
op: "add"op: "replace"op: "remove"The existing
getClusterCustomObjectcall (previously used only to check the queue exists before patching) is reused to fetch the current spec, so this doesn't add an extra API round trip.A caveat worth flagging
The queue edit form's Form mode only represents
weight/priority/reclaimable/guarantee/capability/deserved. If a queue had some other spec field set outside that set (e.g. via a prior raw YAML edit), saving via Form mode after this fix would now treat that field as removed, since it would be absent from the submitted spec. YAML mode is unaffected since it round-trips the full spec object. I believe this is an acceptable, narrow edge case — arguably it's already broken today in a different way, since Form mode has never had any way to preserve or edit such a field — but flagging it explicitly rather than leaving it implicit. Happy to add a guard if maintainers would prefer one.Test plan
npx tsc --noEmit— no type errorsnpm run lint— no new warnings introducednpm run build— succeeds,/api/trpc/[trpc]route compiles cleanqueue-edit-dialog.tsxguarantee, add one via edit; clear a field and confirm removal viakubectl get queue -o yaml), but the test machine's available memory wasn't sufficient to run kind + Volcano's controllers reliably, and I didn't want to submit a false claim of live verification. If a maintainer can confirm this against a real cluster, or would like me to attempt it again with more resources, I'm happy to follow up.Diff is scoped to the single affected mutation (23 insertions, 3 deletions).