mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Move CPUManager Pod Status logic before container loop
This commit is contained in:
parent
f680c261e6
commit
f6cf9b8ce9
@ -350,19 +350,19 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
|
|
||||||
m.removeStaleState()
|
m.removeStaleState()
|
||||||
for _, pod := range m.activePods() {
|
for _, pod := range m.activePods() {
|
||||||
|
pstatus, ok := m.podStatusProvider.GetPodStatus(pod.UID)
|
||||||
|
if !ok {
|
||||||
|
klog.Warningf("[cpumanager] reconcileState: skipping pod; status not found (pod: %s)", pod.Name)
|
||||||
|
failure = append(failure, reconciledContainer{pod.Name, "", ""})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
allContainers := pod.Spec.InitContainers
|
allContainers := pod.Spec.InitContainers
|
||||||
allContainers = append(allContainers, pod.Spec.Containers...)
|
allContainers = append(allContainers, pod.Spec.Containers...)
|
||||||
status, ok := m.podStatusProvider.GetPodStatus(pod.UID)
|
|
||||||
for _, container := range allContainers {
|
for _, container := range allContainers {
|
||||||
if !ok {
|
containerID, err := findContainerIDByName(&pstatus, container.Name)
|
||||||
klog.Warningf("[cpumanager] reconcileState: skipping pod; status not found (pod: %s)", pod.Name)
|
|
||||||
failure = append(failure, reconciledContainer{pod.Name, container.Name, ""})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
containerID, err := findContainerIDByName(&status, container.Name)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Warningf("[cpumanager] reconcileState: skipping container; ID not found in status (pod: %s, container: %s, error: %v)", pod.Name, container.Name, err)
|
klog.Warningf("[cpumanager] reconcileState: skipping container; ID not found in pod status (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
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
// - kubelet has just been restarted - and there is no previous state file
|
// - kubelet has just been restarted - and there is no previous state file
|
||||||
// - container has been removed from state by RemoveContainer call (DeletionTimestamp is set)
|
// - container has been removed from state by RemoveContainer call (DeletionTimestamp is set)
|
||||||
if _, ok := m.state.GetCPUSet(string(pod.UID), container.Name); !ok {
|
if _, ok := m.state.GetCPUSet(string(pod.UID), container.Name); !ok {
|
||||||
if status.Phase == v1.PodRunning && pod.DeletionTimestamp == nil {
|
if pstatus.Phase == v1.PodRunning && pod.DeletionTimestamp == nil {
|
||||||
klog.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)
|
klog.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)
|
||||||
err := m.AddContainer(pod, &container, containerID)
|
err := m.AddContainer(pod, &container, containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -774,7 +774,7 @@ func TestReconcileState(t *testing.T) {
|
|||||||
stDefaultCPUSet: cpuset.NewCPUSet(),
|
stDefaultCPUSet: cpuset.NewCPUSet(),
|
||||||
updateErr: nil,
|
updateErr: nil,
|
||||||
expectSucceededContainerName: "",
|
expectSucceededContainerName: "",
|
||||||
expectFailedContainerName: "fakeContainerName",
|
expectFailedContainerName: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "cpu manager reconclie - container id not found",
|
description: "cpu manager reconclie - container id not found",
|
||||||
|
Loading…
Reference in New Issue
Block a user