Adding ability to start an update (#12)
* Adding ability to start an update. * Refactoring Job parsing code to be re-usable.
This commit is contained in:
parent
d7db155d88
commit
4806936c71
6 changed files with 173 additions and 78 deletions
22
cmd/start.go
22
cmd/start.go
|
@ -230,7 +230,7 @@ func slaDrain(cmd *cobra.Command, args []string) {
|
|||
if cmd.Flags().Changed(percentageFlag) {
|
||||
log.Infoln("Setting hosts to DRAINING with the Percentage SLA policy.")
|
||||
policy.PercentageSlaPolicy = &aurora.PercentageSlaPolicy{
|
||||
Percentage: percent,
|
||||
Percentage: percent,
|
||||
DurationSecs: int64(duration.Seconds()),
|
||||
}
|
||||
}
|
||||
|
@ -273,5 +273,25 @@ func maintenance(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
func update(cmd *cobra.Command, args []string) {
|
||||
updateJob, err := internal.UnmarshalUpdate(args[0])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
update, err := updateJob.ToRealis()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
result, err := client.StartJobUpdate(update, "")
|
||||
if err != nil {
|
||||
log.Fatalf("Update failed to start %v", err)
|
||||
}
|
||||
|
||||
if ok, monitorErr := client.MonitorJobUpdate(*result.GetKey(),
|
||||
startUpdateCmd.MonitorInterval,
|
||||
startUpdateCmd.MonitorTimeout); !ok || monitorErr != nil {
|
||||
log.Fatal("update did not ROLL FORWARD before monitor timed out")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue