agent: ignore updating cpuset error when update cgroups

The result of `cpuset_controller.set_cpus(&cpu.cpus)` is unwrapped,
this will lead creating container to fail if cpuset is set.

The sandbox's `CreateContainer` sequence is:

c, err := newContainer(s, &contConfig)
err = c.create()
  c.sandbox.agent.createContainer(c.sandbox, c) (1)
err = s.updateResources()
  oldCPUs, newCPUs, err := s.hypervisor.resizeVCPUs(sandboxVCPUs) (2)

cpuset only avaiable after `s.hypervisor.resizeVCPUs` has been called at (2),
and then cpuset is written to cgourps file.

Fixes: #1159

Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
bin liu 2020-12-01 16:45:57 +08:00
parent 1dd77e204f
commit 705182d04e

View File

@ -365,7 +365,9 @@ fn set_cpu_resources(cg: &cgroups::Cgroup, cpu: &LinuxCPU) -> Result<()> {
let cpuset_controller: &CpuSetController = cg.controller_of().unwrap();
if !cpu.cpus.is_empty() {
cpuset_controller.set_cpus(&cpu.cpus)?;
if let Err(e) = cpuset_controller.set_cpus(&cpu.cpus) {
warn!(sl!(), "write cpuset failed: {:?}", e);
}
}
if !cpu.mems.is_empty() {