mirror of https://github.com/k3s-io/k3s
make funcs in azure cloud provider as public
parent
79ce30cc6a
commit
38f0908597
|
@ -82,7 +82,7 @@ func (c *BlobDiskController) initStorageAccounts() {
|
||||||
// If no storage account is given, search all the storage accounts associated with the resource group and pick one that
|
// If no storage account is given, search all the storage accounts associated with the resource group and pick one that
|
||||||
// fits storage type and location.
|
// fits storage type and location.
|
||||||
func (c *BlobDiskController) CreateVolume(blobName, accountName, accountType, location string, requestGB int) (string, string, int, error) {
|
func (c *BlobDiskController) CreateVolume(blobName, accountName, accountType, location string, requestGB int) (string, string, int, error) {
|
||||||
account, key, err := c.common.cloud.ensureStorageAccount(accountName, accountType, string(defaultStorageAccountKind), c.common.resourceGroup, location, dedicatedDiskAccountNamePrefix)
|
account, key, err := c.common.cloud.EnsureStorageAccount(accountName, accountType, string(defaultStorageAccountKind), c.common.resourceGroup, location, dedicatedDiskAccountNamePrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", 0, fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err)
|
return "", "", 0, fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
|
||||||
diskID := ""
|
diskID := ""
|
||||||
|
|
||||||
err = kwait.ExponentialBackoff(defaultBackOff, func() (bool, error) {
|
err = kwait.ExponentialBackoff(defaultBackOff, func() (bool, error) {
|
||||||
provisionState, id, err := c.getDisk(options.ResourceGroup, options.DiskName)
|
provisionState, id, err := c.GetDisk(options.ResourceGroup, options.DiskName)
|
||||||
diskID = id
|
diskID = id
|
||||||
// We are waiting for provisioningState==Succeeded
|
// We are waiting for provisioningState==Succeeded
|
||||||
// We don't want to hand-off managed disks to k8s while they are
|
// We don't want to hand-off managed disks to k8s while they are
|
||||||
|
@ -197,8 +197,8 @@ func (c *ManagedDiskController) DeleteManagedDisk(diskURI string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// return: disk provisionState, diskID, error
|
// GetDisk return: disk provisionState, diskID, error
|
||||||
func (c *ManagedDiskController) getDisk(resourceGroup, diskName string) (string, string, error) {
|
func (c *ManagedDiskController) GetDisk(resourceGroup, diskName string) (string, string, error) {
|
||||||
ctx, cancel := getContextWithCancel()
|
ctx, cancel := getContextWithCancel()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (az *Cloud) CreateFileShare(shareName, accountName, accountType, accountKin
|
||||||
resourceGroup = az.resourceGroup
|
resourceGroup = az.resourceGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
account, key, err := az.ensureStorageAccount(accountName, accountType, accountKind, resourceGroup, location, fileShareAccountNamePrefix)
|
account, key, err := az.EnsureStorageAccount(accountName, accountType, accountKind, resourceGroup, location, fileShareAccountNamePrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err)
|
return "", "", fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,8 @@ func (az *Cloud) GetStorageAccesskey(account, resourceGroup string) (string, err
|
||||||
return "", fmt.Errorf("no valid keys")
|
return "", fmt.Errorf("no valid keys")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensureStorageAccount search storage account, create one storage account(with genAccountNamePrefix) if not found, return accountName, accountKey
|
// EnsureStorageAccount search storage account, create one storage account(with genAccountNamePrefix) if not found, return accountName, accountKey
|
||||||
func (az *Cloud) ensureStorageAccount(accountName, accountType, accountKind, resourceGroup, location, genAccountNamePrefix string) (string, string, error) {
|
func (az *Cloud) EnsureStorageAccount(accountName, accountType, accountKind, resourceGroup, location, genAccountNamePrefix string) (string, string, error) {
|
||||||
if len(accountName) == 0 {
|
if len(accountName) == 0 {
|
||||||
// find a storage account that matches accountType
|
// find a storage account that matches accountType
|
||||||
accounts, err := az.getStorageAccounts(accountType, accountKind, resourceGroup, location)
|
accounts, err := az.getStorageAccounts(accountType, accountKind, resourceGroup, location)
|
||||||
|
|
Loading…
Reference in New Issue