mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Update comments and error messages in the CPUManager
This commit is contained in:
parent
f2acbf6607
commit
7be9b0fe55
@ -192,6 +192,8 @@ func (m *manager) Start(activePods ActivePodsFunc, sourcesReady config.SourcesRe
|
|||||||
if m.policy.Name() == string(PolicyNone) {
|
if m.policy.Name() == string(PolicyNone) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Periodically call m.reconcileState() to continue to keep the CPU sets of
|
||||||
|
// all pods in sync with and guaranteed CPUs handed out among them.
|
||||||
go wait.Until(func() { m.reconcileState() }, m.reconcilePeriod, wait.NeverStop)
|
go wait.Until(func() { m.reconcileState() }, m.reconcilePeriod, wait.NeverStop)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,19 +210,24 @@ func (m *manager) AddContainer(p *v1.Pod, c *v1.Container, containerID string) e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call down into the policy to assign this container CPUs if required.
|
||||||
err := m.policyAddContainer(p, c, containerID)
|
err := m.policyAddContainer(p, c, containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("[cpumanager] AddContainer error: %v", err)
|
klog.Errorf("[cpumanager] AddContainer error: %v", err)
|
||||||
m.Unlock()
|
m.Unlock()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the CPUs just assigned to the container (or fall back to the default
|
||||||
|
// CPUSet if none were assigned).
|
||||||
cpus := m.state.GetCPUSetOrDefault(string(p.UID), c.Name)
|
cpus := m.state.GetCPUSetOrDefault(string(p.UID), c.Name)
|
||||||
m.Unlock()
|
m.Unlock()
|
||||||
|
|
||||||
if !cpus.IsEmpty() {
|
if !cpus.IsEmpty() {
|
||||||
err = m.updateContainerCPUSet(containerID, cpus)
|
err = m.updateContainerCPUSet(containerID, cpus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("[cpumanager] AddContainer error: %v", err)
|
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)
|
||||||
m.Lock()
|
m.Lock()
|
||||||
err := m.policyRemoveContainerByID(containerID)
|
err := m.policyRemoveContainerByID(containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -376,7 +383,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
|
|
||||||
if cstatus.State.Waiting != nil ||
|
if cstatus.State.Waiting != nil ||
|
||||||
(cstatus.State.Waiting == nil && cstatus.State.Running == nil && cstatus.State.Terminated == nil) {
|
(cstatus.State.Waiting == nil && cstatus.State.Running == nil && cstatus.State.Terminated == nil) {
|
||||||
klog.Warningf("[cpumanager] reconcileState: skipping container; container still in the waiting state (pod: %s, container: %s)", pod.Name, container.Name)
|
klog.Warningf("[cpumanager] reconcileState: skipping container; container still in the waiting state (pod: %s, container: %s, error: %v)", pod.Name, container.Name, err)
|
||||||
failure = append(failure, reconciledContainer{pod.Name, container.Name, ""})
|
failure = append(failure, reconciledContainer{pod.Name, container.Name, ""})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -398,6 +405,9 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Once we make it here we know we have a running container.
|
||||||
|
// Idempotently add it to the containerMap incase it is missing.
|
||||||
|
// This can happen after a kubelet restart, for example.
|
||||||
m.containerMap.Add(string(pod.UID), container.Name, containerID)
|
m.containerMap.Add(string(pod.UID), container.Name, containerID)
|
||||||
|
|
||||||
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)
|
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)
|
||||||
|
Loading…
Reference in New Issue
Block a user