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
daec2bd7
Commit
daec2bd7
authored
Feb 07, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cache for route tables
parent
21c8a636
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
12 deletions
+36
-12
azure.go
pkg/cloudprovider/providers/azure/azure.go
+7
-0
azure_routes.go
pkg/cloudprovider/providers/azure/azure_routes.go
+3
-4
azure_routes_test.go
pkg/cloudprovider/providers/azure/azure_routes_test.go
+1
-0
azure_test.go
pkg/cloudprovider/providers/azure/azure_test.go
+1
-0
azure_wrap.go
pkg/cloudprovider/providers/azure/azure_wrap.go
+24
-8
No files found.
pkg/cloudprovider/providers/azure/azure.go
View file @
daec2bd7
...
@@ -138,6 +138,7 @@ type Cloud struct {
...
@@ -138,6 +138,7 @@ type Cloud struct {
vmCache
*
timedCache
vmCache
*
timedCache
lbCache
*
timedCache
lbCache
*
timedCache
nsgCache
*
timedCache
nsgCache
*
timedCache
rtCache
*
timedCache
*
BlobDiskController
*
BlobDiskController
*
ManagedDiskController
*
ManagedDiskController
...
@@ -266,6 +267,12 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
...
@@ -266,6 +267,12 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
}
}
az
.
nsgCache
=
nsgCache
az
.
nsgCache
=
nsgCache
rtCache
,
err
:=
az
.
newRouteTableCache
()
if
err
!=
nil
{
return
nil
,
err
}
az
.
rtCache
=
rtCache
if
err
:=
initDiskControllers
(
&
az
);
err
!=
nil
{
if
err
:=
initDiskControllers
(
&
az
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/cloudprovider/providers/azure/azure_routes.go
View file @
daec2bd7
...
@@ -98,10 +98,9 @@ func (az *Cloud) createRouteTable() error {
...
@@ -98,10 +98,9 @@ func (az *Cloud) createRouteTable() error {
return
err
return
err
}
}
glog
.
V
(
10
)
.
Infof
(
"RouteTablesClient.Get(%q): start"
,
az
.
RouteTableName
)
// Invalidate the cache right after updating
_
,
err
=
az
.
RouteTablesClient
.
Get
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
""
)
az
.
rtCache
.
Delete
(
az
.
RouteTableName
)
glog
.
V
(
10
)
.
Infof
(
"RouteTablesClient.Get(%q): end"
,
az
.
RouteTableName
)
return
nil
return
err
}
}
// CreateRoute creates the described managed route
// CreateRoute creates the described managed route
...
...
pkg/cloudprovider/providers/azure/azure_routes_test.go
View file @
daec2bd7
...
@@ -37,6 +37,7 @@ func TestCreateRoute(t *testing.T) {
...
@@ -37,6 +37,7 @@ func TestCreateRoute(t *testing.T) {
Location
:
"location"
,
Location
:
"location"
,
},
},
}
}
cloud
.
rtCache
,
_
=
cloud
.
newRouteTableCache
()
expectedTable
:=
network
.
RouteTable
{
expectedTable
:=
network
.
RouteTable
{
Name
:
&
cloud
.
RouteTableName
,
Name
:
&
cloud
.
RouteTableName
,
Location
:
&
cloud
.
Location
,
Location
:
&
cloud
.
Location
,
...
...
pkg/cloudprovider/providers/azure/azure_test.go
View file @
daec2bd7
...
@@ -881,6 +881,7 @@ func getTestCloud() (az *Cloud) {
...
@@ -881,6 +881,7 @@ func getTestCloud() (az *Cloud) {
az
.
vmCache
,
_
=
az
.
newVMCache
()
az
.
vmCache
,
_
=
az
.
newVMCache
()
az
.
lbCache
,
_
=
az
.
newLBCache
()
az
.
lbCache
,
_
=
az
.
newLBCache
()
az
.
nsgCache
,
_
=
az
.
newNSGCache
()
az
.
nsgCache
,
_
=
az
.
newNSGCache
()
az
.
rtCache
,
_
=
az
.
newRouteTableCache
()
return
az
return
az
}
}
...
...
pkg/cloudprovider/providers/azure/azure_wrap.go
View file @
daec2bd7
...
@@ -33,6 +33,7 @@ var (
...
@@ -33,6 +33,7 @@ var (
vmCacheTTL
=
time
.
Minute
vmCacheTTL
=
time
.
Minute
lbCacheTTL
=
2
*
time
.
Minute
lbCacheTTL
=
2
*
time
.
Minute
nsgCacheTTL
=
2
*
time
.
Minute
nsgCacheTTL
=
2
*
time
.
Minute
rtCacheTTL
=
2
*
time
.
Minute
)
)
// checkExistsFromError inspects an error and returns a true if err is nil,
// checkExistsFromError inspects an error and returns a true if err is nil,
...
@@ -83,19 +84,16 @@ func (az *Cloud) getVirtualMachine(nodeName types.NodeName) (vm compute.VirtualM
...
@@ -83,19 +84,16 @@ func (az *Cloud) getVirtualMachine(nodeName types.NodeName) (vm compute.VirtualM
}
}
func
(
az
*
Cloud
)
getRouteTable
()
(
routeTable
network
.
RouteTable
,
exists
bool
,
err
error
)
{
func
(
az
*
Cloud
)
getRouteTable
()
(
routeTable
network
.
RouteTable
,
exists
bool
,
err
error
)
{
var
realErr
error
cachedRt
,
err
:=
az
.
rtCache
.
Get
(
az
.
RouteTableName
)
if
err
!=
nil
{
routeTable
,
err
=
az
.
RouteTablesClient
.
Get
(
az
.
ResourceGroup
,
az
.
RouteTableName
,
""
)
return
routeTable
,
false
,
err
exists
,
realErr
=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
routeTable
,
false
,
realErr
}
}
if
!
exists
{
if
cachedRt
==
nil
{
return
routeTable
,
false
,
nil
return
routeTable
,
false
,
nil
}
}
return
routeTable
,
exists
,
err
return
*
(
cachedRt
.
(
*
network
.
RouteTable
)),
true
,
nil
}
}
func
(
az
*
Cloud
)
getPublicIPAddress
(
pipResourceGroup
string
,
pipName
string
)
(
pip
network
.
PublicIPAddress
,
exists
bool
,
err
error
)
{
func
(
az
*
Cloud
)
getPublicIPAddress
(
pipResourceGroup
string
,
pipName
string
)
(
pip
network
.
PublicIPAddress
,
exists
bool
,
err
error
)
{
...
@@ -220,3 +218,21 @@ func (az *Cloud) newNSGCache() (*timedCache, error) {
...
@@ -220,3 +218,21 @@ func (az *Cloud) newNSGCache() (*timedCache, error) {
return
newTimedcache
(
nsgCacheTTL
,
getter
)
return
newTimedcache
(
nsgCacheTTL
,
getter
)
}
}
func
(
az
*
Cloud
)
newRouteTableCache
()
(
*
timedCache
,
error
)
{
getter
:=
func
(
key
string
)
(
interface
{},
error
)
{
rt
,
err
:=
az
.
RouteTablesClient
.
Get
(
az
.
ResourceGroup
,
key
,
""
)
exists
,
realErr
:=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
nil
,
realErr
}
if
!
exists
{
return
nil
,
nil
}
return
&
rt
,
nil
}
return
newTimedcache
(
rtCacheTTL
,
getter
)
}
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