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
cd293025
Commit
cd293025
authored
Nov 28, 2018
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix detch azure disk issue by clean vm cache
parent
5dfe48b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
azure_controller_standard.go
...loudprovider/providers/azure/azure_controller_standard.go
+7
-4
azure_controller_vmss.go
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
+10
-7
No files found.
pkg/cloudprovider/providers/azure/azure_controller_standard.go
View file @
cd293025
...
@@ -77,6 +77,9 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
...
@@ -77,6 +77,9 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
// Invalidate the cache right after updating
defer
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
_
,
err
=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
_
,
err
=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"azureDisk - attach disk(%s) failed, err: %v"
,
diskName
,
err
)
klog
.
Errorf
(
"azureDisk - attach disk(%s) failed, err: %v"
,
diskName
,
err
)
...
@@ -88,8 +91,6 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
...
@@ -88,8 +91,6 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
}
}
}
else
{
}
else
{
klog
.
V
(
2
)
.
Infof
(
"azureDisk - attach disk(%s) succeeded"
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - attach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
}
}
return
err
return
err
}
}
...
@@ -139,13 +140,15 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
...
@@ -139,13 +140,15 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk(%s)"
,
nodeResourceGroup
,
vmName
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk(%s)"
,
nodeResourceGroup
,
vmName
,
diskName
)
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
// Invalidate the cache right after updating
defer
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
_
,
err
=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
_
,
err
=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"azureDisk - detach disk(%s) failed, err: %v"
,
diskName
,
err
)
klog
.
Errorf
(
"azureDisk - detach disk(%s) failed, err: %v"
,
diskName
,
err
)
}
else
{
}
else
{
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk(%s) succeeded"
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
}
}
return
err
return
err
}
}
...
...
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
View file @
cd293025
...
@@ -71,8 +71,12 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
...
@@ -71,8 +71,12 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
klog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
// Invalidate the cache right after updating
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
defer
ss
.
vmssVMCache
.
Delete
(
key
)
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
,
vm
)
if
err
!=
nil
{
if
err
!=
nil
{
detail
:=
err
.
Error
()
detail
:=
err
.
Error
()
...
@@ -83,9 +87,6 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
...
@@ -83,9 +87,6 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
}
}
}
else
{
}
else
{
klog
.
V
(
2
)
.
Infof
(
"azureDisk - attach disk(%s) succeeded"
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - attach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
ss
.
vmssVMCache
.
Delete
(
key
)
}
}
return
err
return
err
}
}
...
@@ -128,15 +129,17 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
...
@@ -128,15 +129,17 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
vm
.
StorageProfile
.
DataDisks
=
&
disks
vm
.
StorageProfile
.
DataDisks
=
&
disks
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
// Invalidate the cache right after updating
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
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
,
vm
)
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
{
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk(%s) succeeded"
,
diskName
)
klog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
ss
.
vmssVMCache
.
Delete
(
key
)
}
}
return
err
return
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