Skip to content

Commit

Permalink
Added qps and burst to server's client
Browse files Browse the repository at this point in the history
Signed-off-by: Darko Radisic <ffd2subroutine@users.noreply.github.com>
  • Loading branch information
ffd2subroutine committed Nov 9, 2018
1 parent fe19863 commit e5556fe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const (

defaultBackupSyncPeriod = time.Minute
defaultPodVolumeOperationTimeout = 60 * time.Minute

// server's client default qps and burst
defaultClientQPS float32 = 20.0
defaultClientBurst int = 30
)

type serverConfig struct {
Expand All @@ -84,6 +88,8 @@ type serverConfig struct {
restoreResourcePriorities []string
defaultVolumeSnapshotLocations map[string]string
restoreOnly bool
clientQPS float32
clientBurst int
}

func NewCommand() *cobra.Command {
Expand All @@ -98,6 +104,8 @@ func NewCommand() *cobra.Command {
backupSyncPeriod: defaultBackupSyncPeriod,
podVolumeOperationTimeout: defaultPodVolumeOperationTimeout,
restoreResourcePriorities: defaultRestorePriorities,
clientQPS: defaultClientQPS,
clientBurst: defaultClientBurst,
}
)

Expand Down Expand Up @@ -153,6 +161,8 @@ func NewCommand() *cobra.Command {
command.Flags().StringSliceVar(&config.restoreResourcePriorities, "restore-resource-priorities", config.restoreResourcePriorities, "desired order of resource restores; any resource not in the list will be restored alphabetically after the prioritized resources")
command.Flags().StringVar(&config.defaultBackupLocation, "default-backup-storage-location", config.defaultBackupLocation, "name of the default backup storage location")
command.Flags().Var(&volumeSnapshotLocations, "default-volume-snapshot-locations", "list of unique volume providers and default volume snapshot location (provider1:location-01,provider2:location-02,...)")
command.Flags().Float32Var(&config.clientQPS, "client-qps", config.clientQPS, "maximum number of requests per second by the server to the Kubernetes API once the burst limit has been reached")
command.Flags().IntVar(&config.clientBurst, "client-burst", config.clientBurst, "maximum number of requests by the server to the Kubernetes API in a short period of time")

return command
}
Expand Down Expand Up @@ -197,6 +207,15 @@ func newServer(namespace, baseName string, config serverConfig, logger *logrus.L
if err != nil {
return nil, err
}
if config.clientQPS < 0.0 {
return nil, errors.New("client-qps must be positive")
}
clientConfig.QPS = config.clientQPS

if config.clientBurst <= 0 {
return nil, errors.New("client-burst must be positive")
}
clientConfig.Burst = config.clientBurst

kubeClient, err := kubernetes.NewForConfig(clientConfig)
if err != nil {
Expand Down

0 comments on commit e5556fe

Please sign in to comment.