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
0f3dff25
Unverified
Commit
0f3dff25
authored
Nov 02, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70568 from andyzhangx/remove-retry-azuredisk
remove retry operation on attach/detach azure disk
parents
33555943
8abadbe3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
55 deletions
+19
-55
azure_controller_standard.go
...loudprovider/providers/azure/azure_controller_standard.go
+10
-28
azure_controller_vmss.go
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
+9
-27
No files found.
pkg/cloudprovider/providers/azure/azure_controller_standard.go
View file @
0f3dff25
...
@@ -73,28 +73,19 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
...
@@ -73,28 +73,19 @@ func (as *availabilitySet) AttachDisk(isManagedDisk bool, diskName, diskURI stri
},
},
},
},
}
}
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk
"
,
nodeResourceGroup
,
vm
Name
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk
(%s)"
,
nodeResourceGroup
,
vmName
,
disk
Name
)
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
resp
,
err
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
if
_
,
err
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
);
err
!=
nil
{
if
as
.
CloudProviderBackoff
&&
shouldRetryHTTPRequest
(
resp
,
err
)
{
glog
.
Errorf
(
"azureDisk - attach disk(%s) failed, err: %v"
,
diskName
,
err
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) backing off: vm(%s)"
,
nodeResourceGroup
,
vmName
)
retryErr
:=
as
.
CreateOrUpdateVMWithRetry
(
nodeResourceGroup
,
vmName
,
newVM
)
if
retryErr
!=
nil
{
err
=
retryErr
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) abort backoff: vm(%s)"
,
nodeResourceGroup
,
vmName
)
}
}
if
err
!=
nil
{
glog
.
Errorf
(
"azureDisk - azure attach failed, err: %v"
,
err
)
detail
:=
err
.
Error
()
detail
:=
err
.
Error
()
if
strings
.
Contains
(
detail
,
errLeaseFailed
)
||
strings
.
Contains
(
detail
,
errDiskBlobNotFound
)
{
if
strings
.
Contains
(
detail
,
errLeaseFailed
)
||
strings
.
Contains
(
detail
,
errDiskBlobNotFound
)
{
// if lease cannot be acquired or disk not found, immediately detach the disk and return the original error
// if lease cannot be acquired or disk not found, immediately detach the disk and return the original error
glog
.
Infof
(
"azureDisk - err %s, try detach"
,
detail
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - err %v, try detach disk(%s)"
,
err
,
diskName
)
as
.
DetachDiskByName
(
diskName
,
diskURI
,
nodeName
)
as
.
DetachDiskByName
(
diskName
,
diskURI
,
nodeName
)
}
}
}
else
{
}
else
{
glog
.
V
(
4
)
.
Info
(
"azureDisk - azure attach succeeded"
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - attach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
// Invalidate the cache right after updating
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
}
}
...
@@ -124,7 +115,7 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
...
@@ -124,7 +115,7 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
(
disk
.
Vhd
!=
nil
&&
disk
.
Vhd
.
URI
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
Vhd
.
URI
==
diskURI
)
||
(
disk
.
Vhd
!=
nil
&&
disk
.
Vhd
.
URI
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
Vhd
.
URI
==
diskURI
)
||
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
ManagedDisk
.
ID
==
diskURI
)
{
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
ManagedDisk
.
ID
==
diskURI
)
{
// found the disk
// found the disk
glog
.
V
(
4
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
disks
=
append
(
disks
[
:
i
],
disks
[
i
+
1
:
]
...
)
disks
=
append
(
disks
[
:
i
],
disks
[
i
+
1
:
]
...
)
bFoundDisk
=
true
bFoundDisk
=
true
break
break
...
@@ -143,22 +134,13 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
...
@@ -143,22 +134,13 @@ func (as *availabilitySet) DetachDiskByName(diskName, diskURI string, nodeName t
},
},
},
},
}
}
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk
"
,
nodeResourceGroup
,
vm
Name
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk
(%s)"
,
nodeResourceGroup
,
vmName
,
disk
Name
)
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
resp
,
err
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
)
if
_
,
err
:=
as
.
VirtualMachinesClient
.
CreateOrUpdate
(
ctx
,
nodeResourceGroup
,
vmName
,
newVM
);
err
!=
nil
{
if
as
.
CloudProviderBackoff
&&
shouldRetryHTTPRequest
(
resp
,
err
)
{
glog
.
Errorf
(
"azureDisk - detach disk(%s) failed, err: %v"
,
diskName
,
err
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) backing off: vm(%s)"
,
nodeResourceGroup
,
vmName
)
retryErr
:=
as
.
CreateOrUpdateVMWithRetry
(
nodeResourceGroup
,
vmName
,
newVM
)
if
retryErr
!=
nil
{
err
=
retryErr
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) abort backoff: vm(%s)"
,
nodeResourceGroup
,
vmName
)
}
}
if
err
!=
nil
{
glog
.
Errorf
(
"azureDisk - azure disk detach failed, err: %v"
,
err
)
}
else
{
}
else
{
glog
.
V
(
4
)
.
Info
(
"azureDisk - azure disk detach succeeded"
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
// Invalidate the cache right after updating
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
as
.
cloud
.
vmCache
.
Delete
(
vmName
)
}
}
...
...
pkg/cloudprovider/providers/azure/azure_controller_vmss.go
View file @
0f3dff25
...
@@ -71,25 +71,16 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
...
@@ -71,25 +71,16 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
ctx
,
cancel
:=
getContextWithCancel
()
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
defer
cancel
()
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk"
,
nodeResourceGroup
,
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - attach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
resp
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
)
if
_
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
);
err
!=
nil
{
if
ss
.
CloudProviderBackoff
&&
shouldRetryHTTPRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) backing off: vm(%s)"
,
nodeResourceGroup
,
nodeName
)
retryErr
:=
ss
.
UpdateVmssVMWithRetry
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
)
if
retryErr
!=
nil
{
err
=
retryErr
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) abort backoff: vm(%s)"
,
nodeResourceGroup
,
nodeName
)
}
}
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
)
{
// if lease cannot be acquired or disk not found, immediately detach the disk and return the original error
// if lease cannot be acquired or disk not found, immediately detach the disk and return the original error
glog
.
Infof
(
"azureDisk - err %s, try detach
"
,
detail
)
glog
.
Infof
(
"azureDisk - err %s, try detach
disk(%s)"
,
detail
,
diskName
)
ss
.
DetachDiskByName
(
diskName
,
diskURI
,
nodeName
)
ss
.
DetachDiskByName
(
diskName
,
diskURI
,
nodeName
)
}
}
}
else
{
}
else
{
glog
.
V
(
4
)
.
Info
(
"azureDisk - azure attach succeeded"
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - attach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
// Invalidate the cache right after updating
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
ss
.
vmssVMCache
.
Delete
(
key
)
ss
.
vmssVMCache
.
Delete
(
key
)
...
@@ -121,7 +112,7 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
...
@@ -121,7 +112,7 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
(
disk
.
Vhd
!=
nil
&&
disk
.
Vhd
.
URI
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
Vhd
.
URI
==
diskURI
)
||
(
disk
.
Vhd
!=
nil
&&
disk
.
Vhd
.
URI
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
Vhd
.
URI
==
diskURI
)
||
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
ManagedDisk
.
ID
==
diskURI
)
{
(
disk
.
ManagedDisk
!=
nil
&&
diskURI
!=
""
&&
*
disk
.
ManagedDisk
.
ID
==
diskURI
)
{
// found the disk
// found the disk
glog
.
V
(
4
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk: name %q uri %q"
,
diskName
,
diskURI
)
disks
=
append
(
disks
[
:
i
],
disks
[
i
+
1
:
]
...
)
disks
=
append
(
disks
[
:
i
],
disks
[
i
+
1
:
]
...
)
bFoundDisk
=
true
bFoundDisk
=
true
break
break
...
@@ -135,20 +126,11 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
...
@@ -135,20 +126,11 @@ 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
()
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk"
,
nodeResourceGroup
,
nodeName
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s): vm(%s) - detach disk(%s)"
,
nodeResourceGroup
,
nodeName
,
diskName
)
resp
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
)
if
_
,
err
:=
ss
.
VirtualMachineScaleSetVMsClient
.
Update
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
);
err
!=
nil
{
if
ss
.
CloudProviderBackoff
&&
shouldRetryHTTPRequest
(
resp
,
err
)
{
glog
.
Errorf
(
"azureDisk - detach disk(%s) from %s failed, err: %v"
,
diskName
,
nodeName
,
err
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) backing off: vm(%s)"
,
nodeResourceGroup
,
nodeName
)
retryErr
:=
ss
.
UpdateVmssVMWithRetry
(
ctx
,
nodeResourceGroup
,
ssName
,
instanceID
,
vm
)
if
retryErr
!=
nil
{
err
=
retryErr
glog
.
V
(
2
)
.
Infof
(
"azureDisk - update(%s) abort backoff: vm(%s)"
,
nodeResourceGroup
,
nodeName
)
}
}
if
err
!=
nil
{
glog
.
Errorf
(
"azureDisk - azure disk detach %q from %s failed, err: %v"
,
diskName
,
nodeName
,
err
)
}
else
{
}
else
{
glog
.
V
(
4
)
.
Info
(
"azureDisk - azure detach succeeded"
)
glog
.
V
(
2
)
.
Infof
(
"azureDisk - detach disk(%s) succeeded"
,
diskName
)
// Invalidate the cache right after updating
// Invalidate the cache right after updating
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
key
:=
buildVmssCacheKey
(
nodeResourceGroup
,
ss
.
makeVmssVMName
(
ssName
,
instanceID
))
ss
.
vmssVMCache
.
Delete
(
key
)
ss
.
vmssVMCache
.
Delete
(
key
)
...
...
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