mirror of https://github.com/k3s-io/k3s
add timeout in GetVolumeLimits operation
add timeout for getAllStorageAccountspull/564/head
parent
156602408a
commit
8cd09bb143
|
@ -18,6 +18,7 @@ package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -439,7 +440,7 @@ func (c *BlobDiskController) getDiskCount(SAName string) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BlobDiskController) getAllStorageAccounts() (map[string]*storageAccountState, error) {
|
func (c *BlobDiskController) getAllStorageAccounts() (map[string]*storageAccountState, error) {
|
||||||
ctx, cancel := getContextWithCancel()
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
accountListResult, err := c.common.cloud.StorageAccountClient.ListByResourceGroup(ctx, c.common.resourceGroup)
|
accountListResult, err := c.common.cloud.StorageAccountClient.ListByResourceGroup(ctx, c.common.resourceGroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
|
||||||
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
|
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
|
||||||
|
@ -164,7 +165,9 @@ func (plugin *azureDataDiskPlugin) GetVolumeLimits() (map[string]int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if vmSizeList == nil {
|
if vmSizeList == nil {
|
||||||
result, err := az.VirtualMachineSizesClient.List(context.TODO(), az.Location)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
result, err := az.VirtualMachineSizesClient.List(ctx, az.Location)
|
||||||
if err != nil || result.Value == nil {
|
if err != nil || result.Value == nil {
|
||||||
klog.Errorf("failed to list vm sizes in GetVolumeLimits, plugin.host: %s, location: %s", plugin.host.GetHostName(), az.Location)
|
klog.Errorf("failed to list vm sizes in GetVolumeLimits, plugin.host: %s, location: %s", plugin.host.GetHostName(), az.Location)
|
||||||
return volumeLimits, nil
|
return volumeLimits, nil
|
||||||
|
|
Loading…
Reference in New Issue