Include all priority classes option for cancellation and preemption#4717
Include all priority classes option for cancellation and preemption#4717nikola-jokic merged 3 commits intomasterfrom
Conversation
d64bd45 to
c64d1e1
Compare
bbd7e4a to
1038492
Compare
| PreRunE: func(cmd *cobra.Command, args []string) error { | ||
| if err := cmd.MarkFlagRequired("priority-classes"); err != nil { | ||
| return fmt.Errorf("error marking priority-class flag as required: %s", err) | ||
| all, err := cmd.Flags().GetBool("all-priority-classes") |
There was a problem hiding this comment.
I am thinking should we extract all-priority-classes into a const as it is repeated 30 times
| if !all { | ||
| if err := cmd.MarkFlagRequired("priority-classes"); err != nil { | ||
| return fmt.Errorf("error marking priority-class flag as required: %s", err) | ||
| } |
There was a problem hiding this comment.
Actually, the block from L77-L84 is repeated, might be worthwhile to extract it into a function and reuse in 12 places
Greptile SummaryThis PR enhances the Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User runs cancel/preempt command] --> B{--all-priority-classes set?}
B -- Yes --> C[priorityClasses = nil]
B -- No --> D{--priority-classes provided?}
D -- No --> E[Error: priority-classes required]
D -- Yes --> F[priorityClasses = provided values]
C --> G[Call App.CancelOn* / PreemptOn*]
F --> G
G --> H{len priorityClasses > 0?}
H -- No --> I[Log: priority-classes = 'all'\nSkip DB filter → all jobs selected]
H -- Yes --> J[Log: priority-classes = values\nfilterJobsByPriorityClasses]
I --> K[MarkJobsCancelRequested / MarkJobRunsPreemptRequested]
J --> K
|
| "all-priority-classes", | ||
| "a", | ||
| false, | ||
| "Preempt jobs on executor for all priority classes.", |
There was a problem hiding this comment.
Wrong verb in flag description for cancel commands
The --all-priority-classes flag description says "Preempt jobs on executor for all priority classes." but this is a cancel command — the description was copied from the preempt command. This appears in all three cancel subcommands: cancelExecutorCmd (here), cancelNodeCmd (line ~195), and cancelQueueCmd (in the queue block). The description should say "Cancel" rather than "Preempt", and the mention of "executor" is also wrong for cancelNodeCmd and cancelQueueCmd.
| "Preempt jobs on executor for all priority classes.", | |
| "Cancel jobs on executor for all priority classes.", |
| "all-priority-classes", | ||
| "a", | ||
| false, | ||
| "Preempt jobs in all priority classes. Cannot be used with the priority-classes flag.", |
There was a problem hiding this comment.
Flag description claims mutual exclusion that is not enforced
The description says "Cannot be used with the priority-classes flag." but there is no enforcement of this constraint in PreRunE or RunE. If a user provides both --all-priority-classes and --priority-classes, all-priority-classes silently wins (sets priorityClasses = nil). Either add a validation check like:
if allPriorityClasses && len(priorityClasses) > 0 {
return fmt.Errorf("--all-priority-classes and --priority-classes are mutually exclusive")
}Or update the description to reflect the actual behaviour (e.g., "When set, overrides the --priority-classes flag and targets all priority classes.").
…4717) <!-- Thanks for sending a pull request! Here are some tips for you: --> #### What type of PR is this? Enhancement #### What this PR does / why we need it Allow users to preempt/cancel jobs on all priority classes Signed-off-by: Nikola Jokic <jokicnikola07@gmail.com>
…4717) <!-- Thanks for sending a pull request! Here are some tips for you: --> #### What type of PR is this? Enhancement #### What this PR does / why we need it Allow users to preempt/cancel jobs on all priority classes Signed-off-by: Nikola Jokic <jokicnikola07@gmail.com>
What type of PR is this?
Enhancement
What this PR does / why we need it
Allow users to preempt/cancel jobs on all priority classes