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
2e3f2ea2
Commit
2e3f2ea2
authored
Jul 05, 2015
by
David Oppenheimer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt
parent
9fbccb4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
23 deletions
+22
-23
priorities.go
plugin/pkg/scheduler/algorithm/priorities/priorities.go
+3
-3
priorities_test.go
plugin/pkg/scheduler/algorithm/priorities/priorities_test.go
+19
-20
No files found.
plugin/pkg/scheduler/algorithm/priorities/priorities.go
View file @
2e3f2ea2
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"math"
"math"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/algorithm"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/algorithm"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -47,8 +47,8 @@ func calculateScore(requested int64, capacity int64, node string) int {
...
@@ -47,8 +47,8 @@ func calculateScore(requested int64, capacity int64, node string) int {
// pods will not all be scheduled to the machine with the smallest in-use limit,
// pods will not all be scheduled to the machine with the smallest in-use limit,
// and that when scheduling regular pods, such pods will not see zero-limit pods as
// and that when scheduling regular pods, such pods will not see zero-limit pods as
// consuming no resources whatsoever.
// consuming no resources whatsoever.
const
defaultMilliCpuLimit
int64
=
100
// 0.1 core
const
defaultMilliCpuLimit
int64
=
100
// 0.1 core
const
defaultMemoryLimit
int64
=
60
*
1024
*
1024
// 60 MB
const
defaultMemoryLimit
int64
=
60
*
1024
*
1024
// 60 MB
// TODO: Consider setting default as a fixed fraction of machine capacity (take "capacity api.ResourceList"
// TODO: Consider setting default as a fixed fraction of machine capacity (take "capacity api.ResourceList"
// as an additional argument here) rather than using constants
// as an additional argument here) rather than using constants
...
...
plugin/pkg/scheduler/algorithm/priorities/priorities_test.go
View file @
2e3f2ea2
...
@@ -73,9 +73,9 @@ func TestZeroLimit(t *testing.T) {
...
@@ -73,9 +73,9 @@ func TestZeroLimit(t *testing.T) {
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
api
.
ResourceList
{
Limits
:
api
.
ResourceList
{
"cpu"
:
resource
.
MustParse
(
"cpu"
:
resource
.
MustParse
(
strconv
.
FormatInt
(
defaultMilliCpuLimit
*
3
,
10
)
+
"m"
),
strconv
.
FormatInt
(
defaultMilliCpuLimit
*
3
,
10
)
+
"m"
),
"memory"
:
resource
.
MustParse
(
"memory"
:
resource
.
MustParse
(
strconv
.
FormatInt
(
defaultMemoryLimit
*
3
,
10
)),
strconv
.
FormatInt
(
defaultMemoryLimit
*
3
,
10
)),
},
},
},
},
},
},
...
@@ -86,30 +86,30 @@ func TestZeroLimit(t *testing.T) {
...
@@ -86,30 +86,30 @@ func TestZeroLimit(t *testing.T) {
large2
:=
large
large2
:=
large
large2
.
NodeName
=
"machine2"
large2
.
NodeName
=
"machine2"
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
*
api
.
Pod
pod
*
api
.
Pod
pods
[]
*
api
.
Pod
pods
[]
*
api
.
Pod
nodes
[]
api
.
Node
nodes
[]
api
.
Node
test
string
test
string
}{
}{
// The point of these tests is to show you get the same priority for a zero-limit pod
// The point of these tests is to show you get the same priority for a zero-limit pod
// as for a pod with the defaults limits, both when the zero-limit pod is already on the machine
// as for a pod with the defaults limits, both when the zero-limit pod is already on the machine
// and when the zero-limit pod is the one being scheduled.
// and when the zero-limit pod is the one being scheduled.
{
{
pod
:
&
api
.
Pod
{
Spec
:
noResources
},
pod
:
&
api
.
Pod
{
Spec
:
noResources
},
// match current f1-micro on GCE
// match current f1-micro on GCE
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
1000
,
defaultMemoryLimit
*
10
),
makeMinion
(
"machine2"
,
1000
,
defaultMemoryLimit
*
10
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
1000
,
defaultMemoryLimit
*
10
),
makeMinion
(
"machine2"
,
1000
,
defaultMemoryLimit
*
10
)},
test
:
"test priority of zero-limit pod with machine with zero-limit pod"
,
test
:
"test priority of zero-limit pod with machine with zero-limit pod"
,
pods
:
[]
*
api
.
Pod
{
pods
:
[]
*
api
.
Pod
{
{
Spec
:
large1
},
{
Spec
:
noResources1
},
{
Spec
:
large1
},
{
Spec
:
noResources1
},
{
Spec
:
large2
},
{
Spec
:
small2
},
{
Spec
:
large2
},
{
Spec
:
small2
},
},
},
},
},
{
{
pod
:
&
api
.
Pod
{
Spec
:
small
},
pod
:
&
api
.
Pod
{
Spec
:
small
},
// match current f1-micro on GCE
// match current f1-micro on GCE
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
1000
,
defaultMemoryLimit
*
10
),
makeMinion
(
"machine2"
,
1000
,
defaultMemoryLimit
*
10
)},
nodes
:
[]
api
.
Node
{
makeMinion
(
"machine1"
,
1000
,
defaultMemoryLimit
*
10
),
makeMinion
(
"machine2"
,
1000
,
defaultMemoryLimit
*
10
)},
test
:
"test priority of nonzero-limit pod with machine with zero-limit pod"
,
test
:
"test priority of nonzero-limit pod with machine with zero-limit pod"
,
pods
:
[]
*
api
.
Pod
{
pods
:
[]
*
api
.
Pod
{
{
Spec
:
large1
},
{
Spec
:
noResources1
},
{
Spec
:
large1
},
{
Spec
:
noResources1
},
{
Spec
:
large2
},
{
Spec
:
small2
},
{
Spec
:
large2
},
{
Spec
:
small2
},
},
},
...
@@ -130,14 +130,13 @@ func TestZeroLimit(t *testing.T) {
...
@@ -130,14 +130,13 @@ func TestZeroLimit(t *testing.T) {
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
for
_
,
hp
:=
range
list
{
for
_
,
hp
:=
range
list
{
if
(
hp
.
Score
!=
expectedPriority
)
{
if
hp
.
Score
!=
expectedPriority
{
t
.
Errorf
(
"%s: expected 25 for all priorities, got list %#v"
,
list
)
t
.
Errorf
(
"%s: expected 25 for all priorities, got list %#v"
,
list
)
}
}
}
}
}
}
}
}
func
TestLeastRequested
(
t
*
testing
.
T
)
{
func
TestLeastRequested
(
t
*
testing
.
T
)
{
labels1
:=
map
[
string
]
string
{
labels1
:=
map
[
string
]
string
{
"foo"
:
"bar"
,
"foo"
:
"bar"
,
...
@@ -162,7 +161,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -162,7 +161,7 @@ func TestLeastRequested(t *testing.T) {
{
{
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
api
.
ResourceList
{
Limits
:
api
.
ResourceList
{
"cpu"
:
resource
.
MustParse
(
"1000m"
),
"cpu"
:
resource
.
MustParse
(
"1000m"
),
"memory"
:
resource
.
MustParse
(
"0"
),
"memory"
:
resource
.
MustParse
(
"0"
),
},
},
},
},
...
@@ -170,7 +169,7 @@ func TestLeastRequested(t *testing.T) {
...
@@ -170,7 +169,7 @@ func TestLeastRequested(t *testing.T) {
{
{
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
api
.
ResourceList
{
Limits
:
api
.
ResourceList
{
"cpu"
:
resource
.
MustParse
(
"2000m"
),
"cpu"
:
resource
.
MustParse
(
"2000m"
),
"memory"
:
resource
.
MustParse
(
"0"
),
"memory"
:
resource
.
MustParse
(
"0"
),
},
},
},
},
...
@@ -494,7 +493,7 @@ func TestBalancedResourceAllocation(t *testing.T) {
...
@@ -494,7 +493,7 @@ func TestBalancedResourceAllocation(t *testing.T) {
{
{
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
api
.
ResourceList
{
Limits
:
api
.
ResourceList
{
"cpu"
:
resource
.
MustParse
(
"1000m"
),
"cpu"
:
resource
.
MustParse
(
"1000m"
),
"memory"
:
resource
.
MustParse
(
"0"
),
"memory"
:
resource
.
MustParse
(
"0"
),
},
},
},
},
...
@@ -502,7 +501,7 @@ func TestBalancedResourceAllocation(t *testing.T) {
...
@@ -502,7 +501,7 @@ func TestBalancedResourceAllocation(t *testing.T) {
{
{
Resources
:
api
.
ResourceRequirements
{
Resources
:
api
.
ResourceRequirements
{
Limits
:
api
.
ResourceList
{
Limits
:
api
.
ResourceList
{
"cpu"
:
resource
.
MustParse
(
"2000m"
),
"cpu"
:
resource
.
MustParse
(
"2000m"
),
"memory"
:
resource
.
MustParse
(
"0"
),
"memory"
:
resource
.
MustParse
(
"0"
),
},
},
},
},
...
...
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