Skip to content

Commit

Permalink
fix: disable disk related rate limit
Browse files Browse the repository at this point in the history
ut

fix panic
  • Loading branch information
andyzhangx committed Aug 21, 2021
1 parent e0a7bc7 commit cf8d8f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pkg/azuredisk/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/klog/v2"

"sigs.k8s.io/azuredisk-csi-driver/pkg/util"
azclients "sigs.k8s.io/cloud-provider-azure/pkg/azureclients"
azure "sigs.k8s.io/cloud-provider-azure/pkg/provider"
)

Expand Down Expand Up @@ -105,6 +106,13 @@ func GetCloudProvider(kubeconfig, secretName, secretNamespace, userAgent string)
klog.V(2).Infof("no cloud config provided, error: %v, driver will run without cloud config", err)
} else {
config.UserAgent = userAgent
// disable disk related rate limit
config.DiskRateLimit = &azclients.RateLimitConfig{
CloudProviderRateLimit: false,
}
config.SnapshotRateLimit = &azclients.RateLimitConfig{
CloudProviderRateLimit: false,
}
if err = az.InitializeCloudFromConfig(config, fromSecret, false); err != nil {
klog.Warningf("InitializeCloudFromConfig failed with error: %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/azuredisk/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ users:
t.Errorf("return value of getCloudProvider should not be nil even there is error")
} else {
assert.Equal(t, cloud.UserAgent, test.userAgent)
assert.Equal(t, cloud.DiskRateLimit != nil && cloud.DiskRateLimit.CloudProviderRateLimit, false)
assert.Equal(t, cloud.SnapshotRateLimit != nil && cloud.SnapshotRateLimit.CloudProviderRateLimit, false)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/azuredisk/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestGetUserAgent(t *testing.T) {
driverName: "",
customUserAgent: "",
userAgentSuffix: "",
expectedResult: fmt.Sprintf("%s/%s %s/%s (%s-%s) %s/%s", "", driverVersion, runtime.Compiler, runtime.Version(), runtime.GOARCH, runtime.GOOS, gitCommit, buildDate),
expectedResult: fmt.Sprintf("%s/%s %s/%s (%s-%s)", "", driverVersion, runtime.Compiler, runtime.Version(), runtime.GOARCH, runtime.GOOS),
},
{
driverName: "",
Expand All @@ -85,7 +85,7 @@ func TestGetUserAgent(t *testing.T) {
driverName: "drivername",
customUserAgent: "",
userAgentSuffix: "suffix",
expectedResult: fmt.Sprintf("%s/%s %s/%s (%s-%s) %s/%s suffix", "drivername", driverVersion, runtime.Compiler, runtime.Version(), runtime.GOARCH, runtime.GOOS, gitCommit, buildDate),
expectedResult: fmt.Sprintf("%s/%s %s/%s (%s-%s) suffix", "drivername", driverVersion, runtime.Compiler, runtime.Version(), runtime.GOARCH, runtime.GOOS),
},
}

Expand Down

0 comments on commit cf8d8f2

Please sign in to comment.