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
aac20ed6
Commit
aac20ed6
authored
Feb 06, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20600 from freehan/servicevalidation
Auto commit by PR queue bot
parents
70946a57
ec7366fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
validation.go
pkg/api/validation/validation.go
+6
-0
validation_test.go
pkg/api/validation/validation_test.go
+9
-1
No files found.
pkg/api/validation/validation.go
View file @
aac20ed6
...
...
@@ -1653,12 +1653,18 @@ func ValidateService(service *api.Service) field.ErrorList {
if
service
.
Spec
.
Type
==
api
.
ServiceTypeLoadBalancer
{
portsPath
:=
specPath
.
Child
(
"ports"
)
includeProtocols
:=
sets
.
NewString
()
for
i
:=
range
service
.
Spec
.
Ports
{
portPath
:=
portsPath
.
Index
(
i
)
if
!
supportedPortProtocols
.
Has
(
string
(
service
.
Spec
.
Ports
[
i
]
.
Protocol
))
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
portPath
.
Child
(
"protocol"
),
service
.
Spec
.
Ports
[
i
]
.
Protocol
,
"cannot create an external load balancer with non-TCP/UDP ports"
))
}
else
{
includeProtocols
.
Insert
(
string
(
service
.
Spec
.
Ports
[
i
]
.
Protocol
))
}
}
if
includeProtocols
.
Len
()
>
1
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
portsPath
,
service
.
Spec
.
Ports
,
"cannot create an external load balancer with mix protocols"
))
}
}
if
service
.
Spec
.
Type
==
api
.
ServiceTypeClusterIP
{
...
...
pkg/api/validation/validation_test.go
View file @
aac20ed6
...
...
@@ -2580,11 +2580,19 @@ func TestValidateService(t *testing.T) {
name
:
"valid load balancer protocol UDP 2"
,
tweakSvc
:
func
(
s
*
api
.
Service
)
{
s
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"q"
,
Port
:
12345
,
Protocol
:
"UDP"
,
TargetPort
:
intstr
.
FromInt
(
12345
)})
s
.
Spec
.
Ports
[
0
]
=
api
.
ServicePort
{
Name
:
"q"
,
Port
:
12345
,
Protocol
:
"UDP"
,
TargetPort
:
intstr
.
FromInt
(
12345
)}
},
numErrs
:
0
,
},
{
name
:
"invalid load balancer with mix protocol"
,
tweakSvc
:
func
(
s
*
api
.
Service
)
{
s
.
Spec
.
Type
=
api
.
ServiceTypeLoadBalancer
s
.
Spec
.
Ports
=
append
(
s
.
Spec
.
Ports
,
api
.
ServicePort
{
Name
:
"q"
,
Port
:
12345
,
Protocol
:
"UDP"
,
TargetPort
:
intstr
.
FromInt
(
12345
)})
},
numErrs
:
1
,
},
{
name
:
"valid 1"
,
tweakSvc
:
func
(
s
*
api
.
Service
)
{
// do nothing
...
...
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