goimports style fixes.
This commit is contained in:
parent
4551231644
commit
616d4bc57e
9 changed files with 125 additions and 131 deletions
10
cmd/fetch.go
10
cmd/fetch.go
|
@ -3,7 +3,7 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/paypal/gorealis/v2"
|
realis "github.com/paypal/gorealis/v2"
|
||||||
"github.com/paypal/gorealis/v2/gen-go/apache/aurora"
|
"github.com/paypal/gorealis/v2/gen-go/apache/aurora"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
@ -29,7 +29,6 @@ func init() {
|
||||||
taskStatusCmd.Flags().StringVarP(role, "role", "r", "", "Aurora Role")
|
taskStatusCmd.Flags().StringVarP(role, "role", "r", "", "Aurora Role")
|
||||||
taskStatusCmd.Flags().StringVarP(name, "name", "n", "", "Aurora Name")
|
taskStatusCmd.Flags().StringVarP(name, "name", "n", "", "Aurora Name")
|
||||||
|
|
||||||
|
|
||||||
/* Fetch Leader */
|
/* Fetch Leader */
|
||||||
leaderCmd.Flags().String("zkPath", "/aurora/scheduler", "Zookeeper node path where leader election happens")
|
leaderCmd.Flags().String("zkPath", "/aurora/scheduler", "Zookeeper node path where leader election happens")
|
||||||
|
|
||||||
|
@ -37,9 +36,9 @@ func init() {
|
||||||
|
|
||||||
// Hijack help function to hide unnecessary global flags
|
// Hijack help function to hide unnecessary global flags
|
||||||
help := leaderCmd.HelpFunc()
|
help := leaderCmd.HelpFunc()
|
||||||
leaderCmd.SetHelpFunc(func(cmd *cobra.Command, s []string){
|
leaderCmd.SetHelpFunc(func(cmd *cobra.Command, s []string) {
|
||||||
if cmd.HasInheritedFlags(){
|
if cmd.HasInheritedFlags() {
|
||||||
cmd.InheritedFlags().VisitAll(func(f *pflag.Flag){
|
cmd.InheritedFlags().VisitAll(func(f *pflag.Flag) {
|
||||||
if f.Name != "logLevel" {
|
if f.Name != "logLevel" {
|
||||||
f.Hidden = true
|
f.Hidden = true
|
||||||
}
|
}
|
||||||
|
@ -66,7 +65,6 @@ var fetchTaskCmd = &cobra.Command{
|
||||||
Short: "Task information from Aurora",
|
Short: "Task information from Aurora",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var taskConfigCmd = &cobra.Command{
|
var taskConfigCmd = &cobra.Command{
|
||||||
Use: "config",
|
Use: "config",
|
||||||
Short: "Fetch a list of task configurations from Aurora.",
|
Short: "Fetch a list of task configurations from Aurora.",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/paypal/gorealis/v2"
|
realis "github.com/paypal/gorealis/v2"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -49,4 +49,3 @@ func rollbackUpdate(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
fmt.Printf("Rollback update for update ID %v sent successfully\n", updateID)
|
fmt.Printf("Rollback update for update ID %v sent successfully\n", updateID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
cmd/root.go
10
cmd/root.go
|
@ -1,11 +1,12 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/paypal/gorealis/v2"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
|
realis "github.com/paypal/gorealis/v2"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -48,7 +49,7 @@ func init() {
|
||||||
rootCmd.PersistentFlags().BoolVarP(&skipCertVerification, "skipCertVerification", "i", false, "Skip CA certificate hostname verification.")
|
rootCmd.PersistentFlags().BoolVarP(&skipCertVerification, "skipCertVerification", "i", false, "Skip CA certificate hostname verification.")
|
||||||
rootCmd.PersistentFlags().StringVar(&configFile, "config", "/etc/aurora/australis.yml", "Config file to use.")
|
rootCmd.PersistentFlags().StringVar(&configFile, "config", "/etc/aurora/australis.yml", "Config file to use.")
|
||||||
rootCmd.PersistentFlags().BoolVar(&toJson, "toJSON", false, "Print output in JSON format.")
|
rootCmd.PersistentFlags().BoolVar(&toJson, "toJSON", false, "Print output in JSON format.")
|
||||||
rootCmd.PersistentFlags().StringVarP(&logLevel, "logLevel", "l", "info", "Set logging level [" + getLoggingLevels() + "].")
|
rootCmd.PersistentFlags().StringVarP(&logLevel, "logLevel", "l", "info", "Set logging level ["+getLoggingLevels()+"].")
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
|
@ -81,7 +82,6 @@ func setConfig(cmd *cobra.Command, args []string) {
|
||||||
func connect(cmd *cobra.Command, args []string) {
|
func connect(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
||||||
setConfig(cmd, args)
|
setConfig(cmd, args)
|
||||||
|
|
||||||
zkAddrSlice := strings.Split(zkAddr, ",")
|
zkAddrSlice := strings.Split(zkAddr, ",")
|
||||||
|
@ -133,7 +133,7 @@ func connect(cmd *cobra.Command, args []string) {
|
||||||
// Prefer zookeeper if both ways of connecting are provided
|
// Prefer zookeeper if both ways of connecting are provided
|
||||||
if len(zkAddrSlice) > 0 && zkAddrSlice[0] != "" {
|
if len(zkAddrSlice) > 0 && zkAddrSlice[0] != "" {
|
||||||
// Configure Zookeeper to connect
|
// Configure Zookeeper to connect
|
||||||
zkOptions := []realis.ZKOpt{ realis.ZKEndpoints(zkAddrSlice...), realis.ZKPath("/aurora/scheduler")}
|
zkOptions := []realis.ZKOpt{realis.ZKEndpoints(zkAddrSlice...), realis.ZKPath("/aurora/scheduler")}
|
||||||
realisOptions = append(realisOptions, realis.ZookeeperOptions(zkOptions...))
|
realisOptions = append(realisOptions, realis.ZookeeperOptions(zkOptions...))
|
||||||
} else if schedAddr != "" {
|
} else if schedAddr != "" {
|
||||||
realisOptions = append(realisOptions, realis.SchedulerUrl(schedAddr))
|
realisOptions = append(realisOptions, realis.SchedulerUrl(schedAddr))
|
||||||
|
|
|
@ -2,10 +2,11 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -32,7 +33,7 @@ var setQuotaCmd = &cobra.Command{
|
||||||
|
|
||||||
*role = args[0]
|
*role = args[0]
|
||||||
|
|
||||||
for i:=1; i < len(args); i++ {
|
for i := 1; i < len(args); i++ {
|
||||||
resourcePair := strings.Split(args[i], ":")
|
resourcePair := strings.Split(args[i], ":")
|
||||||
|
|
||||||
if len(resourcePair) != 2 {
|
if len(resourcePair) != 2 {
|
||||||
|
|
26
cmd/start.go
26
cmd/start.go
|
@ -1,47 +1,46 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/paypal/gorealis/v2/gen-go/apache/aurora"
|
"github.com/paypal/gorealis/v2/gen-go/apache/aurora"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(startCmd)
|
rootCmd.AddCommand(startCmd)
|
||||||
|
|
||||||
|
|
||||||
// Sub-commands
|
// Sub-commands
|
||||||
startCmd.AddCommand(startDrainCmd)
|
startCmd.AddCommand(startDrainCmd)
|
||||||
|
|
||||||
// Maintenance specific flags
|
// Maintenance specific flags
|
||||||
startDrainCmd.Flags().DurationVar(&monitorInterval,"interval", time.Second * 5, "Interval at which to poll scheduler.")
|
startDrainCmd.Flags().DurationVar(&monitorInterval, "interval", time.Second*5, "Interval at which to poll scheduler.")
|
||||||
startDrainCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 10, "Time after which the monitor will stop polling and throw an error.")
|
startDrainCmd.Flags().DurationVar(&monitorTimeout, "timeout", time.Minute*10, "Time after which the monitor will stop polling and throw an error.")
|
||||||
|
|
||||||
startCmd.AddCommand(startSLADrainCmd)
|
startCmd.AddCommand(startSLADrainCmd)
|
||||||
|
|
||||||
|
|
||||||
/* SLA Aware commands */
|
/* SLA Aware commands */
|
||||||
startSLADrainCmd.AddCommand(startSLACountDrainCmd)
|
startSLADrainCmd.AddCommand(startSLACountDrainCmd)
|
||||||
|
|
||||||
// SLA Maintenance specific flags
|
// SLA Maintenance specific flags
|
||||||
startSLACountDrainCmd.Flags().DurationVar(&monitorInterval,"interval", time.Second * 5, "Interval at which to poll scheduler.")
|
startSLACountDrainCmd.Flags().DurationVar(&monitorInterval, "interval", time.Second*5, "Interval at which to poll scheduler.")
|
||||||
startSLACountDrainCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 20, "Time after which the monitor will stop polling and throw an error.")
|
startSLACountDrainCmd.Flags().DurationVar(&monitorTimeout, "timeout", time.Minute*20, "Time after which the monitor will stop polling and throw an error.")
|
||||||
startSLACountDrainCmd.Flags().Int64Var(&count, "count", 5, "Instances count that should be running to meet SLA.")
|
startSLACountDrainCmd.Flags().Int64Var(&count, "count", 5, "Instances count that should be running to meet SLA.")
|
||||||
startSLACountDrainCmd.Flags().DurationVar(&duration, "duration", time.Minute * 10, "Window of time from which we derive the SLA.")
|
startSLACountDrainCmd.Flags().DurationVar(&duration, "duration", time.Minute*10, "Window of time from which we derive the SLA.")
|
||||||
|
|
||||||
startSLADrainCmd.AddCommand(startSLAPercentageDrainCmd)
|
startSLADrainCmd.AddCommand(startSLAPercentageDrainCmd)
|
||||||
|
|
||||||
// SLA Maintenance specific flags
|
// SLA Maintenance specific flags
|
||||||
startSLAPercentageDrainCmd.Flags().DurationVar(&monitorInterval,"interval", time.Second * 5, "Interval at which to poll scheduler.")
|
startSLAPercentageDrainCmd.Flags().DurationVar(&monitorInterval, "interval", time.Second*5, "Interval at which to poll scheduler.")
|
||||||
startSLAPercentageDrainCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 1, "Time after which the monitor will stop polling and throw an error.")
|
startSLAPercentageDrainCmd.Flags().DurationVar(&monitorTimeout, "timeout", time.Minute*1, "Time after which the monitor will stop polling and throw an error.")
|
||||||
startSLAPercentageDrainCmd.Flags().Float64Var(&percent, "percent", 75.0, "Percentage of instances that should be running to meet SLA.")
|
startSLAPercentageDrainCmd.Flags().Float64Var(&percent, "percent", 75.0, "Percentage of instances that should be running to meet SLA.")
|
||||||
startSLAPercentageDrainCmd.Flags().DurationVar(&duration, "duration", time.Minute * 10, "Window of time from which we derive the SLA.")
|
startSLAPercentageDrainCmd.Flags().DurationVar(&duration, "duration", time.Minute*10, "Window of time from which we derive the SLA.")
|
||||||
|
|
||||||
startCmd.AddCommand(startMaintenanceCmd)
|
startCmd.AddCommand(startMaintenanceCmd)
|
||||||
|
|
||||||
// SLA Maintenance specific flags
|
// SLA Maintenance specific flags
|
||||||
startMaintenanceCmd.Flags().DurationVar(&monitorInterval,"interval", time.Second * 5, "Interval at which to poll scheduler.")
|
startMaintenanceCmd.Flags().DurationVar(&monitorInterval, "interval", time.Second*5, "Interval at which to poll scheduler.")
|
||||||
startMaintenanceCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 10, "Time after which the monitor will stop polling and throw an error.")
|
startMaintenanceCmd.Flags().DurationVar(&monitorTimeout, "timeout", time.Minute*10, "Time after which the monitor will stop polling and throw an error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
var startCmd = &cobra.Command{
|
var startCmd = &cobra.Command{
|
||||||
|
@ -179,7 +178,6 @@ func maintenance(cmd *cobra.Command, args []string) {
|
||||||
monitorInterval,
|
monitorInterval,
|
||||||
monitorTimeout)
|
monitorTimeout)
|
||||||
|
|
||||||
|
|
||||||
maintenanceMonitorPrint(hostResult, []aurora.MaintenanceMode{aurora.MaintenanceMode_SCHEDULED})
|
maintenanceMonitorPrint(hostResult, []aurora.MaintenanceMode{aurora.MaintenanceMode_SCHEDULED})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -12,8 +12,8 @@ func init() {
|
||||||
|
|
||||||
// Stop subcommands
|
// Stop subcommands
|
||||||
stopCmd.AddCommand(stopMaintCmd)
|
stopCmd.AddCommand(stopMaintCmd)
|
||||||
stopMaintCmd.Flags().DurationVar(&monitorInterval,"interval", time.Second * 5, "Interval at which to poll scheduler.")
|
stopMaintCmd.Flags().DurationVar(&monitorInterval, "interval", time.Second*5, "Interval at which to poll scheduler.")
|
||||||
stopMaintCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 1, "Time after which the monitor will stop polling and throw an error.")
|
stopMaintCmd.Flags().DurationVar(&monitorTimeout, "timeout", time.Minute*1, "Time after which the monitor will stop polling and throw an error.")
|
||||||
|
|
||||||
// Stop update
|
// Stop update
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ func endMaintenance(cmd *cobra.Command, args []string) {
|
||||||
monitorInterval,
|
monitorInterval,
|
||||||
monitorTimeout)
|
monitorTimeout)
|
||||||
|
|
||||||
maintenanceMonitorPrint(hostResult,[]aurora.MaintenanceMode{aurora.MaintenanceMode_NONE})
|
maintenanceMonitorPrint(hostResult, []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("error: %+v", err)
|
log.Fatalln("error: %+v", err)
|
||||||
|
|
|
@ -20,7 +20,6 @@ func toJSON(v interface{}) string {
|
||||||
return string(output)
|
return string(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getLoggingLevels() string {
|
func getLoggingLevels() string {
|
||||||
|
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
@ -30,17 +29,16 @@ func getLoggingLevels() string {
|
||||||
buffer.WriteString(" ")
|
buffer.WriteString(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.Truncate(buffer.Len()-1)
|
buffer.Truncate(buffer.Len() - 1)
|
||||||
|
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func maintenanceMonitorPrint(hostResult map[string]bool, desiredStates []aurora.MaintenanceMode) {
|
func maintenanceMonitorPrint(hostResult map[string]bool, desiredStates []aurora.MaintenanceMode) {
|
||||||
if len(hostResult) > 0 {
|
if len(hostResult) > 0 {
|
||||||
// Create anonymous struct for JSON formatting
|
// Create anonymous struct for JSON formatting
|
||||||
output := struct{
|
output := struct {
|
||||||
DesiredStates []string `json:desired_states`
|
DesiredStates []string `json:desired_states`
|
||||||
Transitioned []string `json:transitioned`
|
Transitioned []string `json:transitioned`
|
||||||
NonTransitioned []string `json:non-transitioned`
|
NonTransitioned []string `json:non-transitioned`
|
||||||
|
@ -50,7 +48,7 @@ func maintenanceMonitorPrint(hostResult map[string]bool, desiredStates []aurora.
|
||||||
make([]string, 0),
|
make([]string, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _,state := range desiredStates {
|
for _, state := range desiredStates {
|
||||||
output.DesiredStates = append(output.DesiredStates, state.String())
|
output.DesiredStates = append(output.DesiredStates, state.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue