diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go index a0add2fde2..e7db8ee2b2 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go @@ -877,6 +877,14 @@ func initDiskControllers(az *Cloud) error { // Common controller contains the function // needed by both blob disk and managed disk controllers + qps := float32(defaultAtachDetachDiskQPS) + bucket := defaultAtachDetachDiskBucket + if az.Config.AttachDetachDiskRateLimit != nil { + qps = az.Config.AttachDetachDiskRateLimit.CloudProviderRateLimitQPSWrite + bucket = az.Config.AttachDetachDiskRateLimit.CloudProviderRateLimitBucketWrite + } + klog.V(2).Infof("disk operation RateLimiter QPS: %f, Bucket: %d", qps, bucket) + common := &controllerCommon{ location: az.Location, storageEndpointSuffix: az.Environment.StorageEndpointSuffix, @@ -884,7 +892,7 @@ func initDiskControllers(az *Cloud) error { subscriptionID: az.SubscriptionID, cloud: az, lockMap: newLockMap(), - diskOpRateLimiter: flowcontrol.NewTokenBucketRateLimiter(10, 20), + diskOpRateLimiter: flowcontrol.NewTokenBucketRateLimiter(qps, bucket), } if az.HasExtendedLocation() { diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_controller_common.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_controller_common.go index 21ff2405c9..d96f203ee8 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_controller_common.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_controller_common.go @@ -255,15 +255,13 @@ func (c *controllerCommon) AttachDisk(isManagedDisk bool, diskName, diskURI stri return -1, err } - klog.V(2).Infof("diskOpRateLimiter QPS: %d", c.diskOpRateLimiter.QPS()) if c.diskOpRateLimiter.TryAccept() { // unlock and wait for attach disk complete unlock = true c.lockMap.UnlockEntry(node) } else { - klog.Warningf("switch to batch operation since disk operation is rate limited, current QPS: %f", c.diskOpRateLimiter.QPS()) + klog.Warningf("azureDisk - switch to batch operation since disk operation is rate limited, current QPS: %f", c.diskOpRateLimiter.QPS()) } - klog.V(2).Infof("diskOpRateLimiter QPS: %d", c.diskOpRateLimiter.QPS()) ctx, cancel := getContextWithCancel() defer cancel() @@ -376,15 +374,13 @@ func (c *controllerCommon) DetachDisk(diskName, diskURI string, nodeName types.N if err != nil { return err } - klog.V(2).Infof("diskOpRateLimiter QPS: %d", c.diskOpRateLimiter.QPS()) if c.diskOpRateLimiter.TryAccept() { // unlock and wait for attach disk complete unlock = true c.lockMap.UnlockEntry(node) } else { - klog.Warningf("switch to batch operation since disk operation is rate limited, current QPS: %f", c.diskOpRateLimiter.QPS()) + klog.Warningf("azureDisk - switch to batch operation since disk operation is rate limited, current QPS: %f", c.diskOpRateLimiter.QPS()) } - klog.V(2).Infof("diskOpRateLimiter QPS: %d", c.diskOpRateLimiter.QPS()) if err := vmset.WaitForUpdateResult(ctx, future, resourceGroup, "detach_disk"); err != nil { klog.Errorf("azureDisk - detach disk(%s, %s) failed with error: %v", diskName, diskURI, err) diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_ratelimit.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_ratelimit.go index 94e6acfb91..b9f9206471 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_ratelimit.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_ratelimit.go @@ -21,6 +21,11 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/consts" ) +const ( + defaultAtachDetachDiskQPS = 6.0 + defaultAtachDetachDiskBucket = 10 +) + // CloudProviderRateLimitConfig indicates the rate limit config for each clients. type CloudProviderRateLimitConfig struct { // The default rate limit config options. @@ -41,6 +46,7 @@ type CloudProviderRateLimitConfig struct { VirtualMachineScaleSetRateLimit *azclients.RateLimitConfig `json:"virtualMachineScaleSetRateLimit,omitempty" yaml:"virtualMachineScaleSetRateLimit,omitempty"` VirtualMachineSizeRateLimit *azclients.RateLimitConfig `json:"virtualMachineSizesRateLimit,omitempty" yaml:"virtualMachineSizesRateLimit,omitempty"` AvailabilitySetRateLimit *azclients.RateLimitConfig `json:"availabilitySetRateLimit,omitempty" yaml:"availabilitySetRateLimit,omitempty"` + AttachDetachDiskRateLimit *azclients.RateLimitConfig `json:"attachDetachDiskRateLimit,omitempty" yaml:"attachDetachDiskRateLimit,omitempty"` } // InitializeCloudProviderRateLimitConfig initializes rate limit configs. @@ -78,6 +84,13 @@ func InitializeCloudProviderRateLimitConfig(config *CloudProviderRateLimitConfig config.VirtualMachineScaleSetRateLimit = overrideDefaultRateLimitConfig(&config.RateLimitConfig, config.VirtualMachineScaleSetRateLimit) config.VirtualMachineSizeRateLimit = overrideDefaultRateLimitConfig(&config.RateLimitConfig, config.VirtualMachineSizeRateLimit) config.AvailabilitySetRateLimit = overrideDefaultRateLimitConfig(&config.RateLimitConfig, config.AvailabilitySetRateLimit) + + atachDetachDiskRateLimitConfig := azclients.RateLimitConfig{ + CloudProviderRateLimit: true, + CloudProviderRateLimitQPSWrite: defaultAtachDetachDiskQPS, + CloudProviderRateLimitBucketWrite: defaultAtachDetachDiskBucket, + } + config.AttachDetachDiskRateLimit = overrideDefaultRateLimitConfig(&atachDetachDiskRateLimitConfig, config.AttachDetachDiskRateLimit) } // overrideDefaultRateLimitConfig overrides the default CloudProviderRateLimitConfig.