@@ -26,6 +26,7 @@ import (
26
26
27
27
v1 "k8s.io/api/core/v1"
28
28
"k8s.io/apimachinery/pkg/api/resource"
29
+ "k8s.io/apimachinery/pkg/types"
29
30
"k8s.io/apimachinery/pkg/util/clock"
30
31
utilfeature "k8s.io/apiserver/pkg/util/feature"
31
32
"k8s.io/client-go/tools/record"
@@ -98,6 +99,8 @@ type managerImpl struct {
98
99
thresholdNotifiers []ThresholdNotifier
99
100
// thresholdsLastUpdated is the last time the thresholdNotifiers were updated.
100
101
thresholdsLastUpdated time.Time
102
+ // etcHostsPath is a function that will get the etc-hosts file's path for a pod given its UID
103
+ etcHostsPath func (podUID types.UID ) string
101
104
}
102
105
103
106
// ensure it implements the required interface
@@ -114,6 +117,7 @@ func NewManager(
114
117
recorder record.EventRecorder ,
115
118
nodeRef * v1.ObjectReference ,
116
119
clock clock.Clock ,
120
+ etcHostsPath func (types.UID ) string ,
117
121
) (Manager , lifecycle.PodAdmitHandler ) {
118
122
manager := & managerImpl {
119
123
clock : clock ,
@@ -129,6 +133,7 @@ func NewManager(
129
133
thresholdsFirstObservedAt : thresholdsObservedAt {},
130
134
dedicatedImageFs : nil ,
131
135
thresholdNotifiers : []ThresholdNotifier {},
136
+ etcHostsPath : etcHostsPath ,
132
137
}
133
138
return manager , manager
134
139
}
@@ -514,7 +519,7 @@ func (m *managerImpl) podEphemeralStorageLimitEviction(podStats statsapi.PodStat
514
519
} else {
515
520
fsStatsSet = []fsStatsType {fsStatsRoot , fsStatsLogs , fsStatsLocalVolumeSource }
516
521
}
517
- podEphemeralUsage , err := podLocalEphemeralStorageUsage (podStats , pod , fsStatsSet )
522
+ podEphemeralUsage , err := podLocalEphemeralStorageUsage (podStats , pod , fsStatsSet , m . etcHostsPath ( pod . UID ) )
518
523
if err != nil {
519
524
klog .Errorf ("eviction manager: error getting pod disk usage %v" , err )
520
525
return false
0 commit comments