Skip to content

Commit 2781e4e

Browse files
authored
Merge pull request #956 from ffd2subroutine/qps-burst-configurable
Added qps and burst to server's client
2 parents 449cac5 + e5556fe commit 2781e4e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pkg/cmd/server/server.go

+19
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ const (
7575

7676
defaultBackupSyncPeriod = time.Minute
7777
defaultPodVolumeOperationTimeout = 60 * time.Minute
78+
79+
// server's client default qps and burst
80+
defaultClientQPS float32 = 20.0
81+
defaultClientBurst int = 30
7882
)
7983

8084
type serverConfig struct {
@@ -83,6 +87,8 @@ type serverConfig struct {
8387
restoreResourcePriorities []string
8488
defaultVolumeSnapshotLocations map[string]string
8589
restoreOnly bool
90+
clientQPS float32
91+
clientBurst int
8692
}
8793

8894
func NewCommand() *cobra.Command {
@@ -97,6 +103,8 @@ func NewCommand() *cobra.Command {
97103
backupSyncPeriod: defaultBackupSyncPeriod,
98104
podVolumeOperationTimeout: defaultPodVolumeOperationTimeout,
99105
restoreResourcePriorities: defaultRestorePriorities,
106+
clientQPS: defaultClientQPS,
107+
clientBurst: defaultClientBurst,
100108
}
101109
)
102110

@@ -152,6 +160,8 @@ func NewCommand() *cobra.Command {
152160
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")
153161
command.Flags().StringVar(&config.defaultBackupLocation, "default-backup-storage-location", config.defaultBackupLocation, "name of the default backup storage location")
154162
command.Flags().Var(&volumeSnapshotLocations, "default-volume-snapshot-locations", "list of unique volume providers and default volume snapshot location (provider1:location-01,provider2:location-02,...)")
163+
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")
164+
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")
155165

156166
return command
157167
}
@@ -196,6 +206,15 @@ func newServer(namespace, baseName string, config serverConfig, logger *logrus.L
196206
if err != nil {
197207
return nil, err
198208
}
209+
if config.clientQPS < 0.0 {
210+
return nil, errors.New("client-qps must be positive")
211+
}
212+
clientConfig.QPS = config.clientQPS
213+
214+
if config.clientBurst <= 0 {
215+
return nil, errors.New("client-burst must be positive")
216+
}
217+
clientConfig.Burst = config.clientBurst
199218

200219
kubeClient, err := kubernetes.NewForConfig(clientConfig)
201220
if err != nil {

0 commit comments

Comments
 (0)