Skip to content

Commit c903c2c

Browse files
committed
feat: make kube-api-qps configurable
fix
1 parent e49979f commit c903c2c

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

pkg/blob/azure.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func IsAzureStackCloud(cloud *azure.Cloud) bool {
5151
}
5252

5353
// getCloudProvider get Azure Cloud Provider
54-
func getCloudProvider(kubeconfig, nodeID, secretName, secretNamespace, userAgent string, allowEmptyCloudConfig bool) (*azure.Cloud, error) {
54+
func getCloudProvider(kubeconfig, nodeID, secretName, secretNamespace, userAgent string, allowEmptyCloudConfig bool, kubeAPIQPS float64, kubeAPIBurst int) (*azure.Cloud, error) {
5555
var (
5656
config *azure.Config
5757
kubeClient *clientset.Clientset
@@ -70,10 +70,10 @@ func getCloudProvider(kubeconfig, nodeID, secretName, secretNamespace, userAgent
7070
kubeCfg, err := getKubeConfig(kubeconfig)
7171
if err == nil && kubeCfg != nil {
7272
// set QPS and QPS Burst as higher values
73-
kubeCfg.QPS = 25
74-
kubeCfg.Burst = 50
75-
kubeClient, err = clientset.NewForConfig(kubeCfg)
76-
if err != nil {
73+
klog.V(2).Infof("set QPS(%f) and QPS Burst(%d) for driver kubeClient", float32(kubeAPIQPS), kubeAPIBurst)
74+
kubeCfg.QPS = float32(kubeAPIQPS)
75+
kubeCfg.Burst = kubeAPIBurst
76+
if kubeClient, err = clientset.NewForConfig(kubeCfg); err != nil {
7777
klog.Warningf("NewForConfig failed with error: %v", err)
7878
}
7979
} else {

pkg/blob/azure_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ users:
169169
}
170170
os.Setenv(DefaultAzureCredentialFileEnv, fakeCredFile)
171171
}
172-
cloud, err := getCloudProvider(test.kubeconfig, test.nodeID, "", "", test.userAgent, test.allowEmptyCloudConfig)
172+
cloud, err := getCloudProvider(test.kubeconfig, test.nodeID, "", "", test.userAgent, test.allowEmptyCloudConfig, 25.0, 50)
173173
if !reflect.DeepEqual(err, test.expectedErr) && test.expectedErr != nil && !strings.Contains(err.Error(), test.expectedErr.Error()) {
174174
t.Errorf("desc: %s,\n input: %q, GetCloudProvider err: %v, expectedErr: %v", test.desc, test.kubeconfig, err, test.expectedErr)
175175
}

pkg/blob/blob.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ type DriverOptions struct {
145145
EnableGetVolumeStats bool
146146
AppendTimeStampInCacheDir bool
147147
MountPermissions uint64
148+
KubeAPIQPS float64
149+
KubeAPIBurst int
148150
}
149151

150152
// Driver implements all interfaces of CSI drivers
@@ -166,6 +168,8 @@ type Driver struct {
166168
appendTimeStampInCacheDir bool
167169
blobfuseProxyConnTimout int
168170
mountPermissions uint64
171+
kubeAPIQPS float64
172+
kubeAPIBurst int
169173
mounter *mount.SafeFormatAndMount
170174
volLockMap *util.LockMap
171175
// A map storing all volumes with ongoing operations so that additional operations
@@ -200,6 +204,8 @@ func NewDriver(options *DriverOptions) *Driver {
200204
allowEmptyCloudConfig: options.AllowEmptyCloudConfig,
201205
enableGetVolumeStats: options.EnableGetVolumeStats,
202206
mountPermissions: options.MountPermissions,
207+
kubeAPIQPS: options.KubeAPIQPS,
208+
kubeAPIBurst: options.KubeAPIBurst,
203209
}
204210
d.Name = options.DriverName
205211
d.Version = driverVersion
@@ -226,7 +232,7 @@ func (d *Driver) Run(endpoint, kubeconfig string, testBool bool) {
226232

227233
userAgent := GetUserAgent(d.Name, d.customUserAgent, d.userAgentSuffix)
228234
klog.V(2).Infof("driver userAgent: %s", userAgent)
229-
d.cloud, err = getCloudProvider(kubeconfig, d.NodeID, d.cloudConfigSecretName, d.cloudConfigSecretNamespace, userAgent, d.allowEmptyCloudConfig)
235+
d.cloud, err = getCloudProvider(kubeconfig, d.NodeID, d.cloudConfigSecretName, d.cloudConfigSecretNamespace, userAgent, d.allowEmptyCloudConfig, d.kubeAPIQPS, d.kubeAPIBurst)
230236
if err != nil {
231237
klog.Fatalf("failed to get Azure Cloud Provider, error: %v", err)
232238
}

pkg/blobplugin/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ var (
5555
appendTimeStampInCacheDir = flag.Bool("append-timestamp-cache-dir", false, "append timestamp into cache directory on agent node")
5656
mountPermissions = flag.Uint64("mount-permissions", 0777, "mounted folder permissions")
5757
allowInlineVolumeKeyAccessWithIdentity = flag.Bool("allow-inline-volume-key-access-with-idenitity", false, "allow accessing storage account key using cluster identity for inline volume")
58+
kubeAPIQPS = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.")
59+
kubeAPIBurst = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.")
5860
)
5961

6062
func main() {
@@ -91,6 +93,8 @@ func handle() {
9193
AppendTimeStampInCacheDir: *appendTimeStampInCacheDir,
9294
MountPermissions: *mountPermissions,
9395
AllowInlineVolumeKeyAccessWithIdentity: *allowInlineVolumeKeyAccessWithIdentity,
96+
KubeAPIQPS: *kubeAPIQPS,
97+
KubeAPIBurst: *kubeAPIBurst,
9498
}
9599
driver := blob.NewDriver(&driverOptions)
96100
if driver == nil {

0 commit comments

Comments
 (0)