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
ccb06730
Commit
ccb06730
authored
Aug 12, 2019
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix conflicted cache when the requests are canceled by other Azure operations
parent
3f2d0c73
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
azure_backoff.go
.../src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go
+49
-1
azure_loadbalancer.go
...k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go
+2
-0
No files found.
staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go
View file @
ccb06730
...
...
@@ -19,6 +19,7 @@ package azure
import
(
"fmt"
"net/http"
"strings"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-07-01/network"
...
...
@@ -32,6 +33,11 @@ import (
"k8s.io/klog"
)
const
(
// operationCancledErrorMessage means the operation is canceled by another new operation.
operationCancledErrorMessage
=
"canceledandsupersededduetoanotheroperation"
)
// requestBackoff if backoff is disabled in cloud provider it
// returns a new Backoff object steps = 1
// This is to make sure that the requested command executes
...
...
@@ -162,6 +168,12 @@ func (az *Cloud) CreateOrUpdateSecurityGroup(service *v1.Service, sg network.Sec
if
resp
!=
nil
&&
resp
.
StatusCode
==
http
.
StatusPreconditionFailed
{
az
.
nsgCache
.
Delete
(
*
sg
.
Name
)
}
// Invalidate the cache because another new operation has canceled the current request.
if
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
nsgCache
.
Delete
(
*
sg
.
Name
)
}
return
err
}
...
...
@@ -187,6 +199,13 @@ func (az *Cloud) CreateOrUpdateSGWithRetry(service *v1.Service, sg network.Secur
az
.
nsgCache
.
Delete
(
*
sg
.
Name
)
return
true
,
err
}
// Invalidate the cache and abort backoff because another new operation has canceled the current request.
if
err
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
nsgCache
.
Delete
(
*
sg
.
Name
)
return
true
,
err
}
return
done
,
retryError
})
}
...
...
@@ -212,6 +231,10 @@ func (az *Cloud) CreateOrUpdateLB(service *v1.Service, lb network.LoadBalancer)
if
resp
!=
nil
&&
resp
.
StatusCode
==
http
.
StatusPreconditionFailed
{
az
.
lbCache
.
Delete
(
*
lb
.
Name
)
}
// Invalidate the cache because another new operation has canceled the current request.
if
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
lbCache
.
Delete
(
*
lb
.
Name
)
}
return
err
}
...
...
@@ -234,7 +257,12 @@ func (az *Cloud) createOrUpdateLBWithRetry(service *v1.Service, lb network.LoadB
// Invalidate the cache and abort backoff because ETAG precondition mismatch.
if
resp
!=
nil
&&
resp
.
StatusCode
==
http
.
StatusPreconditionFailed
{
az
.
nsgCache
.
Delete
(
*
lb
.
Name
)
az
.
lbCache
.
Delete
(
*
lb
.
Name
)
return
true
,
err
}
// Invalidate the cache and abort backoff because another new operation has canceled the current request.
if
err
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
lbCache
.
Delete
(
*
lb
.
Name
)
return
true
,
err
}
return
done
,
retryError
...
...
@@ -456,6 +484,10 @@ func (az *Cloud) CreateOrUpdateRouteTable(routeTable network.RouteTable) error {
if
resp
!=
nil
&&
resp
.
StatusCode
==
http
.
StatusPreconditionFailed
{
az
.
rtCache
.
Delete
(
*
routeTable
.
Name
)
}
// Invalidate the cache because another new operation has canceled the current request.
if
err
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
rtCache
.
Delete
(
*
routeTable
.
Name
)
}
return
az
.
processHTTPResponse
(
nil
,
""
,
resp
,
err
)
}
...
...
@@ -480,6 +512,11 @@ func (az *Cloud) createOrUpdateRouteTableWithRetry(routeTable network.RouteTable
az
.
rtCache
.
Delete
(
*
routeTable
.
Name
)
return
true
,
err
}
// Invalidate the cache and abort backoff because another new operation has canceled the current request.
if
err
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
rtCache
.
Delete
(
*
routeTable
.
Name
)
return
true
,
err
}
return
done
,
retryError
})
}
...
...
@@ -495,6 +532,10 @@ func (az *Cloud) CreateOrUpdateRoute(route network.Route) error {
if
resp
!=
nil
&&
resp
.
StatusCode
==
http
.
StatusPreconditionFailed
{
az
.
rtCache
.
Delete
(
az
.
RouteTableName
)
}
// Invalidate the cache because another new operation has canceled the current request.
if
err
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
rtCache
.
Delete
(
az
.
RouteTableName
)
}
return
az
.
processHTTPResponse
(
nil
,
""
,
resp
,
err
)
}
...
...
@@ -520,6 +561,13 @@ func (az *Cloud) createOrUpdateRouteWithRetry(route network.Route) error {
az
.
rtCache
.
Delete
(
az
.
RouteTableName
)
return
true
,
err
}
// Invalidate the cache and abort backoff because another new operation has canceled the current request.
if
err
!=
nil
&&
strings
.
Contains
(
strings
.
ToLower
(
err
.
Error
()),
operationCancledErrorMessage
)
{
az
.
rtCache
.
Delete
(
az
.
RouteTableName
)
return
true
,
err
}
return
done
,
retryError
})
}
...
...
staging/src/k8s.io/legacy-cloud-providers/azure/azure_loadbalancer.go
View file @
ccb06730
...
...
@@ -874,6 +874,8 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
if
wantLb
&&
nodes
!=
nil
{
// Add the machines to the backend pool if they're not already
vmSetName
:=
az
.
mapLoadBalancerNameToVMSet
(
lbName
,
clusterName
)
// Etag would be changed when updating backend pools, so invalidate lbCache after it.
defer
az
.
lbCache
.
Delete
(
lbName
)
err
:=
az
.
vmSet
.
EnsureHostsInPool
(
service
,
nodes
,
lbBackendPoolID
,
vmSetName
,
isInternal
)
if
err
!=
nil
{
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