Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear pod cpuset to support "cpuManagerPolicy=static" #177

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions vmm/sandbox/src/container/handler/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use containerd_sandbox::{
error::Error,
spec::{JsonSpec, Mount},
};
use log::debug;
use path_clean::clean;
use vmm_common::{
ETC_HOSTNAME, ETC_HOSTS, ETC_RESOLV, HOSTNAME_FILENAME, HOSTS_FILENAME, KUASAR_STATE_DIR,
Expand Down Expand Up @@ -69,6 +70,21 @@ where
if let Some(p) = spec.process.as_mut() {
p.apparmor_profile = "".to_string();
}

// When the kubelet configures cpuManagerPolicy as static, the Pod will specify CPU IDs
// for CPU affinity. Due to the different cpusets of the guest OS and host OS, this can
// lead to configuration failures. There is no need for CPU affinity in the guest OS,
// so the Pod's cpuset should be cleared.
spec.linux
.as_mut()
.and_then(|l| l.resources.as_mut())
.and_then(|r| {
r.cpu.as_mut().map(|cpu| {
debug!("Container cpuset will be clear: {:?}", &cpu.cpus);
cpu.cpus = "".to_string();
})
});

// Update sandbox files mounts for container
container_mounts(&shared_path, spec);
let spec_str = serde_json::to_string(spec)
Expand Down
Loading