Adding new verbs and fleshing out the skeleton. Drain works while Kill has an error tha requires a deeper dive.
This commit is contained in:
parent
51ff20165e
commit
8e0988513a
7 changed files with 232 additions and 40 deletions
34
cmd/kill.go
34
cmd/kill.go
|
@ -2,12 +2,14 @@ package cmd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
realis "github.com/paypal/gorealis"
|
||||
"github.com/paypal/gorealis/gen-go/apache/aurora"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var env, role, name string
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(killCmd)
|
||||
killCmd.Flags().StringVarP(&env, "environment", "e", "", "Aurora Environment")
|
||||
|
@ -20,8 +22,28 @@ func init() {
|
|||
|
||||
var killCmd = &cobra.Command{
|
||||
Use: "kill",
|
||||
Short: "kill an Aurora Job",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("%s %s %s", env, role, name)
|
||||
},
|
||||
Short: "Kill an Aurora Job",
|
||||
Run: killJob,
|
||||
}
|
||||
|
||||
func killJob(cmd *cobra.Command, args []string) {
|
||||
log.Printf("Killing job [Env:%s Role:%s Name:%s]\n", env, role, name)
|
||||
|
||||
job := realis.NewJob().
|
||||
Environment(env).
|
||||
Role(role).
|
||||
Name(name)
|
||||
resp, err := client.KillJob(job.JobKey())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if resp.ResponseCode == aurora.ResponseCode_OK {
|
||||
if ok, err := monitor.Instances(job.JobKey(), 0, 5, 50); !ok || err != nil {
|
||||
log.Println("Unable to kill all instances of job")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
fmt.Println(resp.String())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue