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
fe379ec9
Unverified
Commit
fe379ec9
authored
Oct 04, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69355 from bsalamat/perc_validation
Add validation for percentage-of-nodes-to-score of the scheduler config
parents
6e850768
2d9d8c40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
validation.go
pkg/scheduler/apis/config/validation/validation.go
+4
-0
validation_test.go
pkg/scheduler/apis/config/validation/validation_test.go
+9
-1
No files found.
pkg/scheduler/apis/config/validation/validation.go
View file @
fe379ec9
...
@@ -44,6 +44,10 @@ func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) f
...
@@ -44,6 +44,10 @@ func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) f
if
cc
.
BindTimeoutSeconds
==
nil
{
if
cc
.
BindTimeoutSeconds
==
nil
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
field
.
NewPath
(
"bindTimeoutSeconds"
),
""
))
allErrs
=
append
(
allErrs
,
field
.
Required
(
field
.
NewPath
(
"bindTimeoutSeconds"
),
""
))
}
}
if
cc
.
PercentageOfNodesToScore
<
0
||
cc
.
PercentageOfNodesToScore
>
100
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"percentageOfNodesToScore"
),
cc
.
PercentageOfNodesToScore
,
"not in valid range 0-100"
))
}
return
allErrs
return
allErrs
}
}
...
...
pkg/scheduler/apis/config/validation/validation_test.go
View file @
fe379ec9
...
@@ -58,7 +58,8 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
...
@@ -58,7 +58,8 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
RetryPeriod
:
metav1
.
Duration
{
Duration
:
5
*
time
.
Second
},
RetryPeriod
:
metav1
.
Duration
{
Duration
:
5
*
time
.
Second
},
},
},
},
},
BindTimeoutSeconds
:
&
testTimeout
,
BindTimeoutSeconds
:
&
testTimeout
,
PercentageOfNodesToScore
:
35
,
}
}
HardPodAffinitySymmetricWeightGt100
:=
validConfig
.
DeepCopy
()
HardPodAffinitySymmetricWeightGt100
:=
validConfig
.
DeepCopy
()
...
@@ -92,6 +93,9 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
...
@@ -92,6 +93,9 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
bindTimeoutUnset
:=
validConfig
.
DeepCopy
()
bindTimeoutUnset
:=
validConfig
.
DeepCopy
()
bindTimeoutUnset
.
BindTimeoutSeconds
=
nil
bindTimeoutUnset
.
BindTimeoutSeconds
=
nil
percentageOfNodesToScore101
:=
validConfig
.
DeepCopy
()
percentageOfNodesToScore101
.
PercentageOfNodesToScore
=
int32
(
101
)
scenarios
:=
map
[
string
]
struct
{
scenarios
:=
map
[
string
]
struct
{
expectedToFail
bool
expectedToFail
bool
config
*
config
.
KubeSchedulerConfiguration
config
*
config
.
KubeSchedulerConfiguration
...
@@ -136,6 +140,10 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
...
@@ -136,6 +140,10 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
expectedToFail
:
true
,
expectedToFail
:
true
,
config
:
bindTimeoutUnset
,
config
:
bindTimeoutUnset
,
},
},
"bad-percentage-of-nodes-to-score"
:
{
expectedToFail
:
true
,
config
:
percentageOfNodesToScore101
,
},
}
}
for
name
,
scenario
:=
range
scenarios
{
for
name
,
scenario
:=
range
scenarios
{
...
...
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