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
d765f91c
Commit
d765f91c
authored
Jul 18, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix health check node port test flake
parent
08d98939
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
rest.go
pkg/registry/core/service/rest.go
+2
-2
rest_test.go
pkg/registry/core/service/rest_test.go
+22
-2
No files found.
pkg/registry/core/service/rest.go
View file @
d765f91c
...
...
@@ -544,9 +544,9 @@ func (rs *REST) allocateHealthCheckNodePort(service *api.Service) error {
err
:=
rs
.
serviceNodePorts
.
Allocate
(
int
(
healthCheckNodePort
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to allocate requested HealthCheck NodePort %v: %v"
,
service
.
Spec
.
H
ealthCheckNodePort
,
err
)
h
ealthCheckNodePort
,
err
)
}
glog
.
Infof
(
"Reserved user requested nodePort: %d"
,
service
.
Spec
.
H
ealthCheckNodePort
)
glog
.
Infof
(
"Reserved user requested nodePort: %d"
,
h
ealthCheckNodePort
)
}
else
{
// If the request has no health check nodePort specified, allocate any.
healthCheckNodePort
,
err
:=
rs
.
serviceNodePorts
.
AllocateNext
()
...
...
pkg/registry/core/service/rest_test.go
View file @
d765f91c
...
...
@@ -996,8 +996,10 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortAllocation(t *testing.
port
:=
service
.
GetServiceHealthCheckNodePort
(
created_service
)
if
port
==
0
{
t
.
Errorf
(
"Failed to allocate health check node port and set the HealthCheckNodePort"
)
}
else
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
}
}
// Validate allocation of a nodePort when ExternalTraffic beta annotation is set to OnlyLocal
...
...
@@ -1034,8 +1036,10 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortAllocationBeta(t *test
port
:=
service
.
GetServiceHealthCheckNodePort
(
created_service
)
if
port
==
0
{
t
.
Errorf
(
"Failed to allocate health check node port and set the HealthCheckNodePort"
)
}
else
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
}
}
// Validate using the user specified nodePort when ExternalTrafficPolicy is set to Local
...
...
@@ -1074,6 +1078,11 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortUserAllocation(t *test
if
port
!=
randomNodePort
{
t
.
Errorf
(
"Failed to allocate requested nodePort expected %d, got %d"
,
randomNodePort
,
port
)
}
if
port
!=
0
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
}
}
// Validate using the user specified nodePort when ExternalTraffic beta annotation is set to OnlyLocal
...
...
@@ -1116,6 +1125,11 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortUserAllocationBeta(t *
if
port
!=
randomNodePort
{
t
.
Errorf
(
"Failed to allocate requested nodePort expected %d, got %d"
,
randomNodePort
,
port
)
}
if
port
!=
0
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
}
}
// Validate that the service creation fails when the requested port number is -1.
...
...
@@ -1203,6 +1217,8 @@ func TestServiceRegistryExternalTrafficGlobal(t *testing.T) {
// Make sure the service does not have the health check node port allocated
port
:=
service
.
GetServiceHealthCheckNodePort
(
created_service
)
if
port
!=
0
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
t
.
Errorf
(
"Unexpected allocation of health check node port: %v"
,
port
)
}
}
...
...
@@ -1240,6 +1256,8 @@ func TestServiceRegistryExternalTrafficGlobalBeta(t *testing.T) {
// Make sure the service does not have the health check node port allocated
port
:=
service
.
GetServiceHealthCheckNodePort
(
created_service
)
if
port
!=
0
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
t
.
Errorf
(
"Unexpected allocation of health check node port: %v"
,
port
)
}
}
...
...
@@ -1273,6 +1291,8 @@ func TestServiceRegistryExternalTrafficAnnotationClusterIP(t *testing.T) {
// Make sure that ClusterIP services do not have the health check node port allocated
port
:=
service
.
GetServiceHealthCheckNodePort
(
created_service
)
if
port
!=
0
{
// Release the node port at the end of the test case.
storage
.
serviceNodePorts
.
Release
(
int
(
port
))
t
.
Errorf
(
"Unexpected allocation of health check node port annotation %s"
,
api
.
BetaAnnotationHealthCheckNodePort
)
}
}
...
...
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