Merge pull request #53122 from resouer/fix-cpu

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Eliminate extra CRI call during processing cpu set

**What this PR does / why we need it**:

Encountered this during `kubernetes/frakti` node e2e test.

When cpuset is not set, there's still plenty of `runtime.UpdateContainerResources` been called, which seems unnecessary.

cc @ConnorDoyle Make sense? Fixes: #53304

**Special notes for your reviewer**:

**Release note**:

```release-note
Only do UpdateContainerResources when cpuset is set 
```
This commit is contained in:
Kubernetes Submit Queue 2017-10-01 15:30:56 -07:00 committed by GitHub
commit 5e2ce3aaf2
2 changed files with 10 additions and 5 deletions

View File

@ -176,11 +176,16 @@ func (m *manager) AddContainer(p *v1.Pod, c *v1.Container, containerID string) e
cpus := m.state.GetCPUSetOrDefault(containerID) cpus := m.state.GetCPUSetOrDefault(containerID)
m.Unlock() m.Unlock()
err = m.updateContainerCPUSet(containerID, cpus) if !cpus.IsEmpty() {
if err != nil { err = m.updateContainerCPUSet(containerID, cpus)
glog.Errorf("[cpumanager] AddContainer error: %v", err) if err != nil {
return err glog.Errorf("[cpumanager] AddContainer error: %v", err)
return err
}
} else {
glog.V(5).Infof("[cpumanager] update container resources is skipped due to cpu set is empty")
} }
return nil return nil
} }

View File

@ -180,7 +180,7 @@ func TestCPUManagerAdd(t *testing.T) {
description: "cpu manager add - container update error", description: "cpu manager add - container update error",
regErr: nil, regErr: nil,
updateErr: fmt.Errorf("fake update error"), updateErr: fmt.Errorf("fake update error"),
expErr: fmt.Errorf("fake update error"), expErr: nil,
}, },
} }