Change:
Is this a BUG REPORT or FEATURE REQUEST?: /kind bug What happened: The azuredd plugin will always provision two instances of storage account with different type during init. There could be cases when: may only want to use one certain type of storage account, then the other type of storage account would be not in use. chooses to use managed disk, both of the storage account would be not in use. There is a limit for storage account numbers per subscription, and the storage account should be created with a on-demand policy. Log: Code: What you expected to happen: The storage accounts be created on-demand. How to reproduce it (as minimally and precisely as possible): Setup a kubernetes v1.7.2 cluster on Azure, create a dynamic pvc. Anything else we need to know?: Environment: Kubernetes version (use ):Cloud provider or hardware configuration*: Azure
/sig azure
Creating a storage account is a lengthy process (~ 1.5 mins), these 2 accounts are created upfront to ensure that PVCs will be quickly provisioned into existing storage accounts. Since ACS & acs-engine currently supports mixed (managed and blob) disks we won't be able to tell if they user will or won't use blob disks. Maybe once acs- moves away from blob disks we can disable them. They have no impact on users since users get billed only for data inside storage accounts not storage accounts themselves
for the "limit for storage account numbers per subscription" issue, I have another issue to track this: , will fix it in v1.9 and cherry pick to v1.8, v1.7
/assign

Discussion:
"bytes" "encoding/binary" "fmt" <del> "math" </del> "net/url" <del> "os" </del> "regexp" "sync"

var defaultContainerName = "" var storageAccountNamePrefix = "" var storageAccountNameMatch = "" <del> var initFlag int64 </del> var accountsLock = &sync.Mutex{} func newBlobDiskController(common *controllerCommon) (*BlobDiskController, error) { c := BlobDiskController{common: common} <del> err := c.init() </del> <ins> c.setUniqueStrings() // get accounts accounts, err := c.getAllStorageAccounts() </ins> if err != nil { <del> return nil, err </del> <ins> glog.Errorf("azureDisk - getAllStorageAccounts error: %v", err) c.accounts = make(map[string]*storageAccountState) return &c, nil </ins> } <ins> c.accounts = accounts </ins> return &c, nil }

return err } <del> // 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 { if !c.shouldInit() { return nil } c.setUniqueStrings() // get accounts accounts, err := c.getAllStorageAccounts() if err != nil { return err } c.accounts = accounts if len(c.accounts) == 0 { counter := 1 for counter <= storageAccountsCountInit { accountType := storage.PremiumLRS if n := math.Mod(float64(counter), 2); n == 0 { accountType = storage.StandardLRS } // We don't really care if these calls failed // at this stage, we are trying to ensure 2 accounts (Standard/Premium) // are there ready for PVC creation // if we failed here, the accounts will be created in the process // of creating PVC // nor do we care if they were partially created, as the entire // account creation process is idempotent go func(thisNext int) { newAccountName := getAccountNameForNum(thisNext) glog.Infof("azureDisk - BlobDiskController init process  will create new storageAccount:%s type:%s", newAccountName, accountType) err := c.createStorageAccount(newAccountName, accountType, c.common.location, true) // TODO return created and error from if err != nil { glog.Infof("azureDisk - BlobDiskController init: create account %s with error:%s", newAccountName, err.Error()) } else { glog.Infof("azureDisk - BlobDiskController init: created account %s", newAccountName) } }(counter) counter = counter + 1 } } return nil } </del> //Sets unique strings to be used as accountnames && || blob containers names func (c *BlobDiskController) setUniqueStrings() { uniqueString := c.common.resourceGroup + c.common.location + c.common.subscriptionID

return int(c.accounts[SAName].diskCount), nil } <del> // shouldInit ensures that we only init the plugin once // 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 } </del> func (c *BlobDiskController) getAllStorageAccounts() (map[string]*storageAccountState, error) { accountListResult, err := c.common.cloud.StorageAccountClient.List() if err != nil {