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
6fd76dc1
Commit
6fd76dc1
authored
Feb 03, 2017
by
tanshanshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
3ce49346
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
.linted_packages
hack/.linted_packages
+1
-0
validation.go
plugin/pkg/scheduler/api/validation/validation.go
+2
-2
validation_test.go
plugin/pkg/scheduler/api/validation/validation_test.go
+15
-0
No files found.
hack/.linted_packages
View file @
6fd76dc1
...
...
@@ -257,6 +257,7 @@ plugin/pkg/admission/securitycontext/scdeny
plugin/pkg/auth
plugin/pkg/auth/authorizer
plugin/pkg/auth/authorizer/rbac/bootstrappolicy
plugin/pkg/scheduler/api/validation
staging/src/k8s.io/apimachinery/pkg/api/equality
staging/src/k8s.io/apimachinery/pkg/api/errors
staging/src/k8s.io/apimachinery/pkg/api/resource
...
...
plugin/pkg/scheduler/api/validation/validation.go
View file @
6fd76dc1
...
...
@@ -23,10 +23,10 @@ import (
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
)
// Validate checks for errors in the Config
// Validate
Policy
checks for errors in the Config
// It does not return early so that it can find as many errors as possible
func
ValidatePolicy
(
policy
schedulerapi
.
Policy
)
error
{
va
lidationErrors
:=
make
([]
error
,
0
)
va
r
validationErrors
[]
error
for
_
,
priority
:=
range
policy
.
Priorities
{
if
priority
.
Weight
<=
0
{
...
...
plugin/pkg/scheduler/api/validation/validation_test.go
View file @
6fd76dc1
...
...
@@ -50,3 +50,18 @@ func TestValidatePriorityWithNegativeWeight(t *testing.T) {
t
.
Errorf
(
"Expected error about priority weight not being positive"
)
}
}
func
TestValidateExtenderWithNonNegativeWeight
(
t
*
testing
.
T
)
{
extenderPolicy
:=
api
.
Policy
{
ExtenderConfigs
:
[]
api
.
ExtenderConfig
{{
URLPrefix
:
"http://127.0.0.1:8081/extender"
,
FilterVerb
:
"filter"
,
Weight
:
2
}}}
errs
:=
ValidatePolicy
(
extenderPolicy
)
if
errs
!=
nil
{
t
.
Errorf
(
"Unexpected errors %v"
,
errs
)
}
}
func
TestValidateExtenderWithNegativeWeight
(
t
*
testing
.
T
)
{
extenderPolicy
:=
api
.
Policy
{
ExtenderConfigs
:
[]
api
.
ExtenderConfig
{{
URLPrefix
:
"http://127.0.0.1:8081/extender"
,
FilterVerb
:
"filter"
,
Weight
:
-
2
}}}
if
ValidatePolicy
(
extenderPolicy
)
==
nil
{
t
.
Errorf
(
"Expected error about priority weight for extender not being positive"
)
}
}
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