@@ -152,8 +152,8 @@ func NewManager(cpuPolicyName string, reconcilePeriod time.Duration, machineInfo
152
152
}
153
153
154
154
func (m * manager ) Start (activePods ActivePodsFunc , podStatusProvider status.PodStatusProvider , containerRuntime runtimeService ) {
155
- glog .Infof ("[cpumanger ] starting with %s policy" , m .policy .Name ())
156
- glog .Infof ("[cpumanger ] reconciling every %v" , m .reconcilePeriod )
155
+ glog .Infof ("[cpumanager ] starting with %s policy" , m .policy .Name ())
156
+ glog .Infof ("[cpumanager ] reconciling every %v" , m .reconcilePeriod )
157
157
158
158
m .activePods = activePods
159
159
m .podStatusProvider = podStatusProvider
@@ -234,6 +234,25 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
234
234
continue
235
235
}
236
236
237
+ // Check whether container is present in state, there may be 3 reasons why it's not present:
238
+ // - policy does not want to track the container
239
+ // - kubelet has just been restarted - and there is no previous state file
240
+ // - container has been removed from state by RemoveContainer call (DeletionTimestamp is set)
241
+ if _ , ok := m .state .GetCPUSet (containerID ); ! ok {
242
+ if status .Phase == v1 .PodRunning && pod .DeletionTimestamp == nil {
243
+ glog .V (4 ).Infof ("[cpumanager] reconcileState: container is not present in state - trying to add (pod: %s, container: %s, container id: %s)" , pod .Name , container .Name , containerID )
244
+ err := m .AddContainer (pod , & container , containerID )
245
+ if err != nil {
246
+ glog .Errorf ("[cpumanager] reconcileState: failed to add container (pod: %s, container: %s, container id: %s, error: %v)" , pod .Name , container .Name , containerID , err )
247
+ failure = append (failure , reconciledContainer {pod .Name , container .Name , containerID })
248
+ }
249
+ } else {
250
+ // if DeletionTimestamp is set, pod has already been removed from state
251
+ // skip the pod/container since it's not running and will be deleted soon
252
+ continue
253
+ }
254
+ }
255
+
237
256
cset := m .state .GetCPUSetOrDefault (containerID )
238
257
if cset .IsEmpty () {
239
258
// NOTE: This should not happen outside of tests.
0 commit comments