Merge pull request #7272 from fidencio/topic/dragonball-k8s-number-cpus-fix

dragonball: Don't fail if a request asks for more CPUs than allowed
This commit is contained in:
Fabiano Fidêncio 2023-07-10 08:25:06 +02:00 committed by GitHub
commit afbc1f94d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View File

@ -161,7 +161,7 @@ impl Process {
pub fn notify_term_close(&mut self) {
let notify = self.term_exit_notifier.clone();
notify.notify_waiters();
notify.notify_one();
}
pub fn close_stdin(&mut self) {

View File

@ -595,16 +595,15 @@ impl AgentService {
let cid = req.container_id;
let eid = req.exec_id;
let term_exit_notifier;
let mut term_exit_notifier = Arc::new(tokio::sync::Notify::new());
let reader = {
let s = self.sandbox.clone();
let mut sandbox = s.lock().await;
let p = sandbox.find_container_process(cid.as_str(), eid.as_str())?;
term_exit_notifier = p.term_exit_notifier.clone();
if p.term_master.is_some() {
term_exit_notifier = p.term_exit_notifier.clone();
p.get_reader(StreamType::TermMaster)
} else if stdout {
if p.parent_stdout.is_some() {

View File

@ -341,7 +341,10 @@ impl DragonballInner {
// cannot exceed maximum value
if new_vcpus > self.config.cpu_info.default_maxvcpus {
return Err(anyhow!("resize vcpu error: cannot greater than maxvcpus"));
warn!(
sl!(),
"Cannot allocate more vcpus than the max allowed number of vcpus. The maximum allowed amount of vcpus will be used instead.");
return Ok((current_vcpus, self.config.cpu_info.default_maxvcpus));
}
Ok((current_vcpus, new_vcpus))

View File

@ -9,11 +9,15 @@ load "${BATS_TEST_DIRNAME}/../../common.bash"
load "${BATS_TEST_DIRNAME}/tests_common.sh"
setup() {
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "Test is currently failing, see: https://github.com/kata-containers/kata-containers/issues/7271"
pod_name="pod-oom"
get_pod_config_dir
}
@test "Test OOM events for pods" {
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "Test is currently failing, see: https://github.com/kata-containers/kata-containers/issues/7271"
# Create pod
kubectl create -f "${pod_config_dir}/$pod_name.yaml"
@ -29,6 +33,8 @@ setup() {
}
teardown() {
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "Test is currently failing, see: https://github.com/kata-containers/kata-containers/issues/7271"
# Debugging information
kubectl describe "pod/$pod_name"
kubectl get "pod/$pod_name" -o yaml