Skip to content

Commit 64340bd

Browse files
authored
Merge pull request kubernetes#87906 from smarterclayton/evict_limit
kubelet: Record kubelet_evictions when limits are hit
2 parents 3a828af + af9e0be commit 64340bd

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

pkg/kubelet/eviction/eviction_manager.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ const (
4747
podCleanupPollFreq = time.Second
4848
)
4949

50+
const (
51+
// signalEphemeralContainerFsLimit is amount of storage available on filesystem requested by the container
52+
signalEphemeralContainerFsLimit string = "ephemeralcontainerfs.limit"
53+
// signalEphemeralPodFsLimit is amount of storage available on filesystem requested by the pod
54+
signalEphemeralPodFsLimit string = "ephemeralpodfs.limit"
55+
// signalEmptyDirFsLimit is amount of storage available on filesystem requested by an emptyDir
56+
signalEmptyDirFsLimit string = "emptydirfs.limit"
57+
)
58+
5059
// managerImpl implements Manager
5160
type managerImpl struct {
5261
// used to track time
@@ -480,7 +489,11 @@ func (m *managerImpl) emptyDirLimitEviction(podStats statsapi.PodStats, pod *v1.
480489
used := podVolumeUsed[pod.Spec.Volumes[i].Name]
481490
if used != nil && size != nil && size.Sign() == 1 && used.Cmp(*size) > 0 {
482491
// the emptyDir usage exceeds the size limit, evict the pod
483-
return m.evictPod(pod, 0, fmt.Sprintf(emptyDirMessageFmt, pod.Spec.Volumes[i].Name, size.String()), nil)
492+
if m.evictPod(pod, 0, fmt.Sprintf(emptyDirMessageFmt, pod.Spec.Volumes[i].Name, size.String()), nil) {
493+
metrics.Evictions.WithLabelValues(signalEmptyDirFsLimit).Inc()
494+
return true
495+
}
496+
return false
484497
}
485498
}
486499
}
@@ -512,7 +525,11 @@ func (m *managerImpl) podEphemeralStorageLimitEviction(podStats statsapi.PodStat
512525
podEphemeralStorageLimit := podLimits[v1.ResourceEphemeralStorage]
513526
if podEphemeralStorageTotalUsage.Cmp(podEphemeralStorageLimit) > 0 {
514527
// the total usage of pod exceeds the total size limit of containers, evict the pod
515-
return m.evictPod(pod, 0, fmt.Sprintf(podEphemeralStorageMessageFmt, podEphemeralStorageLimit.String()), nil)
528+
if m.evictPod(pod, 0, fmt.Sprintf(podEphemeralStorageMessageFmt, podEphemeralStorageLimit.String()), nil) {
529+
metrics.Evictions.WithLabelValues(signalEphemeralPodFsLimit).Inc()
530+
return true
531+
}
532+
return false
516533
}
517534
return false
518535
}
@@ -534,8 +551,11 @@ func (m *managerImpl) containerEphemeralStorageLimitEviction(podStats statsapi.P
534551

535552
if ephemeralStorageThreshold, ok := thresholdsMap[containerStat.Name]; ok {
536553
if ephemeralStorageThreshold.Cmp(*containerUsed) < 0 {
537-
return m.evictPod(pod, 0, fmt.Sprintf(containerEphemeralStorageMessageFmt, containerStat.Name, ephemeralStorageThreshold.String()), nil)
538-
554+
if m.evictPod(pod, 0, fmt.Sprintf(containerEphemeralStorageMessageFmt, containerStat.Name, ephemeralStorageThreshold.String()), nil) {
555+
metrics.Evictions.WithLabelValues(signalEphemeralContainerFsLimit).Inc()
556+
return true
557+
}
558+
return false
539559
}
540560
}
541561
}

0 commit comments

Comments
 (0)