mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +00:00
move InitStorageAccount into azure disk provision func
This commit is contained in:
parent
11fc906c2b
commit
bb42103fca
@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"sync"
|
||||
|
||||
@ -70,12 +69,6 @@ var accountsLock = &sync.Mutex{}
|
||||
|
||||
func newBlobDiskController(common *controllerCommon) (*BlobDiskController, error) {
|
||||
c := BlobDiskController{common: common}
|
||||
err := c.init()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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
|
||||
// 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() {
|
||||
return nil
|
||||
}
|
||||
@ -543,13 +536,7 @@ func (c *BlobDiskController) getDiskCount(SAName string) (int, error) {
|
||||
// and we only do that in the controller
|
||||
|
||||
func (c *BlobDiskController) shouldInit() bool {
|
||||
if os.Args[0] == "kube-controller-manager" || (os.Args[0] == "/hyperkube" && os.Args[1] == "controller-manager") {
|
||||
swapped := atomic.CompareAndSwapInt64(&initFlag, 0, 1)
|
||||
if swapped {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return atomic.CompareAndSwapInt64(&initFlag, 0, 1)
|
||||
}
|
||||
|
||||
func (c *BlobDiskController) getAllStorageAccounts() (map[string]*storageAccountState, error) {
|
||||
|
@ -28,6 +28,8 @@ import (
|
||||
|
||||
// interface exposed by the cloud provider implementing Disk functionlity
|
||||
type DiskController interface {
|
||||
InitStorageAccount() error
|
||||
|
||||
CreateBlobDisk(dataDiskName string, storageAccountType storage.SkuName, sizeGB int, forceStandAlone bool) (string, error)
|
||||
DeleteBlobDisk(diskUri string, wasForced bool) error
|
||||
|
||||
|
@ -168,6 +168,9 @@ func (p *azureDiskProvisioner) Provision() (*v1.PersistentVolume, error) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err = diskController.InitStorageAccount(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
diskURI, err = diskController.CreateBlobDisk(name, skuName, requestGB, forceStandAlone)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user