Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3d60d180
Commit
3d60d180
authored
Nov 17, 2017
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove initialize storage account pool process
remove init func allow getStorageAccounts failed
parent
bb42103f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
68 deletions
+10
-68
azure_blobDiskController.go
...cloudprovider/providers/azure/azure_blobDiskController.go
+10
-63
azure_dd.go
pkg/volume/azure_dd/azure_dd.go
+0
-2
azure_provision.go
pkg/volume/azure_dd/azure_provision.go
+0
-3
No files found.
pkg/cloudprovider/providers/azure/azure_blobDiskController.go
View file @
3d60d180
...
@@ -20,7 +20,6 @@ import (
...
@@ -20,7 +20,6 @@ import (
"bytes"
"bytes"
"encoding/binary"
"encoding/binary"
"fmt"
"fmt"
"math"
"net/url"
"net/url"
"regexp"
"regexp"
"sync"
"sync"
...
@@ -63,12 +62,21 @@ type BlobDiskController struct {
...
@@ -63,12 +62,21 @@ type BlobDiskController struct {
var
defaultContainerName
=
""
var
defaultContainerName
=
""
var
storageAccountNamePrefix
=
""
var
storageAccountNamePrefix
=
""
var
storageAccountNameMatch
=
""
var
storageAccountNameMatch
=
""
var
initFlag
int64
var
accountsLock
=
&
sync
.
Mutex
{}
var
accountsLock
=
&
sync
.
Mutex
{}
func
newBlobDiskController
(
common
*
controllerCommon
)
(
*
BlobDiskController
,
error
)
{
func
newBlobDiskController
(
common
*
controllerCommon
)
(
*
BlobDiskController
,
error
)
{
c
:=
BlobDiskController
{
common
:
common
}
c
:=
BlobDiskController
{
common
:
common
}
c
.
setUniqueStrings
()
// get accounts
accounts
,
err
:=
c
.
getAllStorageAccounts
()
if
err
!=
nil
{
glog
.
Errorf
(
"azureDisk - getAllStorageAccounts error: %v"
,
err
)
c
.
accounts
=
make
(
map
[
string
]
*
storageAccountState
)
return
&
c
,
nil
}
c
.
accounts
=
accounts
return
&
c
,
nil
return
&
c
,
nil
}
}
...
@@ -307,60 +315,6 @@ func (c *BlobDiskController) DeleteBlobDisk(diskURI string, wasForced bool) erro
...
@@ -307,60 +315,6 @@ func (c *BlobDiskController) DeleteBlobDisk(diskURI string, wasForced bool) erro
return
err
return
err
}
}
// 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
)
InitStorageAccount
()
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
}
//Sets unique strings to be used as accountnames && || blob containers names
//Sets unique strings to be used as accountnames && || blob containers names
func
(
c
*
BlobDiskController
)
setUniqueStrings
()
{
func
(
c
*
BlobDiskController
)
setUniqueStrings
()
{
uniqueString
:=
c
.
common
.
resourceGroup
+
c
.
common
.
location
+
c
.
common
.
subscriptionID
uniqueString
:=
c
.
common
.
resourceGroup
+
c
.
common
.
location
+
c
.
common
.
subscriptionID
...
@@ -532,13 +486,6 @@ func (c *BlobDiskController) getDiskCount(SAName string) (int, error) {
...
@@ -532,13 +486,6 @@ func (c *BlobDiskController) getDiskCount(SAName string) (int, error) {
return
int
(
c
.
accounts
[
SAName
]
.
diskCount
),
nil
return
int
(
c
.
accounts
[
SAName
]
.
diskCount
),
nil
}
}
// shouldInit ensures that we only init the plugin once
// and we only do that in the controller
func
(
c
*
BlobDiskController
)
shouldInit
()
bool
{
return
atomic
.
CompareAndSwapInt64
(
&
initFlag
,
0
,
1
)
}
func
(
c
*
BlobDiskController
)
getAllStorageAccounts
()
(
map
[
string
]
*
storageAccountState
,
error
)
{
func
(
c
*
BlobDiskController
)
getAllStorageAccounts
()
(
map
[
string
]
*
storageAccountState
,
error
)
{
accountListResult
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
List
()
accountListResult
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
List
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/volume/azure_dd/azure_dd.go
View file @
3d60d180
...
@@ -28,8 +28,6 @@ import (
...
@@ -28,8 +28,6 @@ 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
...
...
pkg/volume/azure_dd/azure_provision.go
View file @
3d60d180
...
@@ -168,9 +168,6 @@ func (p *azureDiskProvisioner) Provision() (*v1.PersistentVolume, error) {
...
@@ -168,9 +168,6 @@ 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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment