@@ -47,6 +47,15 @@ const (
47
47
podCleanupPollFreq = time .Second
48
48
)
49
49
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
+
50
59
// managerImpl implements Manager
51
60
type managerImpl struct {
52
61
// used to track time
@@ -480,7 +489,11 @@ func (m *managerImpl) emptyDirLimitEviction(podStats statsapi.PodStats, pod *v1.
480
489
used := podVolumeUsed [pod .Spec .Volumes [i ].Name ]
481
490
if used != nil && size != nil && size .Sign () == 1 && used .Cmp (* size ) > 0 {
482
491
// 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
484
497
}
485
498
}
486
499
}
@@ -512,7 +525,11 @@ func (m *managerImpl) podEphemeralStorageLimitEviction(podStats statsapi.PodStat
512
525
podEphemeralStorageLimit := podLimits [v1 .ResourceEphemeralStorage ]
513
526
if podEphemeralStorageTotalUsage .Cmp (podEphemeralStorageLimit ) > 0 {
514
527
// 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
516
533
}
517
534
return false
518
535
}
@@ -534,8 +551,11 @@ func (m *managerImpl) containerEphemeralStorageLimitEviction(podStats statsapi.P
534
551
535
552
if ephemeralStorageThreshold , ok := thresholdsMap [containerStat .Name ]; ok {
536
553
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
539
559
}
540
560
}
541
561
}
0 commit comments