mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 05:46:16 +00:00
move InitStorageAccount into azure disk provision func
This commit is contained in:
parent
11fc906c2b
commit
bb42103fca
@ -22,7 +22,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -70,12 +69,6 @@ var accountsLock = &sync.Mutex{}
|
|||||||
|
|
||||||
func newBlobDiskController(common *controllerCommon) (*BlobDiskController, error) {
|
func newBlobDiskController(common *controllerCommon) (*BlobDiskController, error) {
|
||||||
c := BlobDiskController{common: common}
|
c := BlobDiskController{common: common}
|
||||||
err := c.init()
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &c, nil
|
return &c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +309,7 @@ func (c *BlobDiskController) DeleteBlobDisk(diskURI string, wasForced bool) erro
|
|||||||
|
|
||||||
// Init tries best effort to ensure that 2 accounts standard/premium were created
|
// Init tries best effort to ensure that 2 accounts standard/premium were created
|
||||||
// to be used by shared blob disks. This to increase the speed pvc provisioning (in most of cases)
|
// to be used by shared blob disks. This to increase the speed pvc provisioning (in most of cases)
|
||||||
func (c *BlobDiskController) init() error {
|
func (c *BlobDiskController) InitStorageAccount() error {
|
||||||
if !c.shouldInit() {
|
if !c.shouldInit() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -543,13 +536,7 @@ func (c *BlobDiskController) getDiskCount(SAName string) (int, error) {
|
|||||||
// and we only do that in the controller
|
// and we only do that in the controller
|
||||||
|
|
||||||
func (c *BlobDiskController) shouldInit() bool {
|
func (c *BlobDiskController) shouldInit() bool {
|
||||||
if os.Args[0] == "kube-controller-manager" || (os.Args[0] == "/hyperkube" && os.Args[1] == "controller-manager") {
|
return atomic.CompareAndSwapInt64(&initFlag, 0, 1)
|
||||||
swapped := atomic.CompareAndSwapInt64(&initFlag, 0, 1)
|
|
||||||
if swapped {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *BlobDiskController) getAllStorageAccounts() (map[string]*storageAccountState, error) {
|
func (c *BlobDiskController) getAllStorageAccounts() (map[string]*storageAccountState, error) {
|
||||||
|
@ -28,6 +28,8 @@ import (
|
|||||||
|
|
||||||
// interface exposed by the cloud provider implementing Disk functionlity
|
// interface exposed by the cloud provider implementing Disk functionlity
|
||||||
type DiskController interface {
|
type DiskController interface {
|
||||||
|
InitStorageAccount() error
|
||||||
|
|
||||||
CreateBlobDisk(dataDiskName string, storageAccountType storage.SkuName, sizeGB int, forceStandAlone bool) (string, error)
|
CreateBlobDisk(dataDiskName string, storageAccountType storage.SkuName, sizeGB int, forceStandAlone bool) (string, error)
|
||||||
DeleteBlobDisk(diskUri string, wasForced bool) error
|
DeleteBlobDisk(diskUri string, wasForced bool) error
|
||||||
|
|
||||||
|
@ -168,6 +168,9 @@ func (p *azureDiskProvisioner) Provision() (*v1.PersistentVolume, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if err = diskController.InitStorageAccount(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
diskURI, err = diskController.CreateBlobDisk(name, skuName, requestGB, forceStandAlone)
|
diskURI, err = diskController.CreateBlobDisk(name, skuName, requestGB, forceStandAlone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user