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
11527d69
Commit
11527d69
authored
Dec 12, 2018
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix race condition when attach azure disk in vmss
fix gofmt issue
parent
598a0198
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
azure_controller_vmss.go
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
+25
-4
No files found.
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
View file @
11527d69
...
@@ -67,7 +67,17 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
...
@@ -67,7 +67,17 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
CreateOption
:
"attach"
,
CreateOption
:
"attach"
,
})
})
}
}
vm
.
StorageProfile
.
DataDisks
=
&
disks
newVM
:=
compute
.
VirtualMachineScaleSetVM
{
Sku
:
vm
.
Sku
,
Location
:
vm
.
Location
,
VirtualMachineScaleSetVMProperties
:
&
compute
.
VirtualMachineScaleSetVMProperties
{
HardwareProfile
:
vm
.
HardwareProfile
,
StorageProfile
:
&
compute
.
StorageProfile
{
OsDisk
:
vm
.
StorageProfile
.
OsDisk
,
DataDisks
:
&
disks
,
},
},
}
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
...
@@ -77,7 +87,7 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
...
@@ -77,7 +87,7 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
defer
ss
.
vmssVMCache
.
Delete
(
key
)
defer
ss
.
vmssVMCache
.
Delete
(
key
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
_
,
err
=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
)
_
,
err
=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
if
err
!=
nil
{
if
err
!=
nil
{
detail
:=
err
.
Error
()
detail
:=
err
.
Error
()
if
strings
.
Contains
(
detail
,
errLeaseFailed
)
||
strings
.
Contains
(
detail
,
errDiskBlobNotFound
)
{
if
strings
.
Contains
(
detail
,
errLeaseFailed
)
||
strings
.
Contains
(
detail
,
errDiskBlobNotFound
)
{
...
@@ -126,7 +136,18 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
...
@@ -126,7 +136,18 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
return
fmt
.
Errorf
(
"detach azure disk failure, disk %s not found, diskURI: %s"
,
diskName
,
diskURI
)
return
fmt
.
Errorf
(
"detach azure disk failure, disk %s not found, diskURI: %s"
,
diskName
,
diskURI
)
}
}
vm
.
StorageProfile
.
DataDisks
=
&
disks
newVM
:=
compute
.
VirtualMachineScaleSetVM
{
Sku
:
vm
.
Sku
,
Location
:
vm
.
Location
,
VirtualMachineScaleSetVMProperties
:
&
compute
.
VirtualMachineScaleSetVMProperties
{
HardwareProfile
:
vm
.
HardwareProfile
,
StorageProfile
:
&
compute
.
StorageProfile
{
OsDisk
:
vm
.
StorageProfile
.
OsDisk
,
DataDisks
:
&
disks
,
},
},
}
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
...
@@ -135,7 +156,7 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
...
@@ -135,7 +156,7 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
defer
ss
.
vmssVMCache
.
Delete
(
key
)
defer
ss
.
vmssVMCache
.
Delete
(
key
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
_
,
err
=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
)
_
,
err
=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
newVM
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"azureDisk - detach disk(%s) from %s failed, err: %v"
,
diskName
,
nodeName
,
err
)
klog
.
Errorf
(
"azureDisk - detach disk(%s) from %s failed, err: %v"
,
diskName
,
nodeName
,
err
)
}
else
{
}
else
{
...
...
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