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
0de1e62b
Commit
0de1e62b
authored
Jul 25, 2016
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify fsStats to fsStatsType to avoid confusion with cadvisor types
parent
9604b47c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
20 deletions
+22
-20
helpers.go
pkg/kubelet/eviction/helpers.go
+14
-12
helpers_test.go
pkg/kubelet/eviction/helpers_test.go
+2
-2
types.go
pkg/kubelet/eviction/types.go
+5
-5
predicates_test.go
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
+1
-1
No files found.
pkg/kubelet/eviction/helpers.go
View file @
0de1e62b
...
@@ -255,6 +255,7 @@ func memoryUsage(memStats *statsapi.MemoryStats) *resource.Quantity {
...
@@ -255,6 +255,7 @@ func memoryUsage(memStats *statsapi.MemoryStats) *resource.Quantity {
}
}
// localVolumeNames returns the set of volumes for the pod that are local
// localVolumeNames returns the set of volumes for the pod that are local
// TODO: sumamry API should report what volumes consume local storage rather than hard-code here.
func
localVolumeNames
(
pod
*
api
.
Pod
)
[]
string
{
func
localVolumeNames
(
pod
*
api
.
Pod
)
[]
string
{
result
:=
[]
string
{}
result
:=
[]
string
{}
for
_
,
volume
:=
range
pod
.
Spec
.
Volumes
{
for
_
,
volume
:=
range
pod
.
Spec
.
Volumes
{
...
@@ -269,22 +270,23 @@ func localVolumeNames(pod *api.Pod) []string {
...
@@ -269,22 +270,23 @@ func localVolumeNames(pod *api.Pod) []string {
}
}
// podDiskUsage aggregates pod disk usage for the specified stats to measure.
// podDiskUsage aggregates pod disk usage for the specified stats to measure.
func
podDiskUsage
(
podStats
statsapi
.
PodStats
,
pod
*
api
.
Pod
,
statsToMeasure
[]
fsStats
)
(
api
.
ResourceList
,
error
)
{
func
podDiskUsage
(
podStats
statsapi
.
PodStats
,
pod
*
api
.
Pod
,
statsToMeasure
[]
fsStats
Type
)
(
api
.
ResourceList
,
error
)
{
disk
:=
resource
.
Quantity
{
Format
:
resource
.
BinarySI
}
disk
:=
resource
.
Quantity
{
Format
:
resource
.
BinarySI
}
for
_
,
container
:=
range
podStats
.
Containers
{
for
_
,
container
:=
range
podStats
.
Containers
{
if
hasFsStats
(
statsToMeasure
,
fsStatsRoot
)
{
if
hasFsStats
Type
(
statsToMeasure
,
fsStatsRoot
)
{
disk
.
Add
(
*
diskUsage
(
container
.
Rootfs
))
disk
.
Add
(
*
diskUsage
(
container
.
Rootfs
))
}
}
if
hasFsStats
(
statsToMeasure
,
fsStatsLogs
)
{
if
hasFsStats
Type
(
statsToMeasure
,
fsStatsLogs
)
{
disk
.
Add
(
*
diskUsage
(
container
.
Logs
))
disk
.
Add
(
*
diskUsage
(
container
.
Logs
))
}
}
}
}
if
hasFsStats
(
statsToMeasure
,
fsStatsLocalVolumeSource
)
{
if
hasFsStats
Type
(
statsToMeasure
,
fsStatsLocalVolumeSource
)
{
volumeNames
:=
localVolumeNames
(
pod
)
volumeNames
:=
localVolumeNames
(
pod
)
for
_
,
volumeName
:=
range
volumeNames
{
for
_
,
volumeName
:=
range
volumeNames
{
for
_
,
volumeStats
:=
range
podStats
.
VolumeStats
{
for
_
,
volumeStats
:=
range
podStats
.
VolumeStats
{
if
volumeStats
.
Name
==
volumeName
{
if
volumeStats
.
Name
==
volumeName
{
disk
.
Add
(
*
diskUsage
(
&
volumeStats
.
FsStats
))
disk
.
Add
(
*
diskUsage
(
&
volumeStats
.
FsStats
))
break
}
}
}
}
}
}
...
@@ -451,7 +453,7 @@ func memory(stats statsFunc) cmpFunc {
...
@@ -451,7 +453,7 @@ func memory(stats statsFunc) cmpFunc {
}
}
// disk compares pods by largest consumer of disk relative to request.
// disk compares pods by largest consumer of disk relative to request.
func
disk
(
stats
statsFunc
,
fsStatsToMeasure
[]
fsStats
)
cmpFunc
{
func
disk
(
stats
statsFunc
,
fsStatsToMeasure
[]
fsStats
Type
)
cmpFunc
{
return
func
(
p1
,
p2
*
api
.
Pod
)
int
{
return
func
(
p1
,
p2
*
api
.
Pod
)
int
{
p1Stats
,
found
:=
stats
(
p1
)
p1Stats
,
found
:=
stats
(
p1
)
// if we have no usage stats for p1, we want p2 first
// if we have no usage stats for p1, we want p2 first
...
@@ -489,7 +491,7 @@ func rankMemoryPressure(pods []*api.Pod, stats statsFunc) {
...
@@ -489,7 +491,7 @@ func rankMemoryPressure(pods []*api.Pod, stats statsFunc) {
}
}
// rankDiskPressureFunc returns a rankFunc that measures the specified fs stats.
// rankDiskPressureFunc returns a rankFunc that measures the specified fs stats.
func
rankDiskPressureFunc
(
fsStatsToMeasure
[]
fsStats
)
rankFunc
{
func
rankDiskPressureFunc
(
fsStatsToMeasure
[]
fsStats
Type
)
rankFunc
{
return
func
(
pods
[]
*
api
.
Pod
,
stats
statsFunc
)
{
return
func
(
pods
[]
*
api
.
Pod
,
stats
statsFunc
)
{
orderedBy
(
qosComparator
,
disk
(
stats
,
fsStatsToMeasure
))
.
Sort
(
pods
)
orderedBy
(
qosComparator
,
disk
(
stats
,
fsStatsToMeasure
))
.
Sort
(
pods
)
}
}
...
@@ -622,8 +624,8 @@ func nodeConditionsObservedSince(observedAt nodeConditionsObservedAt, period tim
...
@@ -622,8 +624,8 @@ func nodeConditionsObservedSince(observedAt nodeConditionsObservedAt, period tim
return
results
return
results
}
}
// h
gasFsStats
returns true if the fsStat is in the input list
// h
asFsStatsType
returns true if the fsStat is in the input list
func
hasFsStats
(
inputs
[]
fsStats
,
item
fsStats
)
bool
{
func
hasFsStats
Type
(
inputs
[]
fsStatsType
,
item
fsStatsType
)
bool
{
for
_
,
input
:=
range
inputs
{
for
_
,
input
:=
range
inputs
{
if
input
==
item
{
if
input
==
item
{
return
true
return
true
...
@@ -676,7 +678,7 @@ func isSoftEviction(thresholds []Threshold, starvedResource api.ResourceName) bo
...
@@ -676,7 +678,7 @@ func isSoftEviction(thresholds []Threshold, starvedResource api.ResourceName) bo
return
true
return
true
}
}
// build
r
esourceToRankFunc returns ranking functions associated with resources
// build
R
esourceToRankFunc returns ranking functions associated with resources
func
buildResourceToRankFunc
(
withImageFs
bool
)
map
[
api
.
ResourceName
]
rankFunc
{
func
buildResourceToRankFunc
(
withImageFs
bool
)
map
[
api
.
ResourceName
]
rankFunc
{
resourceToRankFunc
:=
map
[
api
.
ResourceName
]
rankFunc
{
resourceToRankFunc
:=
map
[
api
.
ResourceName
]
rankFunc
{
api
.
ResourceMemory
:
rankMemoryPressure
,
api
.
ResourceMemory
:
rankMemoryPressure
,
...
@@ -684,12 +686,12 @@ func buildResourceToRankFunc(withImageFs bool) map[api.ResourceName]rankFunc {
...
@@ -684,12 +686,12 @@ func buildResourceToRankFunc(withImageFs bool) map[api.ResourceName]rankFunc {
// usage of an imagefs is optional
// usage of an imagefs is optional
if
withImageFs
{
if
withImageFs
{
// with an imagefs, nodefs pod rank func for eviction only includes logs and local volumes
// with an imagefs, nodefs pod rank func for eviction only includes logs and local volumes
resourceToRankFunc
[
resourceNodeFs
]
=
rankDiskPressureFunc
([]
fsStats
{
fsStatsLogs
,
fsStatsLocalVolumeSource
})
resourceToRankFunc
[
resourceNodeFs
]
=
rankDiskPressureFunc
([]
fsStats
Type
{
fsStatsLogs
,
fsStatsLocalVolumeSource
})
// with an imagefs, imagefs pod rank func for eviction only includes rootfs
// with an imagefs, imagefs pod rank func for eviction only includes rootfs
resourceToRankFunc
[
resourceImageFs
]
=
rankDiskPressureFunc
([]
fsStats
{
fsStatsRoot
})
resourceToRankFunc
[
resourceImageFs
]
=
rankDiskPressureFunc
([]
fsStats
Type
{
fsStatsRoot
})
}
else
{
}
else
{
// without an imagefs, nodefs pod rank func for eviction looks at all fs stats
// without an imagefs, nodefs pod rank func for eviction looks at all fs stats
resourceToRankFunc
[
resourceNodeFs
]
=
rankDiskPressureFunc
([]
fsStats
{
fsStatsRoot
,
fsStatsLogs
,
fsStatsLocalVolumeSource
})
resourceToRankFunc
[
resourceNodeFs
]
=
rankDiskPressureFunc
([]
fsStats
Type
{
fsStatsRoot
,
fsStatsLogs
,
fsStatsLocalVolumeSource
})
}
}
return
resourceToRankFunc
return
resourceToRankFunc
}
}
pkg/kubelet/eviction/helpers_test.go
View file @
0de1e62b
...
@@ -311,7 +311,7 @@ func TestOrderedByDisk(t *testing.T) {
...
@@ -311,7 +311,7 @@ func TestOrderedByDisk(t *testing.T) {
return
result
,
found
return
result
,
found
}
}
pods
:=
[]
*
api
.
Pod
{
pod1
,
pod2
,
pod3
,
pod4
,
pod5
,
pod6
}
pods
:=
[]
*
api
.
Pod
{
pod1
,
pod2
,
pod3
,
pod4
,
pod5
,
pod6
}
orderedBy
(
disk
(
statsFn
,
[]
fsStats
{
fsStatsRoot
,
fsStatsLogs
,
fsStatsLocalVolumeSource
}))
.
Sort
(
pods
)
orderedBy
(
disk
(
statsFn
,
[]
fsStats
Type
{
fsStatsRoot
,
fsStatsLogs
,
fsStatsLocalVolumeSource
}))
.
Sort
(
pods
)
expected
:=
[]
*
api
.
Pod
{
pod6
,
pod5
,
pod4
,
pod3
,
pod2
,
pod1
}
expected
:=
[]
*
api
.
Pod
{
pod6
,
pod5
,
pod4
,
pod3
,
pod2
,
pod1
}
for
i
:=
range
expected
{
for
i
:=
range
expected
{
if
pods
[
i
]
!=
expected
[
i
]
{
if
pods
[
i
]
!=
expected
[
i
]
{
...
@@ -377,7 +377,7 @@ func TestOrderedByQoSDisk(t *testing.T) {
...
@@ -377,7 +377,7 @@ func TestOrderedByQoSDisk(t *testing.T) {
return
result
,
found
return
result
,
found
}
}
pods
:=
[]
*
api
.
Pod
{
pod1
,
pod2
,
pod3
,
pod4
,
pod5
,
pod6
}
pods
:=
[]
*
api
.
Pod
{
pod1
,
pod2
,
pod3
,
pod4
,
pod5
,
pod6
}
orderedBy
(
qosComparator
,
disk
(
statsFn
,
[]
fsStats
{
fsStatsRoot
,
fsStatsLogs
,
fsStatsLocalVolumeSource
}))
.
Sort
(
pods
)
orderedBy
(
qosComparator
,
disk
(
statsFn
,
[]
fsStats
Type
{
fsStatsRoot
,
fsStatsLogs
,
fsStatsLocalVolumeSource
}))
.
Sort
(
pods
)
expected
:=
[]
*
api
.
Pod
{
pod2
,
pod1
,
pod4
,
pod3
,
pod6
,
pod5
}
expected
:=
[]
*
api
.
Pod
{
pod2
,
pod1
,
pod4
,
pod3
,
pod6
,
pod5
}
for
i
:=
range
expected
{
for
i
:=
range
expected
{
if
pods
[
i
]
!=
expected
[
i
]
{
if
pods
[
i
]
!=
expected
[
i
]
{
...
...
pkg/kubelet/eviction/types.go
View file @
0de1e62b
...
@@ -36,16 +36,16 @@ const (
...
@@ -36,16 +36,16 @@ const (
SignalImageFsAvailable
Signal
=
"imagefs.available"
SignalImageFsAvailable
Signal
=
"imagefs.available"
)
)
// fsStats defines the types of filesystem stats to collect.
// fsStats
Type
defines the types of filesystem stats to collect.
type
fsStats
string
type
fsStats
Type
string
const
(
const
(
// fsStatsLocalVolumeSource identifies stats for pod local volume sources.
// fsStatsLocalVolumeSource identifies stats for pod local volume sources.
fsStatsLocalVolumeSource
fsStats
=
"localVolumeSource"
fsStatsLocalVolumeSource
fsStats
Type
=
"localVolumeSource"
// fsStatsLogs identifies stats for pod logs.
// fsStatsLogs identifies stats for pod logs.
fsStatsLogs
fsStats
=
"logs"
fsStatsLogs
fsStats
Type
=
"logs"
// fsStatsRoot identifies stats for pod container writable layers.
// fsStatsRoot identifies stats for pod container writable layers.
fsStatsRoot
fsStats
=
"root"
fsStatsRoot
fsStats
Type
=
"root"
)
)
// ThresholdOperator is the operator used to express a Threshold.
// ThresholdOperator is the operator used to express a Threshold.
...
...
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
0de1e62b
...
@@ -2965,7 +2965,7 @@ func TestPodSchedulesOnNodeWithDiskPressureCondition(t *testing.T) {
...
@@ -2965,7 +2965,7 @@ func TestPodSchedulesOnNodeWithDiskPressureCondition(t *testing.T) {
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
fits
,
err
:=
CheckNodeDiskPressurePredicate
(
test
.
pod
,
test
.
nodeInfo
)
fits
,
err
:=
CheckNodeDiskPressurePredicate
(
test
.
pod
,
nil
,
test
.
nodeInfo
)
if
fits
!=
test
.
fits
{
if
fits
!=
test
.
fits
{
t
.
Errorf
(
"%s: expected %v got %v"
,
test
.
name
,
test
.
fits
,
fits
)
t
.
Errorf
(
"%s: expected %v got %v"
,
test
.
name
,
test
.
fits
,
fits
)
}
}
...
...
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