From e5556fe60882789bfe7c06198fb514d73f23fa6a Mon Sep 17 00:00:00 2001 From: Darko Radisic Date: Thu, 18 Oct 2018 19:45:24 +0200 Subject: [PATCH] Added qps and burst to server's client Signed-off-by: Darko Radisic --- pkg/cmd/server/server.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/cmd/server/server.go b/pkg/cmd/server/server.go index 809bd2ad81..9eca52fbde 100644 --- a/pkg/cmd/server/server.go +++ b/pkg/cmd/server/server.go @@ -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 { @@ -84,6 +88,8 @@ type serverConfig struct { restoreResourcePriorities []string defaultVolumeSnapshotLocations map[string]string restoreOnly bool + clientQPS float32 + clientBurst int } func NewCommand() *cobra.Command { @@ -98,6 +104,8 @@ func NewCommand() *cobra.Command { backupSyncPeriod: defaultBackupSyncPeriod, podVolumeOperationTimeout: defaultPodVolumeOperationTimeout, restoreResourcePriorities: defaultRestorePriorities, + clientQPS: defaultClientQPS, + clientBurst: defaultClientBurst, } ) @@ -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 } @@ -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 {