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
12c9d273
Commit
12c9d273
authored
May 04, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use new azure clients
parent
7d9b1342
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
41 deletions
+56
-41
azure_backoff.go
pkg/cloudprovider/providers/azure/azure_backoff.go
+25
-20
azure_routes.go
pkg/cloudprovider/providers/azure/azure_routes.go
+12
-12
azure_standard.go
pkg/cloudprovider/providers/azure/azure_standard.go
+7
-5
azure_vmss.go
pkg/cloudprovider/providers/azure/azure_vmss.go
+3
-1
azure_wrap.go
pkg/cloudprovider/providers/azure/azure_wrap.go
+9
-3
No files found.
pkg/cloudprovider/providers/azure/azure_backoff.go
View file @
12c9d273
...
...
@@ -111,11 +111,12 @@ func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, string,
// CreateOrUpdateSGWithRetry invokes az.SecurityGroupsClient.CreateOrUpdate with exponential backoff retry
func
(
az
*
Cloud
)
CreateOrUpdateSGWithRetry
(
sg
network
.
SecurityGroup
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
respChan
,
errChan
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
sg
.
Name
,
sg
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
SecurityGroupsClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
*
sg
.
Name
,
sg
)
glog
.
V
(
10
)
.
Infof
(
"SecurityGroupsClient.CreateOrUpdate(%s): end"
,
*
sg
.
Name
)
done
,
err
:=
process
RetryResponse
(
resp
.
Response
,
err
)
done
,
err
:=
process
HTTPRetryResponse
(
resp
,
err
)
if
done
&&
err
==
nil
{
// Invalidate the cache right after updating
az
.
nsgCache
.
Delete
(
*
sg
.
Name
)
...
...
@@ -208,11 +209,12 @@ func (az *Cloud) CreateOrUpdatePIPWithRetry(pipResourceGroup string, pip network
// CreateOrUpdateInterfaceWithRetry invokes az.PublicIPAddressesClient.CreateOrUpdate with exponential backoff retry
func
(
az
*
Cloud
)
CreateOrUpdateInterfaceWithRetry
(
nic
network
.
Interface
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
respChan
,
errChan
:=
az
.
InterfacesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
*
nic
.
Name
,
nic
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
InterfacesClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
*
nic
.
Name
,
nic
)
glog
.
V
(
10
)
.
Infof
(
"InterfacesClient.CreateOrUpdate(%s): end"
,
*
nic
.
Name
)
return
process
RetryResponse
(
resp
.
Response
,
err
)
return
process
HTTPRetryResponse
(
resp
,
err
)
})
}
...
...
@@ -246,32 +248,35 @@ func (az *Cloud) DeleteLBWithRetry(lbName string) error {
// CreateOrUpdateRouteTableWithRetry invokes az.RouteTablesClient.CreateOrUpdate with exponential backoff retry
func
(
az
*
Cloud
)
CreateOrUpdateRouteTableWithRetry
(
routeTable
network
.
RouteTable
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
respChan
,
errChan
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
return
processRetryResponse
(
resp
.
Response
,
err
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
)
return
processHTTPRetryResponse
(
resp
,
err
)
})
}
// CreateOrUpdateRouteWithRetry invokes az.RoutesClient.CreateOrUpdate with exponential backoff retry
func
(
az
*
Cloud
)
CreateOrUpdateRouteWithRetry
(
route
network
.
Route
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
respChan
,
errChan
:=
az
.
RoutesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
RoutesClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
)
glog
.
V
(
10
)
.
Infof
(
"RoutesClient.CreateOrUpdate(%s): end"
,
*
route
.
Name
)
return
process
RetryResponse
(
resp
.
Response
,
err
)
return
process
HTTPRetryResponse
(
resp
,
err
)
})
}
// DeleteRouteWithRetry invokes az.RoutesClient.Delete with exponential backoff retry
func
(
az
*
Cloud
)
DeleteRouteWithRetry
(
routeName
string
)
error
{
return
wait
.
ExponentialBackoff
(
az
.
requestBackoff
(),
func
()
(
bool
,
error
)
{
respChan
,
errChan
:=
az
.
RoutesClient
.
Delete
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
resp
,
err
:=
az
.
RoutesClient
.
Delete
(
ctx
,
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
)
glog
.
V
(
10
)
.
Infof
(
"RoutesClient.Delete(%s): end"
,
az
.
RouteTableName
)
return
processRetryResponse
(
resp
,
err
)
return
process
HTTP
RetryResponse
(
resp
,
err
)
})
}
...
...
pkg/cloudprovider/providers/azure/azure_routes.go
View file @
12c9d273
...
...
@@ -82,11 +82,11 @@ func (az *Cloud) createRouteTable() error {
}
glog
.
V
(
3
)
.
Infof
(
"create: creating routetable. routeTableName=%q"
,
az
.
RouteTableName
)
respChan
,
errChan
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
(
)
defer
cancel
()
resp
,
err
:=
az
.
RouteTablesClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeTable
)
glog
.
V
(
10
)
.
Infof
(
"RouteTablesClient.CreateOrUpdate(%q): end"
,
az
.
RouteTableName
)
if
az
.
CloudProviderBackoff
&&
shouldRetry
APIRequest
(
resp
.
Response
,
err
)
{
if
az
.
CloudProviderBackoff
&&
shouldRetry
HTTPRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"create backing off: creating routetable. routeTableName=%q"
,
az
.
RouteTableName
)
retryErr
:=
az
.
CreateOrUpdateRouteTableWithRetry
(
routeTable
)
if
retryErr
!=
nil
{
...
...
@@ -127,11 +127,11 @@ func (az *Cloud) CreateRoute(ctx context.Context, clusterName string, nameHint s
}
glog
.
V
(
3
)
.
Infof
(
"create: creating route: instance=%q cidr=%q"
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
respChan
,
errChan
:=
az
.
RoutesClient
.
CreateOrUpdate
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
,
nil
)
resp
:=
<-
respChan
err
=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
(
)
defer
cancel
()
resp
,
err
:=
az
.
RoutesClient
.
CreateOrUpdate
(
ctx
,
az
.
ResourceGroup
,
az
.
RouteTableName
,
*
route
.
Name
,
route
)
glog
.
V
(
10
)
.
Infof
(
"RoutesClient.CreateOrUpdate(%q): end"
,
az
.
RouteTableName
)
if
az
.
CloudProviderBackoff
&&
shouldRetry
APIRequest
(
resp
.
Response
,
err
)
{
if
az
.
CloudProviderBackoff
&&
shouldRetry
HTTPRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"create backing off: creating route: instance=%q cidr=%q"
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
retryErr
:=
az
.
CreateOrUpdateRouteWithRetry
(
route
)
if
retryErr
!=
nil
{
...
...
@@ -152,13 +152,13 @@ func (az *Cloud) CreateRoute(ctx context.Context, clusterName string, nameHint s
func
(
az
*
Cloud
)
DeleteRoute
(
ctx
context
.
Context
,
clusterName
string
,
kubeRoute
*
cloudprovider
.
Route
)
error
{
glog
.
V
(
2
)
.
Infof
(
"delete: deleting route. clusterName=%q instance=%q cidr=%q"
,
clusterName
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
routeName
:=
mapNodeNameToRouteName
(
kubeRoute
.
TargetNode
)
respChan
,
errChan
:=
az
.
RoutesClient
.
Delete
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
resp
,
err
:=
az
.
RoutesClient
.
Delete
(
ctx
,
az
.
ResourceGroup
,
az
.
RouteTableName
,
routeName
)
glog
.
V
(
10
)
.
Infof
(
"RoutesClient.Delete(%q): end"
,
az
.
RouteTableName
)
if
az
.
CloudProviderBackoff
&&
shouldRetry
API
Request
(
resp
,
err
)
{
if
az
.
CloudProviderBackoff
&&
shouldRetry
HTTP
Request
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"delete backing off: deleting route. clusterName=%q instance=%q cidr=%q"
,
clusterName
,
kubeRoute
.
TargetNode
,
kubeRoute
.
DestinationCIDR
)
retryErr
:=
az
.
DeleteRouteWithRetry
(
routeName
)
if
retryErr
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_standard.go
View file @
12c9d273
...
...
@@ -584,7 +584,9 @@ func (as *availabilitySet) GetPrimaryInterface(nodeName, vmSetName string) (netw
}
}
nic
,
err
:=
as
.
InterfacesClient
.
Get
(
as
.
ResourceGroup
,
nicName
,
""
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
nic
,
err
:=
as
.
InterfacesClient
.
Get
(
ctx
,
as
.
ResourceGroup
,
nicName
,
""
)
if
err
!=
nil
{
return
network
.
Interface
{},
err
}
...
...
@@ -652,11 +654,11 @@ func (as *availabilitySet) ensureHostInPool(serviceName string, nodeName types.N
nicName
:=
*
nic
.
Name
glog
.
V
(
3
)
.
Infof
(
"nicupdate(%s): nic(%s) - updating"
,
serviceName
,
nicName
)
respChan
,
errChan
:=
as
.
InterfacesClient
.
CreateOrUpdate
(
as
.
ResourceGroup
,
*
nic
.
Name
,
nic
,
nil
)
resp
:=
<-
respChan
err
:=
<-
errChan
ctx
,
cancel
:=
getContextWithCancel
(
)
defer
cancel
()
resp
,
err
:=
as
.
InterfacesClient
.
CreateOrUpdate
(
ctx
,
as
.
ResourceGroup
,
*
nic
.
Name
,
nic
)
glog
.
V
(
10
)
.
Infof
(
"InterfacesClient.CreateOrUpdate(%q): end"
,
*
nic
.
Name
)
if
as
.
CloudProviderBackoff
&&
shouldRetry
APIRequest
(
resp
.
Response
,
err
)
{
if
as
.
CloudProviderBackoff
&&
shouldRetry
HTTPRequest
(
resp
,
err
)
{
glog
.
V
(
2
)
.
Infof
(
"nicupdate(%s) backing off: nic(%s) - updating, err=%v"
,
serviceName
,
nicName
,
err
)
retryErr
:=
as
.
CreateOrUpdateInterfaceWithRetry
(
nic
)
if
retryErr
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_vmss.go
View file @
12c9d273
...
...
@@ -453,7 +453,9 @@ func (ss *scaleSet) GetPrimaryInterface(nodeName, vmSetName string) (network.Int
return
network
.
Interface
{},
err
}
nic
,
err
:=
ss
.
InterfacesClient
.
GetVirtualMachineScaleSetNetworkInterface
(
ss
.
ResourceGroup
,
ssName
,
instanceID
,
nicName
,
""
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
nic
,
err
:=
ss
.
InterfacesClient
.
GetVirtualMachineScaleSetNetworkInterface
(
ctx
,
ss
.
ResourceGroup
,
ssName
,
instanceID
,
nicName
,
""
)
if
err
!=
nil
{
glog
.
Errorf
(
"error: ss.GetPrimaryInterface(%s), ss.GetVirtualMachineScaleSetNetworkInterface.Get(%s, %s, %s), err=%v"
,
nodeName
,
ss
.
ResourceGroup
,
ssName
,
nicName
,
err
)
return
network
.
Interface
{},
err
...
...
pkg/cloudprovider/providers/azure/azure_wrap.go
View file @
12c9d273
...
...
@@ -129,7 +129,9 @@ func (az *Cloud) getSubnet(virtualNetworkName string, subnetName string) (subnet
rg
=
az
.
ResourceGroup
}
subnet
,
err
=
az
.
SubnetsClient
.
Get
(
rg
,
virtualNetworkName
,
subnetName
,
""
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
subnet
,
err
=
az
.
SubnetsClient
.
Get
(
ctx
,
rg
,
virtualNetworkName
,
subnetName
,
""
)
exists
,
realErr
=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
subnet
,
false
,
realErr
...
...
@@ -217,7 +219,9 @@ func (az *Cloud) newLBCache() (*timedCache, error) {
func
(
az
*
Cloud
)
newNSGCache
()
(
*
timedCache
,
error
)
{
getter
:=
func
(
key
string
)
(
interface
{},
error
)
{
nsg
,
err
:=
az
.
SecurityGroupsClient
.
Get
(
az
.
ResourceGroup
,
key
,
""
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
nsg
,
err
:=
az
.
SecurityGroupsClient
.
Get
(
ctx
,
az
.
ResourceGroup
,
key
,
""
)
exists
,
realErr
:=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
nil
,
realErr
...
...
@@ -235,7 +239,9 @@ func (az *Cloud) newNSGCache() (*timedCache, error) {
func
(
az
*
Cloud
)
newRouteTableCache
()
(
*
timedCache
,
error
)
{
getter
:=
func
(
key
string
)
(
interface
{},
error
)
{
rt
,
err
:=
az
.
RouteTablesClient
.
Get
(
az
.
ResourceGroup
,
key
,
""
)
ctx
,
cancel
:=
getContextWithCancel
()
defer
cancel
()
rt
,
err
:=
az
.
RouteTablesClient
.
Get
(
ctx
,
az
.
ResourceGroup
,
key
,
""
)
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