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
21c8a636
Commit
21c8a636
authored
Feb 07, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cache for network security groups
parent
d22b6d9e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
6 deletions
+52
-6
azure.go
pkg/cloudprovider/providers/azure/azure.go
+9
-2
azure_backoff.go
pkg/cloudprovider/providers/azure/azure_backoff.go
+6
-1
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+1
-1
azure_test.go
pkg/cloudprovider/providers/azure/azure_test.go
+1
-0
azure_wrap.go
pkg/cloudprovider/providers/azure/azure_wrap.go
+35
-2
No files found.
pkg/cloudprovider/providers/azure/azure.go
View file @
21c8a636
...
@@ -135,8 +135,9 @@ type Cloud struct {
...
@@ -135,8 +135,9 @@ type Cloud struct {
VirtualMachineScaleSetsClient
VirtualMachineScaleSetsClient
VirtualMachineScaleSetsClient
VirtualMachineScaleSetsClient
VirtualMachineScaleSetVMsClient
VirtualMachineScaleSetVMsClient
VirtualMachineScaleSetVMsClient
VirtualMachineScaleSetVMsClient
vmCache
*
timedCache
vmCache
*
timedCache
lbCache
*
timedCache
lbCache
*
timedCache
nsgCache
*
timedCache
*
BlobDiskController
*
BlobDiskController
*
ManagedDiskController
*
ManagedDiskController
...
@@ -259,6 +260,12 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
...
@@ -259,6 +260,12 @@ func NewCloud(configReader io.Reader) (cloudprovider.Interface, error) {
}
}
az
.
lbCache
=
lbCache
az
.
lbCache
=
lbCache
nsgCache
,
err
:=
az
.
newNSGCache
()
if
err
!=
nil
{
return
nil
,
err
}
az
.
nsgCache
=
nsgCache
if
err
:=
initDiskControllers
(
&
az
);
err
!=
nil
{
if
err
:=
initDiskControllers
(
&
az
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/cloudprovider/providers/azure/azure_backoff.go
View file @
21c8a636
...
@@ -131,7 +131,12 @@ func (az *Cloud) CreateOrUpdateSGWithRetry(sg network.SecurityGroup) error {
...
@@ -131,7 +131,12 @@ func (az *Cloud) CreateOrUpdateSGWithRetry(sg network.SecurityGroup) error {
resp
:=
<-
respChan
resp
:=
<-
respChan
err
:=
<-
errChan
err
:=
<-
errChan
glog
.
V
(
10
)
.
Infof
(
"SecurityGroupsClient.CreateOrUpdate(%s): end"
,
*
sg
.
Name
)
glog
.
V
(
10
)
.
Infof
(
"SecurityGroupsClient.CreateOrUpdate(%s): end"
,
*
sg
.
Name
)
return
processRetryResponse
(
resp
.
Response
,
err
)
done
,
err
:=
processRetryResponse
(
resp
.
Response
,
err
)
if
done
&&
err
==
nil
{
// Invalidate the cache right after updating
az
.
lbCache
.
Delete
(
*
sg
.
Name
)
}
return
done
,
err
})
})
}
}
...
...
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
21c8a636
...
@@ -819,7 +819,7 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
...
@@ -819,7 +819,7 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
ports
=
[]
v1
.
ServicePort
{}
ports
=
[]
v1
.
ServicePort
{}
}
}
sg
,
err
:=
az
.
SecurityGroupsClient
.
Get
(
az
.
ResourceGroup
,
az
.
SecurityGroupName
,
""
)
sg
,
err
:=
az
.
getSecurityGroup
(
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/cloudprovider/providers/azure/azure_test.go
View file @
21c8a636
...
@@ -880,6 +880,7 @@ func getTestCloud() (az *Cloud) {
...
@@ -880,6 +880,7 @@ func getTestCloud() (az *Cloud) {
az
.
vmSet
=
newAvailabilitySet
(
az
)
az
.
vmSet
=
newAvailabilitySet
(
az
)
az
.
vmCache
,
_
=
az
.
newVMCache
()
az
.
vmCache
,
_
=
az
.
newVMCache
()
az
.
lbCache
,
_
=
az
.
newLBCache
()
az
.
lbCache
,
_
=
az
.
newLBCache
()
az
.
nsgCache
,
_
=
az
.
newNSGCache
()
return
az
return
az
}
}
...
...
pkg/cloudprovider/providers/azure/azure_wrap.go
View file @
21c8a636
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
azure
package
azure
import
(
import
(
"fmt"
"net/http"
"net/http"
"time"
"time"
...
@@ -29,8 +30,9 @@ import (
...
@@ -29,8 +30,9 @@ import (
)
)
var
(
var
(
vmCacheTTL
=
time
.
Minute
vmCacheTTL
=
time
.
Minute
lbCacheTTL
=
2
*
time
.
Minute
lbCacheTTL
=
2
*
time
.
Minute
nsgCacheTTL
=
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,
...
@@ -152,6 +154,19 @@ func (az *Cloud) getAzureLoadBalancer(name string) (lb network.LoadBalancer, exi
...
@@ -152,6 +154,19 @@ func (az *Cloud) getAzureLoadBalancer(name string) (lb network.LoadBalancer, exi
return
*
(
cachedLB
.
(
*
network
.
LoadBalancer
)),
true
,
nil
return
*
(
cachedLB
.
(
*
network
.
LoadBalancer
)),
true
,
nil
}
}
func
(
az
*
Cloud
)
getSecurityGroup
()
(
nsg
network
.
SecurityGroup
,
err
error
)
{
securityGroup
,
err
:=
az
.
nsgCache
.
Get
(
az
.
SecurityGroupName
)
if
err
!=
nil
{
return
nsg
,
err
}
if
securityGroup
==
nil
{
return
nsg
,
fmt
.
Errorf
(
"nsg %q not found"
,
az
.
SecurityGroupName
)
}
return
*
(
securityGroup
.
(
*
network
.
SecurityGroup
)),
nil
}
func
(
az
*
Cloud
)
newVMCache
()
(
*
timedCache
,
error
)
{
func
(
az
*
Cloud
)
newVMCache
()
(
*
timedCache
,
error
)
{
getter
:=
func
(
key
string
)
(
interface
{},
error
)
{
getter
:=
func
(
key
string
)
(
interface
{},
error
)
{
vm
,
err
:=
az
.
VirtualMachinesClient
.
Get
(
az
.
ResourceGroup
,
key
,
compute
.
InstanceView
)
vm
,
err
:=
az
.
VirtualMachinesClient
.
Get
(
az
.
ResourceGroup
,
key
,
compute
.
InstanceView
)
...
@@ -187,3 +202,21 @@ func (az *Cloud) newLBCache() (*timedCache, error) {
...
@@ -187,3 +202,21 @@ func (az *Cloud) newLBCache() (*timedCache, error) {
return
newTimedcache
(
lbCacheTTL
,
getter
)
return
newTimedcache
(
lbCacheTTL
,
getter
)
}
}
func
(
az
*
Cloud
)
newNSGCache
()
(
*
timedCache
,
error
)
{
getter
:=
func
(
key
string
)
(
interface
{},
error
)
{
nsg
,
err
:=
az
.
SecurityGroupsClient
.
Get
(
az
.
ResourceGroup
,
key
,
""
)
exists
,
realErr
:=
checkResourceExistsFromError
(
err
)
if
realErr
!=
nil
{
return
nil
,
realErr
}
if
!
exists
{
return
nil
,
nil
}
return
&
nsg
,
nil
}
return
newTimedcache
(
nsgCacheTTL
,
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