Skip to content

Commit 7be9b0f

Browse files
committed
Update comments and error messages in the CPUManager
1 parent f2acbf6 commit 7be9b0f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/kubelet/cm/cpumanager/cpu_manager.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ func (m *manager) Start(activePods ActivePodsFunc, sourcesReady config.SourcesRe
192192
if m.policy.Name() == string(PolicyNone) {
193193
return
194194
}
195+
// Periodically call m.reconcileState() to continue to keep the CPU sets of
196+
// all pods in sync with and guaranteed CPUs handed out among them.
195197
go wait.Until(func() { m.reconcileState() }, m.reconcilePeriod, wait.NeverStop)
196198
}
197199

@@ -208,19 +210,24 @@ func (m *manager) AddContainer(p *v1.Pod, c *v1.Container, containerID string) e
208210
}
209211
}
210212
}
213+
214+
// Call down into the policy to assign this container CPUs if required.
211215
err := m.policyAddContainer(p, c, containerID)
212216
if err != nil {
213217
klog.Errorf("[cpumanager] AddContainer error: %v", err)
214218
m.Unlock()
215219
return err
216220
}
221+
222+
// Get the CPUs just assigned to the container (or fall back to the default
223+
// CPUSet if none were assigned).
217224
cpus := m.state.GetCPUSetOrDefault(string(p.UID), c.Name)
218225
m.Unlock()
219226

220227
if !cpus.IsEmpty() {
221228
err = m.updateContainerCPUSet(containerID, cpus)
222229
if err != nil {
223-
klog.Errorf("[cpumanager] AddContainer error: %v", err)
230+
klog.Errorf("[cpumanager] AddContainer error: error updating CPUSet for container (pod: %s, container: %s, container id: %s, err: %v)", p.Name, c.Name, containerID, err)
224231
m.Lock()
225232
err := m.policyRemoveContainerByID(containerID)
226233
if err != nil {
@@ -376,7 +383,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
376383

377384
if cstatus.State.Waiting != nil ||
378385
(cstatus.State.Waiting == nil && cstatus.State.Running == nil && cstatus.State.Terminated == nil) {
379-
klog.Warningf("[cpumanager] reconcileState: skipping container; container still in the waiting state (pod: %s, container: %s)", pod.Name, container.Name)
386+
klog.Warningf("[cpumanager] reconcileState: skipping container; container still in the waiting state (pod: %s, container: %s, error: %v)", pod.Name, container.Name, err)
380387
failure = append(failure, reconciledContainer{pod.Name, container.Name, ""})
381388
continue
382389
}
@@ -398,6 +405,9 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
398405
continue
399406
}
400407

408+
// Once we make it here we know we have a running container.
409+
// Idempotently add it to the containerMap incase it is missing.
410+
// This can happen after a kubelet restart, for example.
401411
m.containerMap.Add(string(pod.UID), container.Name, containerID)
402412

403413
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)

0 commit comments

Comments
 (0)