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
8d0c5d97
Commit
8d0c5d97
authored
Feb 25, 2019
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix subnet annotation checking for Azure internal loadbalancer
parent
139a13d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+1
-1
azure_loadbalancer_test.go
pkg/cloudprovider/providers/azure/azure_loadbalancer_test.go
+65
-0
No files found.
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
8d0c5d97
...
@@ -1538,7 +1538,7 @@ func requiresInternalLoadBalancer(service *v1.Service) bool {
...
@@ -1538,7 +1538,7 @@ func requiresInternalLoadBalancer(service *v1.Service) bool {
func
subnet
(
service
*
v1
.
Service
)
*
string
{
func
subnet
(
service
*
v1
.
Service
)
*
string
{
if
requiresInternalLoadBalancer
(
service
)
{
if
requiresInternalLoadBalancer
(
service
)
{
if
l
,
found
:=
service
.
Annotations
[
ServiceAnnotationLoadBalancerInternalSubnet
];
found
{
if
l
,
found
:=
service
.
Annotations
[
ServiceAnnotationLoadBalancerInternalSubnet
];
found
&&
strings
.
TrimSpace
(
l
)
!=
""
{
return
&
l
return
&
l
}
}
}
}
...
...
pkg/cloudprovider/providers/azure/azure_loadbalancer_test.go
View file @
8d0c5d97
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-autorest/autorest/to"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
)
func
TestFindProbe
(
t
*
testing
.
T
)
{
func
TestFindProbe
(
t
*
testing
.
T
)
{
...
@@ -243,3 +244,67 @@ func TestGetIdleTimeout(t *testing.T) {
...
@@ -243,3 +244,67 @@ func TestGetIdleTimeout(t *testing.T) {
})
})
}
}
}
}
func
TestSubnet
(
t
*
testing
.
T
)
{
for
i
,
c
:=
range
[]
struct
{
desc
string
service
*
v1
.
Service
expected
*
string
}{
{
desc
:
"No annotation should return nil"
,
service
:
&
v1
.
Service
{},
expected
:
nil
,
},
{
desc
:
"annotation with subnet but no ILB should return nil"
,
service
:
&
v1
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
ServiceAnnotationLoadBalancerInternalSubnet
:
"subnet"
,
},
},
},
expected
:
nil
,
},
{
desc
:
"annotation with subnet but ILB=false should return nil"
,
service
:
&
v1
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
ServiceAnnotationLoadBalancerInternalSubnet
:
"subnet"
,
ServiceAnnotationLoadBalancerInternal
:
"false"
,
},
},
},
expected
:
nil
,
},
{
desc
:
"annotation with empty subnet should return nil"
,
service
:
&
v1
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
ServiceAnnotationLoadBalancerInternalSubnet
:
""
,
ServiceAnnotationLoadBalancerInternal
:
"true"
,
},
},
},
expected
:
nil
,
},
{
desc
:
"annotation with subnet and ILB should return subnet"
,
service
:
&
v1
.
Service
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Annotations
:
map
[
string
]
string
{
ServiceAnnotationLoadBalancerInternalSubnet
:
"subnet"
,
ServiceAnnotationLoadBalancerInternal
:
"true"
,
},
},
},
expected
:
to
.
StringPtr
(
"subnet"
),
},
}
{
real
:=
subnet
(
c
.
service
)
assert
.
Equal
(
t
,
c
.
expected
,
real
,
fmt
.
Sprintf
(
"TestCase[%d]: %s"
,
i
,
c
.
desc
))
}
}
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