Skip to content

Commit

Permalink
feat: make kube-api-qps configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Nov 11, 2022
1 parent e49979f commit 0514906
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pkg/blob/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func IsAzureStackCloud(cloud *azure.Cloud) bool {
}

// getCloudProvider get Azure Cloud Provider
func getCloudProvider(kubeconfig, nodeID, secretName, secretNamespace, userAgent string, allowEmptyCloudConfig bool) (*azure.Cloud, error) {
func getCloudProvider(kubeconfig, nodeID, secretName, secretNamespace, userAgent string, allowEmptyCloudConfig bool, kubeAPIQPS float64, kubeAPIBurst int) (*azure.Cloud, error) {
var (
config *azure.Config
kubeClient *clientset.Clientset
Expand All @@ -70,10 +70,10 @@ func getCloudProvider(kubeconfig, nodeID, secretName, secretNamespace, userAgent
kubeCfg, err := getKubeConfig(kubeconfig)
if err == nil && kubeCfg != nil {
// set QPS and QPS Burst as higher values
kubeCfg.QPS = 25
kubeCfg.Burst = 50
kubeClient, err = clientset.NewForConfig(kubeCfg)
if err != nil {
klog.V(2).Infof("set QPS(%f) and QPS Burst(%d) for driver kubeClient", float32(kubeAPIQPS), kubeAPIBurst)
kubeCfg.QPS = float32(kubeAPIQPS)
kubeCfg.Burst = kubeAPIBurst
if kubeClient, err = clientset.NewForConfig(kubeCfg); err != nil {
klog.Warningf("NewForConfig failed with error: %v", err)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/blob/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ users:
}
os.Setenv(DefaultAzureCredentialFileEnv, fakeCredFile)
}
cloud, err := getCloudProvider(test.kubeconfig, test.nodeID, "", "", test.userAgent, test.allowEmptyCloudConfig)
cloud, err := getCloudProvider(test.kubeconfig, test.nodeID, "", "", test.userAgent, test.allowEmptyCloudConfig, 25.0, 50)
if !reflect.DeepEqual(err, test.expectedErr) && test.expectedErr != nil && !strings.Contains(err.Error(), test.expectedErr.Error()) {
t.Errorf("desc: %s,\n input: %q, GetCloudProvider err: %v, expectedErr: %v", test.desc, test.kubeconfig, err, test.expectedErr)
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ type DriverOptions struct {
EnableGetVolumeStats bool
AppendTimeStampInCacheDir bool
MountPermissions uint64
KubeAPIQPS float64
KubeAPIBurst int
}

// Driver implements all interfaces of CSI drivers
Expand All @@ -166,6 +168,8 @@ type Driver struct {
appendTimeStampInCacheDir bool
blobfuseProxyConnTimout int
mountPermissions uint64
kubeAPIQPS float64
kubeAPIBurst int
mounter *mount.SafeFormatAndMount
volLockMap *util.LockMap
// A map storing all volumes with ongoing operations so that additional operations
Expand Down Expand Up @@ -200,6 +204,8 @@ func NewDriver(options *DriverOptions) *Driver {
allowEmptyCloudConfig: options.AllowEmptyCloudConfig,
enableGetVolumeStats: options.EnableGetVolumeStats,
mountPermissions: options.MountPermissions,
kubeAPIQPS: options.KubeAPIQPS,
kubeAPIBurst: options.KubeAPIBurst,
}
d.Name = options.DriverName
d.Version = driverVersion
Expand All @@ -226,7 +232,7 @@ func (d *Driver) Run(endpoint, kubeconfig string, testBool bool) {

userAgent := GetUserAgent(d.Name, d.customUserAgent, d.userAgentSuffix)
klog.V(2).Infof("driver userAgent: %s", userAgent)
d.cloud, err = getCloudProvider(kubeconfig, d.NodeID, d.cloudConfigSecretName, d.cloudConfigSecretNamespace, userAgent, d.allowEmptyCloudConfig)
d.cloud, err = getCloudProvider(kubeconfig, d.NodeID, d.cloudConfigSecretName, d.cloudConfigSecretNamespace, userAgent, d.allowEmptyCloudConfig, d.kubeAPIQPS, d.kubeAPIBurst)
if err != nil {
klog.Fatalf("failed to get Azure Cloud Provider, error: %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/blobplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ var (
appendTimeStampInCacheDir = flag.Bool("append-timestamp-cache-dir", false, "append timestamp into cache directory on agent node")
mountPermissions = flag.Uint64("mount-permissions", 0777, "mounted folder permissions")
allowInlineVolumeKeyAccessWithIdentity = flag.Bool("allow-inline-volume-key-access-with-idenitity", false, "allow accessing storage account key using cluster identity for inline volume")
kubeAPIQPS = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.")
kubeAPIBurst = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.")
)

func main() {
Expand Down

0 comments on commit 0514906

Please sign in to comment.