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
b7deb6d9
Commit
b7deb6d9
authored
Jun 11, 2018
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix eviction event formatting
parent
93b6d026
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
eviction_manager.go
pkg/kubelet/eviction/eviction_manager.go
+4
-4
helpers.go
pkg/kubelet/eviction/helpers.go
+12
-12
No files found.
pkg/kubelet/eviction/eviction_manager.go
View file @
b7deb6d9
...
@@ -157,7 +157,7 @@ func (m *managerImpl) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAd
...
@@ -157,7 +157,7 @@ func (m *managerImpl) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAd
return
lifecycle
.
PodAdmitResult
{
return
lifecycle
.
PodAdmitResult
{
Admit
:
false
,
Admit
:
false
,
Reason
:
Reason
,
Reason
:
Reason
,
Message
:
fmt
.
Sprintf
(
message
,
m
.
nodeConditions
),
Message
:
fmt
.
Sprintf
(
nodeLowMessageFmt
,
m
.
nodeConditions
),
}
}
}
}
...
@@ -478,7 +478,7 @@ func (m *managerImpl) emptyDirLimitEviction(podStats statsapi.PodStats, pod *v1.
...
@@ -478,7 +478,7 @@ func (m *managerImpl) emptyDirLimitEviction(podStats statsapi.PodStats, pod *v1.
used
:=
podVolumeUsed
[
pod
.
Spec
.
Volumes
[
i
]
.
Name
]
used
:=
podVolumeUsed
[
pod
.
Spec
.
Volumes
[
i
]
.
Name
]
if
used
!=
nil
&&
size
!=
nil
&&
size
.
Sign
()
==
1
&&
used
.
Cmp
(
*
size
)
>
0
{
if
used
!=
nil
&&
size
!=
nil
&&
size
.
Sign
()
==
1
&&
used
.
Cmp
(
*
size
)
>
0
{
// the emptyDir usage exceeds the size limit, evict the pod
// the emptyDir usage exceeds the size limit, evict the pod
return
m
.
evictPod
(
pod
,
0
,
fmt
.
Sprintf
(
emptyDirMessage
,
pod
.
Spec
.
Volumes
[
i
]
.
Name
,
size
.
String
()),
nil
)
return
m
.
evictPod
(
pod
,
0
,
fmt
.
Sprintf
(
emptyDirMessage
Fmt
,
pod
.
Spec
.
Volumes
[
i
]
.
Name
,
size
.
String
()),
nil
)
}
}
}
}
}
}
...
@@ -510,7 +510,7 @@ func (m *managerImpl) podEphemeralStorageLimitEviction(podStats statsapi.PodStat
...
@@ -510,7 +510,7 @@ func (m *managerImpl) podEphemeralStorageLimitEviction(podStats statsapi.PodStat
podEphemeralStorageLimit
:=
podLimits
[
v1
.
ResourceEphemeralStorage
]
podEphemeralStorageLimit
:=
podLimits
[
v1
.
ResourceEphemeralStorage
]
if
podEphemeralStorageTotalUsage
.
Cmp
(
podEphemeralStorageLimit
)
>
0
{
if
podEphemeralStorageTotalUsage
.
Cmp
(
podEphemeralStorageLimit
)
>
0
{
// the total usage of pod exceeds the total size limit of containers, evict the pod
// the total usage of pod exceeds the total size limit of containers, evict the pod
return
m
.
evictPod
(
pod
,
0
,
fmt
.
Sprintf
(
podEphemeralStorageMessage
,
podEphemeralStorageLimit
.
String
()),
nil
)
return
m
.
evictPod
(
pod
,
0
,
fmt
.
Sprintf
(
podEphemeralStorageMessage
Fmt
,
podEphemeralStorageLimit
.
String
()),
nil
)
}
}
return
false
return
false
}
}
...
@@ -532,7 +532,7 @@ func (m *managerImpl) containerEphemeralStorageLimitEviction(podStats statsapi.P
...
@@ -532,7 +532,7 @@ func (m *managerImpl) containerEphemeralStorageLimitEviction(podStats statsapi.P
if
ephemeralStorageThreshold
,
ok
:=
thresholdsMap
[
containerStat
.
Name
];
ok
{
if
ephemeralStorageThreshold
,
ok
:=
thresholdsMap
[
containerStat
.
Name
];
ok
{
if
ephemeralStorageThreshold
.
Cmp
(
*
containerUsed
)
<
0
{
if
ephemeralStorageThreshold
.
Cmp
(
*
containerUsed
)
<
0
{
return
m
.
evictPod
(
pod
,
0
,
fmt
.
Sprintf
(
containerEphemeralStorageMessage
,
containerStat
.
Name
,
ephemeralStorageThreshold
.
String
()),
nil
)
return
m
.
evictPod
(
pod
,
0
,
fmt
.
Sprintf
(
containerEphemeralStorageMessage
Fmt
,
containerStat
.
Name
,
ephemeralStorageThreshold
.
String
()),
nil
)
}
}
}
}
...
...
pkg/kubelet/eviction/helpers.go
View file @
b7deb6d9
...
@@ -38,16 +38,16 @@ const (
...
@@ -38,16 +38,16 @@ const (
unsupportedEvictionSignal
=
"unsupported eviction signal %v"
unsupportedEvictionSignal
=
"unsupported eviction signal %v"
// Reason is the reason reported back in status.
// Reason is the reason reported back in status.
Reason
=
"Evicted"
Reason
=
"Evicted"
//
the message associated with the reason
.
//
nodeLowMessageFmt is the message for evictions due to resource pressure
.
message
=
"The node was low on resource: %v. "
nodeLowMessageFmt
=
"The node was low on resource: %v. "
// additional information for containers exceeding requests
//
containerMessageFmt provides
additional information for containers exceeding requests
containerMessage
=
"Container %s was using %s, which exceeds its request of %s. "
containerMessage
Fmt
=
"Container %s was using %s, which exceeds its request of %s. "
// additional information for containers which have exceeded their ES limit
//
containerEphemeralStorageMessageFmt provides
additional information for containers which have exceeded their ES limit
containerEphemeralStorageMessage
=
"Container %s exceeded its local ephemeral storage limit %q. "
containerEphemeralStorageMessage
Fmt
=
"Container %s exceeded its local ephemeral storage limit %q. "
// additional information for pods which have exceeded their ES limit
//
podEphemeralStorageMessageFmt provides
additional information for pods which have exceeded their ES limit
podEphemeralStorageMessage
=
"Pod ephemeral local storage usage exceeds the total limit of containers %s. "
podEphemeralStorageMessage
Fmt
=
"Pod ephemeral local storage usage exceeds the total limit of containers %s. "
// additional information for empty-dir volumes which have exceeded their size limit
//
emptyDirMessageFmt provides
additional information for empty-dir volumes which have exceeded their size limit
emptyDirMessage
=
"Usage of EmptyDir volume %q exceeds the limit %q. "
emptyDirMessage
Fmt
=
"Usage of EmptyDir volume %q exceeds the limit %q. "
// inodes, number. internal to this module, used to account for local disk inode consumption.
// inodes, number. internal to this module, used to account for local disk inode consumption.
resourceInodes
v1
.
ResourceName
=
"inodes"
resourceInodes
v1
.
ResourceName
=
"inodes"
// OffendingContainersKey is the key in eviction event annotations for the list of container names which exceeded their requests
// OffendingContainersKey is the key in eviction event annotations for the list of container names which exceeded their requests
...
@@ -1061,7 +1061,7 @@ func buildSignalToNodeReclaimFuncs(imageGC ImageGC, containerGC ContainerGC, wit
...
@@ -1061,7 +1061,7 @@ func buildSignalToNodeReclaimFuncs(imageGC ImageGC, containerGC ContainerGC, wit
// evictionMessage constructs a useful message about why an eviction occurred, and annotations to provide metadata about the eviction
// evictionMessage constructs a useful message about why an eviction occurred, and annotations to provide metadata about the eviction
func
evictionMessage
(
resourceToReclaim
v1
.
ResourceName
,
pod
*
v1
.
Pod
,
stats
statsFunc
)
(
message
string
,
annotations
map
[
string
]
string
)
{
func
evictionMessage
(
resourceToReclaim
v1
.
ResourceName
,
pod
*
v1
.
Pod
,
stats
statsFunc
)
(
message
string
,
annotations
map
[
string
]
string
)
{
annotations
=
make
(
map
[
string
]
string
)
annotations
=
make
(
map
[
string
]
string
)
message
=
fmt
.
Sprintf
(
message
,
resourceToReclaim
)
message
=
fmt
.
Sprintf
(
nodeLowMessageFmt
,
resourceToReclaim
)
containers
:=
[]
string
{}
containers
:=
[]
string
{}
containerUsage
:=
[]
string
{}
containerUsage
:=
[]
string
{}
podStats
,
ok
:=
stats
(
pod
)
podStats
,
ok
:=
stats
(
pod
)
...
@@ -1084,7 +1084,7 @@ func evictionMessage(resourceToReclaim v1.ResourceName, pod *v1.Pod, stats stats
...
@@ -1084,7 +1084,7 @@ func evictionMessage(resourceToReclaim v1.ResourceName, pod *v1.Pod, stats stats
}
}
}
}
if
usage
!=
nil
&&
usage
.
Cmp
(
requests
)
>
0
{
if
usage
!=
nil
&&
usage
.
Cmp
(
requests
)
>
0
{
message
+=
fmt
.
Sprintf
(
containerMessage
,
container
.
Name
,
usage
.
String
(),
requests
.
String
())
message
+=
fmt
.
Sprintf
(
containerMessage
Fmt
,
container
.
Name
,
usage
.
String
(),
requests
.
String
())
containers
=
append
(
containers
,
container
.
Name
)
containers
=
append
(
containers
,
container
.
Name
)
containerUsage
=
append
(
containerUsage
,
usage
.
String
())
containerUsage
=
append
(
containerUsage
,
usage
.
String
())
}
}
...
...
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