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
079f9b85
Commit
079f9b85
authored
Apr 24, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new clients in azure cloud provider
parent
8a0cae86
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
127 additions
and
134 deletions
+127
-134
BUILD
pkg/cloudprovider/providers/azure/BUILD
+2
-5
azure_backoff.go
pkg/cloudprovider/providers/azure/azure_backoff.go
+10
-33
azure_blobDiskController.go
...cloudprovider/providers/azure/azure_blobDiskController.go
+15
-8
azure_controller_common.go
pkg/cloudprovider/providers/azure/azure_controller_common.go
+1
-1
azure_controller_standard.go
...loudprovider/providers/azure/azure_controller_standard.go
+9
-9
azure_controller_vmss.go
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
+7
-8
azure_fakes.go
pkg/cloudprovider/providers/azure/azure_fakes.go
+0
-0
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+3
-3
azure_managedDiskController.go
...udprovider/providers/azure/azure_managedDiskController.go
+22
-18
azure_standard.go
pkg/cloudprovider/providers/azure/azure_standard.go
+1
-1
azure_storage.go
pkg/cloudprovider/providers/azure/azure_storage.go
+1
-1
azure_storage_test.go
pkg/cloudprovider/providers/azure/azure_storage_test.go
+1
-1
azure_storageaccount.go
pkg/cloudprovider/providers/azure/azure_storageaccount.go
+12
-7
azure_storageaccount_test.go
...loudprovider/providers/azure/azure_storageaccount_test.go
+1
-1
azure_test.go
pkg/cloudprovider/providers/azure/azure_test.go
+7
-5
azure_vmsets.go
pkg/cloudprovider/providers/azure/azure_vmsets.go
+1
-1
azure_vmss.go
pkg/cloudprovider/providers/azure/azure_vmss.go
+20
-20
azure_vmss_test.go
pkg/cloudprovider/providers/azure/azure_vmss_test.go
+10
-10
azure_wrap.go
pkg/cloudprovider/providers/azure/azure_wrap.go
+4
-2
No files found.
pkg/cloudprovider/providers/azure/BUILD
View file @
079f9b85
...
...
@@ -42,11 +42,9 @@ go_library(
"//pkg/controller:go_default_library",
"//pkg/version:go_default_library",
"//pkg/volume:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/disk:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/storage:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library",
...
...
@@ -89,10 +87,9 @@ go_test(
"//pkg/cloudprovider:go_default_library",
"//pkg/cloudprovider/providers/azure/auth:go_default_library",
"//pkg/kubelet/apis:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/arm/storage:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
...
...
pkg/cloudprovider/providers/azure/azure_backoff.go
View file @
079f9b85
...
...
@@ -20,8 +20,7 @@ import (
"context"
"net/http"
"github.com/Azure/azure-sdk-for-go/arm/compute"
computepreview
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/go-autorest/autorest"
"github.com/golang/glog"
...
...
@@ -72,10 +71,11 @@ func (az *Cloud) GetVirtualMachineWithRetry(name types.NodeName) (compute.Virtua
// VirtualMachineClientListWithRetry invokes az.VirtualMachinesClient.List with exponential backoff retry
func
(
az
*
Cloud
)
VirtualMachineClientListWithRetry
()
([]
compute
.
VirtualMachine
,
error
)
{
allNodes
:=
[]
compute
.
VirtualMachine
{}
var
result
compute
.
VirtualMachineListResult
err
:=
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
var
retryErr
error
result
,
retryErr
=
az
.
VirtualMachinesClient
.
List
(
az
.
ResourceGroup
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
allNodes
,
retryErr
=
az
.
VirtualMachinesClient
.
List
(
ctx
,
az
.
ResourceGroup
)
if
retryErr
!=
nil
{
glog
.
Errorf
(
"VirtualMachinesClient.List(%v) - backoff: failure, will retry,err=%v"
,
az
.
ResourceGroup
,
...
...
@@ -89,30 +89,6 @@ func (az *Cloud) VirtualMachineClientListWithRetry() ([]compute.VirtualMachine,
return
nil
,
err
}
appendResults
:=
(
result
.
Value
!=
nil
&&
len
(
*
result
.
Value
)
>
0
)
for
appendResults
{
allNodes
=
append
(
allNodes
,
*
result
.
Value
...
)
appendResults
=
false
// follow the next link to get all the vms for resource group
if
result
.
NextLink
!=
nil
{
err
:=
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
var
retryErr
error
result
,
retryErr
=
az
.
VirtualMachinesClient
.
ListNextResults
(
az
.
ResourceGroup
,
result
)
if
retryErr
!=
nil
{
glog
.
Errorf
(
"VirtualMachinesClient.ListNextResults(%v) - backoff: failure, will retry,err=%v"
,
az
.
ResourceGroup
,
retryErr
)
return
false
,
retryErr
}
glog
.
V
(
2
)
.
Infof
(
"VirtualMachinesClient.ListNextResults(%v): success"
,
az
.
ResourceGroup
)
return
true
,
nil
})
if
err
!=
nil
{
return
allNodes
,
err
}
appendResults
=
(
result
.
Value
!=
nil
&&
len
(
*
result
.
Value
)
>
0
)
}
}
return
allNodes
,
err
}
...
...
@@ -352,16 +328,17 @@ func (az *Cloud) DeleteRouteWithRetry(routeName string) error {
// CreateOrUpdateVMWithRetry invokes az.VirtualMachinesClient.CreateOrUpdate with exponential backoff retry
func
(
az
*
Cloud
)
CreateOrUpdateVMWithRetry
(
vmName
string
,
newVM
compute
.
VirtualMachine
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
respChan
,
errChan
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
vmName
,
newVM
)
glog
.
V
(
10
)
.
Infof
(
"VirtualMachinesClient.CreateOrUpdate(%s): end"
,
vmName
)
return
process
RetryResponse
(
resp
.
Response
,
err
)
return
process
HTTPRetryResponse
(
resp
,
err
)
})
}
// UpdateVmssVMWithRetry invokes az.VirtualMachineScaleSetVMsClient.Update with exponential backoff retry
func
(
az
*
Cloud
)
UpdateVmssVMWithRetry
(
ctx
context
.
Context
,
resourceGroupName
string
,
VMScaleSetName
string
,
instanceID
string
,
parameters
compute
preview
.
VirtualMachineScaleSetVM
)
error
{
func
(
az
*
Cloud
)
UpdateVmssVMWithRetry
(
ctx
context
.
Context
,
resourceGroupName
string
,
VMScaleSetName
string
,
instanceID
string
,
parameters
compute
.
VirtualMachineScaleSetVM
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
resp
,
err
:=
az
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
resourceGroupName
,
VMScaleSetName
,
instanceID
,
parameters
)
glog
.
V
(
10
)
.
Infof
(
"VirtualMachinesClient.CreateOrUpdate(%s,%s): end"
,
VMScaleSetName
,
instanceID
)
...
...
pkg/cloudprovider/providers/azure/azure_blobDiskController.go
View file @
079f9b85
...
...
@@ -27,7 +27,7 @@ import (
"sync/atomic"
"time"
storage
"github.com/Azure/azure-sdk-for-go/arm
/storage"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01
/storage"
azstorage
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog"
...
...
@@ -277,7 +277,10 @@ func (c *BlobDiskController) getStorageAccountKey(SAName string) (string, error)
if
account
,
exists
:=
c
.
accounts
[
SAName
];
exists
&&
account
.
key
!=
""
{
return
c
.
accounts
[
SAName
]
.
key
,
nil
}
listKeysResult
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
ListKeys
(
c
.
common
.
resourceGroup
,
SAName
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
listKeysResult
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
ListKeys
(
ctx
,
c
.
common
.
resourceGroup
,
SAName
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -432,7 +435,9 @@ func (c *BlobDiskController) getDiskCount(SAName string) (int, error) {
}
func
(
c
*
BlobDiskController
)
getAllStorageAccounts
()
(
map
[
string
]
*
storageAccountState
,
error
)
{
accountListResult
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
ListByResourceGroup
(
c
.
common
.
resourceGroup
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
accountListResult
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
ListByResourceGroup
(
ctx
,
c
.
common
.
resourceGroup
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -484,12 +489,12 @@ func (c *BlobDiskController) createStorageAccount(storageAccountName string, sto
cp
:=
storage
.
AccountCreateParameters
{
Sku
:
&
storage
.
Sku
{
Name
:
storageAccountType
},
Tags
:
&
map
[
string
]
*
string
{
"created-by"
:
to
.
StringPtr
(
"azure-dd"
)},
Tags
:
map
[
string
]
*
string
{
"created-by"
:
to
.
StringPtr
(
"azure-dd"
)},
Location
:
&
location
}
cancel
:=
make
(
chan
struct
{})
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
_
,
errChan
:=
c
.
common
.
cloud
.
StorageAccountClient
.
Create
(
c
.
common
.
resourceGroup
,
storageAccountName
,
cp
,
cancel
)
err
:=
<-
errChan
_
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
Create
(
ctx
,
c
.
common
.
resourceGroup
,
storageAccountName
,
cp
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
fmt
.
Sprintf
(
"Create Storage Account: %s, error: %s"
,
storageAccountName
,
err
))
}
...
...
@@ -584,7 +589,9 @@ func (c *BlobDiskController) findSANameForDisk(storageAccountType storage.SkuNam
//Gets storage account exist, provisionStatus, Error if any
func
(
c
*
BlobDiskController
)
getStorageAccountState
(
storageAccountName
string
)
(
bool
,
storage
.
ProvisioningState
,
error
)
{
account
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
GetProperties
(
c
.
common
.
resourceGroup
,
storageAccountName
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
account
,
err
:=
c
.
common
.
cloud
.
StorageAccountClient
.
GetProperties
(
ctx
,
c
.
common
.
resourceGroup
,
storageAccountName
)
if
err
!=
nil
{
return
false
,
""
,
err
}
...
...
pkg/cloudprovider/providers/azure/azure_controller_common.go
View file @
079f9b85
...
...
@@ -20,7 +20,7 @@ import (
"fmt"
"time"
"github.com/Azure/azure-sdk-for-go/
arm
/compute"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01
/compute"
"k8s.io/apimachinery/pkg/types"
kwait
"k8s.io/apimachinery/pkg/util/wait"
...
...
pkg/cloudprovider/providers/azure/azure_controller_standard.go
View file @
079f9b85
...
...
@@ -20,7 +20,7 @@ import (
"fmt"
"strings"
"github.com/Azure/azure-sdk-for-go/
arm
/compute"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01
/compute"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/types"
...
...
@@ -70,10 +70,10 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
}
vmName
:=
mapNodeNameToVMName
(
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk"
,
as
.
resourceGroup
,
vmName
)
respChan
,
errChan
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
as
.
resourceGroup
,
vmName
,
newVM
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
if
as
.
CloudProviderBackoff
&&
shouldRetry
APIRequest
(
resp
.
Response
,
err
)
{
ctx
,
cancel
:=
getContextWithCancel
(
)
defer
cancel
()
resp
,
err
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
as
.
resourceGroup
,
vmName
,
newVM
)
if
as
.
CloudProviderBackoff
&&
shouldRetry
HTTPRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) backing off: vm(%s)"
,
as
.
resourceGroup
,
vmName
)
retryErr
:=
as
.
CreateOrUpdateVMWithRetry
(
vmName
,
newVM
)
if
retryErr
!=
nil
{
...
...
@@ -135,10 +135,10 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
}
vmName
:=
mapNodeNameToVMName
(
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk"
,
as
.
resourceGroup
,
vmName
)
respChan
,
errChan
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
as
.
resourceGroup
,
vmName
,
newVM
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
if
as
.
CloudProviderBackoff
&&
shouldRetry
APIRequest
(
resp
.
Response
,
err
)
{
ctx
,
cancel
:=
getContextWithCancel
(
)
defer
cancel
()
resp
,
err
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
as
.
resourceGroup
,
vmName
,
newVM
)
if
as
.
CloudProviderBackoff
&&
shouldRetry
HTTPRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) backing off: vm(%s)"
,
as
.
resourceGroup
,
vmName
)
retryErr
:=
as
.
CreateOrUpdateVMWithRetry
(
vmName
,
newVM
)
if
retryErr
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
View file @
079f9b85
...
...
@@ -20,8 +20,7 @@ import (
"fmt"
"strings"
"github.com/Azure/azure-sdk-for-go/arm/compute"
computepreview
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/types"
...
...
@@ -39,24 +38,24 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
disks
:=
*
vm
.
StorageProfile
.
DataDisks
if
isManagedDisk
{
disks
=
append
(
disks
,
compute
preview
.
DataDisk
{
compute
.
DataDisk
{
Name
:
&
diskName
,
Lun
:
&
lun
,
Caching
:
compute
preview
.
CachingTypes
(
cachingMode
),
Caching
:
compute
.
CachingTypes
(
cachingMode
),
CreateOption
:
"attach"
,
ManagedDisk
:
&
compute
preview
.
ManagedDiskParameters
{
ManagedDisk
:
&
compute
.
ManagedDiskParameters
{
ID
:
&
diskURI
,
},
})
}
else
{
disks
=
append
(
disks
,
compute
preview
.
DataDisk
{
compute
.
DataDisk
{
Name
:
&
diskName
,
Vhd
:
&
compute
preview
.
VirtualHardDisk
{
Vhd
:
&
compute
.
VirtualHardDisk
{
URI
:
&
diskURI
,
},
Lun
:
&
lun
,
Caching
:
compute
preview
.
CachingTypes
(
cachingMode
),
Caching
:
compute
.
CachingTypes
(
cachingMode
),
CreateOption
:
"attach"
,
})
}
...
...
pkg/cloudprovider/providers/azure/azure_fakes.go
View file @
079f9b85
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
079f9b85
...
...
@@ -438,7 +438,7 @@ func (az *Cloud) ensurePublicIPExists(service *v1.Service, pipName string, domai
DomainNameLabel
:
&
domainNameLabel
,
}
}
pip
.
Tags
=
&
map
[
string
]
*
string
{
"service"
:
&
serviceName
}
pip
.
Tags
=
map
[
string
]
*
string
{
"service"
:
&
serviceName
}
if
az
.
useStandardLoadBalancer
()
{
pip
.
Sku
=
&
network
.
PublicIPAddressSku
{
Name
:
network
.
PublicIPAddressSkuNameStandard
,
...
...
@@ -1202,8 +1202,8 @@ func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, want
for
_
,
pip
:=
range
pips
{
if
pip
.
Tags
!=
nil
&&
(
*
pip
.
Tags
)[
"service"
]
!=
nil
&&
*
(
*
pip
.
Tags
)[
"service"
]
==
serviceName
{
(
pip
.
Tags
)[
"service"
]
!=
nil
&&
*
(
pip
.
Tags
)[
"service"
]
==
serviceName
{
// We need to process for pips belong to this service
pipName
:=
*
pip
.
Name
if
wantLb
&&
!
isInternal
&&
pipName
==
desiredPipName
{
...
...
pkg/cloudprovider/providers/azure/azure_managedDiskController.go
View file @
079f9b85
...
...
@@ -20,8 +20,8 @@ import (
"path"
"strings"
"github.com/Azure/azure-sdk-for-go/
arm/disk
"
storage
"github.com/Azure/azure-sdk-for-go/arm
/storage"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01/compute
"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01
/storage"
"github.com/golang/glog"
kwait
"k8s.io/apimachinery/pkg/util/wait"
)
...
...
@@ -54,18 +54,19 @@ func (c *ManagedDiskController) CreateManagedDisk(diskName string, storageAccoun
}
diskSizeGB
:=
int32
(
sizeGB
)
model
:=
disk
.
Model
{
model
:=
compute
.
Disk
{
Location
:
&
c
.
common
.
location
,
Tags
:
&
newTags
,
Properties
:
&
disk
.
Properties
{
AccountType
:
disk
.
StorageAccountTypes
(
storageAccountType
),
Tags
:
newTags
,
Sku
:
&
compute
.
DiskSku
{
Name
:
compute
.
StorageAccountTypes
(
storageAccountType
),
},
DiskProperties
:
&
compute
.
DiskProperties
{
DiskSizeGB
:
&
diskSizeGB
,
CreationData
:
&
disk
.
CreationData
{
CreateOption
:
disk
.
Empty
},
CreationData
:
&
compute
.
CreationData
{
CreateOption
:
compute
.
Empty
},
}}
cancel
:=
make
(
chan
struct
{})
respChan
,
errChan
:=
c
.
common
.
cloud
.
DisksClient
.
CreateOrUpdate
(
c
.
common
.
resourceGroup
,
diskName
,
model
,
cancel
)
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
_
,
err
:=
c
.
common
.
cloud
.
DisksClient
.
CreateOrUpdate
(
ctx
,
c
.
common
.
resourceGroup
,
diskName
,
model
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -99,10 +100,10 @@ func (c *ManagedDiskController) CreateManagedDisk(diskName string, storageAccoun
//DeleteManagedDisk : delete managed disk
func
(
c
*
ManagedDiskController
)
DeleteManagedDisk
(
diskURI
string
)
error
{
diskName
:=
path
.
Base
(
diskURI
)
c
ancel
:=
make
(
chan
struct
{}
)
respChan
,
errChan
:=
c
.
common
.
cloud
.
DisksClient
.
Delete
(
c
.
common
.
resourceGroup
,
diskName
,
cancel
)
<-
respChan
err
:=
<-
errChan
c
tx
,
cancel
:=
getContextWithCancel
(
)
defer
cancel
(
)
_
,
err
:=
c
.
common
.
cloud
.
DisksClient
.
Delete
(
ctx
,
c
.
common
.
resourceGroup
,
diskName
)
if
err
!=
nil
{
return
err
}
...
...
@@ -116,13 +117,16 @@ func (c *ManagedDiskController) DeleteManagedDisk(diskURI string) error {
// return: disk provisionState, diskID, error
func
(
c
*
ManagedDiskController
)
getDisk
(
diskName
string
)
(
string
,
string
,
error
)
{
result
,
err
:=
c
.
common
.
cloud
.
DisksClient
.
Get
(
c
.
common
.
resourceGroup
,
diskName
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
result
,
err
:=
c
.
common
.
cloud
.
DisksClient
.
Get
(
ctx
,
c
.
common
.
resourceGroup
,
diskName
)
if
err
!=
nil
{
return
""
,
""
,
err
}
if
result
.
Properties
!=
nil
&&
(
*
result
.
Properties
)
.
ProvisioningState
!=
nil
{
return
*
(
*
result
.
Properties
)
.
ProvisioningState
,
*
result
.
ID
,
nil
if
result
.
DiskProperties
!=
nil
&&
(
*
result
.
Disk
Properties
)
.
ProvisioningState
!=
nil
{
return
*
(
*
result
.
Disk
Properties
)
.
ProvisioningState
,
*
result
.
ID
,
nil
}
return
""
,
""
,
err
...
...
pkg/cloudprovider/providers/azure/azure_standard.go
View file @
079f9b85
...
...
@@ -28,7 +28,7 @@ import (
"k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/cloudprovider"
"github.com/Azure/azure-sdk-for-go/
arm
/compute"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01
/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog"
...
...
pkg/cloudprovider/providers/azure/azure_storage.go
View file @
079f9b85
...
...
@@ -19,7 +19,7 @@ package azure
import
(
"fmt"
"github.com/Azure/azure-sdk-for-go/
arm
/storage"
"github.com/Azure/azure-sdk-for-go/
services/storage/mgmt/2017-10-01
/storage"
"github.com/golang/glog"
)
...
...
pkg/cloudprovider/providers/azure/azure_storage_test.go
View file @
079f9b85
...
...
@@ -19,7 +19,7 @@ package azure
import
(
"testing"
"github.com/Azure/azure-sdk-for-go/
arm
/storage"
"github.com/Azure/azure-sdk-for-go/
services/storage/mgmt/2017-10-01
/storage"
)
func
TestCreateFileShare
(
t
*
testing
.
T
)
{
...
...
pkg/cloudprovider/providers/azure/azure_storageaccount.go
View file @
079f9b85
...
...
@@ -20,7 +20,7 @@ import (
"fmt"
"strings"
"github.com/Azure/azure-sdk-for-go/
arm
/storage"
"github.com/Azure/azure-sdk-for-go/
services/storage/mgmt/2017-10-01
/storage"
"github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog"
)
...
...
@@ -31,7 +31,9 @@ type accountWithLocation struct {
// getStorageAccounts gets name, type, location of all storage accounts in a resource group which matches matchingAccountType, matchingLocation
func
(
az
*
Cloud
)
getStorageAccounts
(
matchingAccountType
,
matchingLocation
string
)
([]
accountWithLocation
,
error
)
{
result
,
err
:=
az
.
StorageAccountClient
.
ListByResourceGroup
(
az
.
ResourceGroup
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
result
,
err
:=
az
.
StorageAccountClient
.
ListByResourceGroup
(
ctx
,
az
.
ResourceGroup
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -60,7 +62,10 @@ func (az *Cloud) getStorageAccounts(matchingAccountType, matchingLocation string
// getStorageAccesskey gets the storage account access key
func
(
az
*
Cloud
)
getStorageAccesskey
(
account
string
)
(
string
,
error
)
{
result
,
err
:=
az
.
StorageAccountClient
.
ListKeys
(
az
.
ResourceGroup
,
account
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
result
,
err
:=
az
.
StorageAccountClient
.
ListKeys
(
ctx
,
az
.
ResourceGroup
,
account
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -108,12 +113,12 @@ func (az *Cloud) ensureStorageAccount(accountName, accountType, location, genAcc
accountName
,
az
.
ResourceGroup
,
location
,
accountType
)
cp
:=
storage
.
AccountCreateParameters
{
Sku
:
&
storage
.
Sku
{
Name
:
storage
.
SkuName
(
accountType
)},
Tags
:
&
map
[
string
]
*
string
{
"created-by"
:
to
.
StringPtr
(
"azure"
)},
Tags
:
map
[
string
]
*
string
{
"created-by"
:
to
.
StringPtr
(
"azure"
)},
Location
:
&
location
}
cancel
:=
make
(
chan
struct
{})
_
,
errchan
:=
az
.
StorageAccountClient
.
Create
(
az
.
ResourceGroup
,
accountName
,
cp
,
cancel
)
err
:=
<-
errchan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
_
,
err
:=
az
.
StorageAccountClient
.
Create
(
ctx
,
az
.
ResourceGroup
,
accountName
,
cp
)
if
err
!=
nil
{
return
""
,
""
,
fmt
.
Errorf
(
fmt
.
Sprintf
(
"Failed to create storage account %s, error: %s"
,
accountName
,
err
))
}
...
...
pkg/cloudprovider/providers/azure/azure_storageaccount_test.go
View file @
079f9b85
...
...
@@ -20,7 +20,7 @@ import (
"fmt"
"testing"
"github.com/Azure/azure-sdk-for-go/
arm
/storage"
"github.com/Azure/azure-sdk-for-go/
services/storage/mgmt/2017-10-01
/storage"
)
func
TestGetStorageAccessKeys
(
t
*
testing
.
T
)
{
...
...
pkg/cloudprovider/providers/azure/azure_test.go
View file @
079f9b85
...
...
@@ -35,7 +35,7 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure/auth"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
"github.com/Azure/azure-sdk-for-go/
arm
/compute"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01
/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/go-autorest/autorest/to"
"github.com/stretchr/testify/assert"
...
...
@@ -1067,8 +1067,10 @@ func getClusterResources(az *Cloud, vmCount int, availabilitySetCount int) (clus
},
}
_
,
errChan
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
az
.
Config
.
ResourceGroup
,
vmName
,
newVM
,
nil
)
if
err
:=
<-
errChan
;
err
!=
nil
{
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
_
,
err
:=
az
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
az
.
Config
.
ResourceGroup
,
vmName
,
newVM
)
if
err
!=
nil
{
}
// add to kubernetes
newNode
:=
&
v1
.
Node
{
...
...
@@ -1314,12 +1316,12 @@ func validatePublicIP(t *testing.T, publicIP *network.PublicIPAddress, service *
t
.
Errorf
(
"Expected publicIP resource exists, when it is not an internal service"
)
}
if
publicIP
.
Tags
==
nil
||
(
*
publicIP
.
Tags
)
[
"service"
]
==
nil
{
if
publicIP
.
Tags
==
nil
||
publicIP
.
Tags
[
"service"
]
==
nil
{
t
.
Errorf
(
"Expected publicIP resource has tags[service]"
)
}
serviceName
:=
getServiceName
(
service
)
if
serviceName
!=
*
(
*
publicIP
.
Tags
)[
"service"
]
{
if
serviceName
!=
*
(
publicIP
.
Tags
[
"service"
])
{
t
.
Errorf
(
"Expected publicIP resource has matching tags[service]"
)
}
// We cannot use service.Spec.LoadBalancerIP to compare with
...
...
pkg/cloudprovider/providers/azure/azure_vmsets.go
View file @
079f9b85
...
...
@@ -17,7 +17,7 @@ limitations under the License.
package
azure
import
(
"github.com/Azure/azure-sdk-for-go/
arm
/compute"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01
/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"k8s.io/api/core/v1"
...
...
pkg/cloudprovider/providers/azure/azure_vmss.go
View file @
079f9b85
...
...
@@ -24,7 +24,7 @@ import (
"strconv"
"strings"
computepreview
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog"
...
...
@@ -91,7 +91,7 @@ func newScaleSet(az *Cloud) (VMSet, error) {
// getVmssVM gets virtualMachineScaleSetVM by nodeName from cache.
// It returns cloudprovider.InstanceNotFound if node does not belong to any scale sets.
func
(
ss
*
scaleSet
)
getVmssVM
(
nodeName
string
)
(
ssName
,
instanceID
string
,
vm
compute
preview
.
VirtualMachineScaleSetVM
,
err
error
)
{
func
(
ss
*
scaleSet
)
getVmssVM
(
nodeName
string
)
(
ssName
,
instanceID
string
,
vm
compute
.
VirtualMachineScaleSetVM
,
err
error
)
{
instanceID
,
err
=
getScaleSetVMInstanceID
(
nodeName
)
if
err
!=
nil
{
return
ssName
,
instanceID
,
vm
,
err
...
...
@@ -117,12 +117,12 @@ func (ss *scaleSet) getVmssVM(nodeName string) (ssName, instanceID string, vm co
return
ssName
,
instanceID
,
vm
,
cloudprovider
.
InstanceNotFound
}
return
ssName
,
instanceID
,
*
(
cachedVM
.
(
*
compute
preview
.
VirtualMachineScaleSetVM
)),
nil
return
ssName
,
instanceID
,
*
(
cachedVM
.
(
*
compute
.
VirtualMachineScaleSetVM
)),
nil
}
// getCachedVirtualMachineByInstanceID gets scaleSetVMInfo from cache.
// The node must belong to one of scale sets.
func
(
ss
*
scaleSet
)
getVmssVMByInstanceID
(
scaleSetName
,
instanceID
string
)
(
vm
compute
preview
.
VirtualMachineScaleSetVM
,
err
error
)
{
func
(
ss
*
scaleSet
)
getVmssVMByInstanceID
(
scaleSetName
,
instanceID
string
)
(
vm
compute
.
VirtualMachineScaleSetVM
,
err
error
)
{
vmName
:=
ss
.
makeVmssVMName
(
scaleSetName
,
instanceID
)
cachedVM
,
err
:=
ss
.
vmssVMCache
.
Get
(
vmName
)
if
err
!=
nil
{
...
...
@@ -134,7 +134,7 @@ func (ss *scaleSet) getVmssVMByInstanceID(scaleSetName, instanceID string) (vm c
return
vm
,
cloudprovider
.
InstanceNotFound
}
return
*
(
cachedVM
.
(
*
compute
preview
.
VirtualMachineScaleSetVM
)),
nil
return
*
(
cachedVM
.
(
*
compute
.
VirtualMachineScaleSetVM
)),
nil
}
// GetInstanceIDByNodeName gets the cloud provider ID by node name.
...
...
@@ -265,7 +265,7 @@ func (ss *scaleSet) GetIPByNodeName(nodeName, vmSetName string) (string, string,
}
// This returns the full identifier of the primary NIC for the given VM.
func
(
ss
*
scaleSet
)
getPrimaryInterfaceID
(
machine
compute
preview
.
VirtualMachineScaleSetVM
)
(
string
,
error
)
{
func
(
ss
*
scaleSet
)
getPrimaryInterfaceID
(
machine
compute
.
VirtualMachineScaleSetVM
)
(
string
,
error
)
{
if
len
(
*
machine
.
NetworkProfile
.
NetworkInterfaces
)
==
1
{
return
*
(
*
machine
.
NetworkProfile
.
NetworkInterfaces
)[
0
]
.
ID
,
nil
}
...
...
@@ -327,12 +327,12 @@ func (ss *scaleSet) listScaleSets() ([]string, error) {
}
// listScaleSetVMs lists VMs belonging to the specified scale set.
func
(
ss
*
scaleSet
)
listScaleSetVMs
(
scaleSetName
string
)
([]
compute
preview
.
VirtualMachineScaleSetVM
,
error
)
{
func
(
ss
*
scaleSet
)
listScaleSetVMs
(
scaleSetName
string
)
([]
compute
.
VirtualMachineScaleSetVM
,
error
)
{
var
err
error
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
allVMs
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
List
(
ctx
,
ss
.
ResourceGroup
,
scaleSetName
,
""
,
""
,
string
(
compute
preview
.
InstanceView
))
allVMs
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
List
(
ctx
,
ss
.
ResourceGroup
,
scaleSetName
,
""
,
""
,
string
(
compute
.
InstanceView
))
if
err
!=
nil
{
glog
.
Errorf
(
"VirtualMachineScaleSetVMsClient.List failed: %v"
,
err
)
return
nil
,
err
...
...
@@ -469,8 +469,8 @@ func (ss *scaleSet) GetPrimaryInterface(nodeName, vmSetName string) (network.Int
}
// getScaleSetWithRetry gets scale set with exponential backoff retry
func
(
ss
*
scaleSet
)
getScaleSetWithRetry
(
name
string
)
(
compute
preview
.
VirtualMachineScaleSet
,
bool
,
error
)
{
var
result
compute
preview
.
VirtualMachineScaleSet
func
(
ss
*
scaleSet
)
getScaleSetWithRetry
(
name
string
)
(
compute
.
VirtualMachineScaleSet
,
bool
,
error
)
{
var
result
compute
.
VirtualMachineScaleSet
var
exists
bool
err
:=
wait
.
ExponentialBackoff
(
ss
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
...
...
@@ -483,7 +483,7 @@ func (ss *scaleSet) getScaleSetWithRetry(name string) (computepreview.VirtualMac
if
cached
!=
nil
{
exists
=
true
result
=
*
(
cached
.
(
*
compute
preview
.
VirtualMachineScaleSet
))
result
=
*
(
cached
.
(
*
compute
.
VirtualMachineScaleSet
))
}
return
true
,
nil
...
...
@@ -493,7 +493,7 @@ func (ss *scaleSet) getScaleSetWithRetry(name string) (computepreview.VirtualMac
}
// getPrimaryNetworkConfiguration gets primary network interface configuration for scale sets.
func
(
ss
*
scaleSet
)
getPrimaryNetworkConfiguration
(
networkConfigurationList
*
[]
compute
preview
.
VirtualMachineScaleSetNetworkConfiguration
,
scaleSetName
string
)
(
*
computepreview
.
VirtualMachineScaleSetNetworkConfiguration
,
error
)
{
func
(
ss
*
scaleSet
)
getPrimaryNetworkConfiguration
(
networkConfigurationList
*
[]
compute
.
VirtualMachineScaleSetNetworkConfiguration
,
scaleSetName
string
)
(
*
compute
.
VirtualMachineScaleSetNetworkConfiguration
,
error
)
{
networkConfigurations
:=
*
networkConfigurationList
if
len
(
networkConfigurations
)
==
1
{
return
&
networkConfigurations
[
0
],
nil
...
...
@@ -509,7 +509,7 @@ func (ss *scaleSet) getPrimaryNetworkConfiguration(networkConfigurationList *[]c
return
nil
,
fmt
.
Errorf
(
"failed to find a primary network configuration for the scale set %q"
,
scaleSetName
)
}
func
(
ss
*
scaleSet
)
getPrimaryIPConfigForScaleSet
(
config
*
compute
preview
.
VirtualMachineScaleSetNetworkConfiguration
,
scaleSetName
string
)
(
*
computepreview
.
VirtualMachineScaleSetIPConfiguration
,
error
)
{
func
(
ss
*
scaleSet
)
getPrimaryIPConfigForScaleSet
(
config
*
compute
.
VirtualMachineScaleSetNetworkConfiguration
,
scaleSetName
string
)
(
*
compute
.
VirtualMachineScaleSetIPConfiguration
,
error
)
{
ipConfigurations
:=
*
config
.
IPConfigurations
if
len
(
ipConfigurations
)
==
1
{
return
&
ipConfigurations
[
0
],
nil
...
...
@@ -526,7 +526,7 @@ func (ss *scaleSet) getPrimaryIPConfigForScaleSet(config *computepreview.Virtual
}
// createOrUpdateVMSSWithRetry invokes ss.VirtualMachineScaleSetsClient.CreateOrUpdate with exponential backoff retry.
func
(
ss
*
scaleSet
)
createOrUpdateVMSSWithRetry
(
virtualMachineScaleSet
compute
preview
.
VirtualMachineScaleSet
)
error
{
func
(
ss
*
scaleSet
)
createOrUpdateVMSSWithRetry
(
virtualMachineScaleSet
compute
.
VirtualMachineScaleSet
)
error
{
return
wait
.
ExponentialBackoff
(
ss
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
...
...
@@ -537,7 +537,7 @@ func (ss *scaleSet) createOrUpdateVMSSWithRetry(virtualMachineScaleSet computepr
}
// updateVMSSInstancesWithRetry invokes ss.VirtualMachineScaleSetsClient.UpdateInstances with exponential backoff retry.
func
(
ss
*
scaleSet
)
updateVMSSInstancesWithRetry
(
scaleSetName
string
,
vmInstanceIDs
compute
preview
.
VirtualMachineScaleSetVMInstanceRequiredIDs
)
error
{
func
(
ss
*
scaleSet
)
updateVMSSInstancesWithRetry
(
scaleSetName
string
,
vmInstanceIDs
compute
.
VirtualMachineScaleSetVMInstanceRequiredIDs
)
error
{
return
wait
.
ExponentialBackoff
(
ss
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
...
...
@@ -611,7 +611,7 @@ func (ss *scaleSet) ensureHostsInVMSetPool(serviceName string, backendPoolID str
// Update primary IP configuration's LoadBalancerBackendAddressPools.
foundPool
:=
false
newBackendPools
:=
[]
compute
preview
.
SubResource
{}
newBackendPools
:=
[]
compute
.
SubResource
{}
if
primaryIPConfiguration
.
LoadBalancerBackendAddressPools
!=
nil
{
newBackendPools
=
*
primaryIPConfiguration
.
LoadBalancerBackendAddressPools
}
...
...
@@ -641,7 +641,7 @@ func (ss *scaleSet) ensureHostsInVMSetPool(serviceName string, backendPoolID str
}
newBackendPools
=
append
(
newBackendPools
,
compute
preview
.
SubResource
{
compute
.
SubResource
{
ID
:
to
.
StringPtr
(
backendPoolID
),
})
primaryIPConfiguration
.
LoadBalancerBackendAddressPools
=
&
newBackendPools
...
...
@@ -665,7 +665,7 @@ func (ss *scaleSet) ensureHostsInVMSetPool(serviceName string, backendPoolID str
}
// Update instances to latest VMSS model.
vmInstanceIDs
:=
compute
preview
.
VirtualMachineScaleSetVMInstanceRequiredIDs
{
vmInstanceIDs
:=
compute
.
VirtualMachineScaleSetVMInstanceRequiredIDs
{
InstanceIds
:
&
instanceIDs
,
}
ctx
,
cancel
:=
getContextWithCancel
()
...
...
@@ -758,7 +758,7 @@ func (ss *scaleSet) ensureScaleSetBackendPoolDeleted(poolID, ssName string) erro
return
nil
}
existingBackendPools
:=
*
primaryIPConfiguration
.
LoadBalancerBackendAddressPools
newBackendPools
:=
[]
compute
preview
.
SubResource
{}
newBackendPools
:=
[]
compute
.
SubResource
{}
foundPool
:=
false
for
i
:=
len
(
existingBackendPools
)
-
1
;
i
>=
0
;
i
--
{
curPool
:=
existingBackendPools
[
i
]
...
...
@@ -794,7 +794,7 @@ func (ss *scaleSet) ensureScaleSetBackendPoolDeleted(poolID, ssName string) erro
// Update instances to latest VMSS model.
instanceIDs
:=
[]
string
{
"*"
}
vmInstanceIDs
:=
compute
preview
.
VirtualMachineScaleSetVMInstanceRequiredIDs
{
vmInstanceIDs
:=
compute
.
VirtualMachineScaleSetVMInstanceRequiredIDs
{
InstanceIds
:
&
instanceIDs
,
}
instanceCtx
,
instanceCancel
:=
getContextWithCancel
()
...
...
pkg/cloudprovider/providers/azure/azure_vmss_test.go
View file @
079f9b85
...
...
@@ -20,7 +20,7 @@ import (
"fmt"
"testing"
compute
preview
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
compute
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/stretchr/testify/assert"
)
...
...
@@ -37,8 +37,8 @@ func newTestScaleSet(scaleSetName string, vmList []string) (*scaleSet, error) {
func
setTestVirtualMachineCloud
(
ss
*
Cloud
,
scaleSetName
string
,
vmList
[]
string
)
{
virtualMachineScaleSetsClient
:=
newFakeVirtualMachineScaleSetsClient
()
scaleSets
:=
make
(
map
[
string
]
map
[
string
]
compute
preview
.
VirtualMachineScaleSet
)
scaleSets
[
"rg"
]
=
map
[
string
]
compute
preview
.
VirtualMachineScaleSet
{
scaleSets
:=
make
(
map
[
string
]
map
[
string
]
compute
.
VirtualMachineScaleSet
)
scaleSets
[
"rg"
]
=
map
[
string
]
compute
.
VirtualMachineScaleSet
{
scaleSetName
:
{
Name
:
&
scaleSetName
,
},
...
...
@@ -46,24 +46,24 @@ func setTestVirtualMachineCloud(ss *Cloud, scaleSetName string, vmList []string)
virtualMachineScaleSetsClient
.
setFakeStore
(
scaleSets
)
virtualMachineScaleSetVMsClient
:=
newFakeVirtualMachineScaleSetVMsClient
()
ssVMs
:=
make
(
map
[
string
]
map
[
string
]
compute
preview
.
VirtualMachineScaleSetVM
)
ssVMs
[
"rg"
]
=
make
(
map
[
string
]
compute
preview
.
VirtualMachineScaleSetVM
)
ssVMs
:=
make
(
map
[
string
]
map
[
string
]
compute
.
VirtualMachineScaleSetVM
)
ssVMs
[
"rg"
]
=
make
(
map
[
string
]
compute
.
VirtualMachineScaleSetVM
)
for
i
:=
range
vmList
{
ID
:=
fmt
.
Sprintf
(
"/subscriptions/script/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%d"
,
scaleSetName
,
i
)
nodeName
:=
vmList
[
i
]
instanceID
:=
fmt
.
Sprintf
(
"%d"
,
i
)
vmName
:=
fmt
.
Sprintf
(
"%s_%s"
,
scaleSetName
,
instanceID
)
networkInterfaces
:=
[]
compute
preview
.
NetworkInterfaceReference
{
networkInterfaces
:=
[]
compute
.
NetworkInterfaceReference
{
{
ID
:
&
nodeName
,
},
}
ssVMs
[
"rg"
][
vmName
]
=
compute
preview
.
VirtualMachineScaleSetVM
{
VirtualMachineScaleSetVMProperties
:
&
compute
preview
.
VirtualMachineScaleSetVMProperties
{
OsProfile
:
&
compute
preview
.
OSProfile
{
ssVMs
[
"rg"
][
vmName
]
=
compute
.
VirtualMachineScaleSetVM
{
VirtualMachineScaleSetVMProperties
:
&
compute
.
VirtualMachineScaleSetVMProperties
{
OsProfile
:
&
compute
.
OSProfile
{
ComputerName
:
&
nodeName
,
},
NetworkProfile
:
&
compute
preview
.
NetworkProfile
{
NetworkProfile
:
&
compute
.
NetworkProfile
{
NetworkInterfaces
:
&
networkInterfaces
,
},
},
...
...
pkg/cloudprovider/providers/azure/azure_wrap.go
View file @
079f9b85
...
...
@@ -22,7 +22,7 @@ import (
"strings"
"time"
"github.com/Azure/azure-sdk-for-go/
arm
/compute"
"github.com/Azure/azure-sdk-for-go/
services/compute/mgmt/2017-12-01
/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/go-autorest/autorest"
...
...
@@ -174,7 +174,9 @@ func (az *Cloud) newVMCache() (*timedCache, error) {
// case we do get instance view every time to fulfill the azure_zones requirement without hitting
// throttling.
// Consider adding separate parameter for controlling 'InstanceView' once node update issue #56276 is fixed
vm
,
err
:=
az
.
VirtualMachinesClient
.
Get
(
az
.
ResourceGroup
,
key
,
compute
.
InstanceView
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
vm
,
err
:=
az
.
VirtualMachinesClient
.
Get
(
ctx
,
az
.
ResourceGroup
,
key
,
compute
.
InstanceView
)
exists
,
realErr
:=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
nil
,
realErr
...
...
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