-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: allow pausing and un-pausing of leader broker routine (#13045)
* core: allow pause/un-pause of eval broker on region leader. * agent: add ability to pause eval broker via scheduler config. * cli: add operator scheduler commands to interact with config. * api: add ability to pause eval broker via scheduler config * e2e: add operator scheduler test for eval broker pause. * docs: include new opertor scheduler CLI and pause eval API info.
- Loading branch information
Showing
32 changed files
with
1,388 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:improvement | ||
cli: Added `scheduler get-config` and `scheduler set-config` commands to the operator CLI | ||
``` | ||
|
||
```release-note:improvement | ||
core: Added the ability to pause and un-pause the eval broker and blocked eval broker | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package command | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/mitchellh/cli" | ||
) | ||
|
||
// Ensure OperatorSchedulerCommand satisfies the cli.Command interface. | ||
var _ cli.Command = &OperatorSchedulerCommand{} | ||
|
||
type OperatorSchedulerCommand struct { | ||
Meta | ||
} | ||
|
||
func (o *OperatorSchedulerCommand) Help() string { | ||
helpText := ` | ||
Usage: nomad operator scheduler <subcommand> [options] | ||
This command groups subcommands for interacting with Nomad's scheduler | ||
subsystem. | ||
Get the scheduler configuration: | ||
$ nomad operator scheduler get-config | ||
Set the scheduler to use the spread algorithm: | ||
$ nomad operator scheduler set-config -scheduler-algorithm=spread | ||
Please see the individual subcommand help for detailed usage information. | ||
` | ||
return strings.TrimSpace(helpText) | ||
} | ||
|
||
func (o *OperatorSchedulerCommand) Synopsis() string { | ||
return "Provides access to the scheduler configuration" | ||
} | ||
|
||
func (o *OperatorSchedulerCommand) Name() string { return "operator scheduler" } | ||
|
||
func (o *OperatorSchedulerCommand) Run(_ []string) int { return cli.RunResultHelp } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/mitchellh/cli" | ||
"github.com/posener/complete" | ||
) | ||
|
||
// Ensure OperatorSchedulerGetConfig satisfies the cli.Command interface. | ||
var _ cli.Command = &OperatorSchedulerGetConfig{} | ||
|
||
type OperatorSchedulerGetConfig struct { | ||
Meta | ||
|
||
json bool | ||
tmpl string | ||
} | ||
|
||
func (o *OperatorSchedulerGetConfig) AutocompleteFlags() complete.Flags { | ||
return mergeAutocompleteFlags(o.Meta.AutocompleteFlags(FlagSetClient), | ||
complete.Flags{ | ||
"-json": complete.PredictNothing, | ||
"-t": complete.PredictAnything, | ||
}, | ||
) | ||
} | ||
|
||
func (o *OperatorSchedulerGetConfig) AutocompleteArgs() complete.Predictor { | ||
return complete.PredictNothing | ||
} | ||
|
||
func (o *OperatorSchedulerGetConfig) Name() string { return "operator scheduler get-config" } | ||
|
||
func (o *OperatorSchedulerGetConfig) Run(args []string) int { | ||
|
||
flags := o.Meta.FlagSet("get-config", FlagSetClient) | ||
flags.BoolVar(&o.json, "json", false, "") | ||
flags.StringVar(&o.tmpl, "t", "", "") | ||
flags.Usage = func() { o.Ui.Output(o.Help()) } | ||
|
||
if err := flags.Parse(args); err != nil { | ||
return 1 | ||
} | ||
|
||
// Set up a client. | ||
client, err := o.Meta.Client() | ||
if err != nil { | ||
o.Ui.Error(fmt.Sprintf("Error initializing client: %s", err)) | ||
return 1 | ||
} | ||
|
||
// Fetch the current configuration. | ||
resp, _, err := client.Operator().SchedulerGetConfiguration(nil) | ||
if err != nil { | ||
o.Ui.Error(fmt.Sprintf("Error querying scheduler configuration: %s", err)) | ||
return 1 | ||
} | ||
|
||
// If the user has specified to output the scheduler config as JSON or | ||
// using a template, perform this action for the entire object and exit the | ||
// command. | ||
if o.json || len(o.tmpl) > 0 { | ||
out, err := Format(o.json, o.tmpl, resp) | ||
if err != nil { | ||
o.Ui.Error(err.Error()) | ||
return 1 | ||
} | ||
o.Ui.Output(out) | ||
return 0 | ||
} | ||
|
||
schedConfig := resp.SchedulerConfig | ||
|
||
// Output the information. | ||
o.Ui.Output(formatKV([]string{ | ||
fmt.Sprintf("Scheduler Algorithm|%s", schedConfig.SchedulerAlgorithm), | ||
fmt.Sprintf("Memory Oversubscription|%v", schedConfig.MemoryOversubscriptionEnabled), | ||
fmt.Sprintf("Reject Job Registration|%v", schedConfig.RejectJobRegistration), | ||
fmt.Sprintf("Pause Eval Broker|%v", schedConfig.PauseEvalBroker), | ||
fmt.Sprintf("Preemption System Scheduler|%v", schedConfig.PreemptionConfig.SystemSchedulerEnabled), | ||
fmt.Sprintf("Preemption Service Scheduler|%v", schedConfig.PreemptionConfig.ServiceSchedulerEnabled), | ||
fmt.Sprintf("Preemption Batch Scheduler|%v", schedConfig.PreemptionConfig.BatchSchedulerEnabled), | ||
fmt.Sprintf("Preemption SysBatch Scheduler|%v", schedConfig.PreemptionConfig.SysBatchSchedulerEnabled), | ||
fmt.Sprintf("Modify Index|%v", resp.SchedulerConfig.ModifyIndex), | ||
})) | ||
return 0 | ||
} | ||
|
||
func (o *OperatorSchedulerGetConfig) Synopsis() string { | ||
return "Display the current scheduler configuration" | ||
} | ||
|
||
func (o *OperatorSchedulerGetConfig) Help() string { | ||
helpText := ` | ||
Usage: nomad operator scheduler get-config [options] | ||
Displays the current scheduler configuration. | ||
If ACLs are enabled, this command requires a token with the 'operator:read' | ||
capability. | ||
General Options: | ||
` + generalOptionsUsage(usageOptsDefault|usageOptsNoNamespace) + ` | ||
Scheduler Get Config Options: | ||
-json | ||
Output the scheduler config in its JSON format. | ||
-t | ||
Format and display the scheduler config using a Go template. | ||
` | ||
|
||
return strings.TrimSpace(helpText) | ||
} |
Oops, something went wrong.