Compare commits

...

3 Commits

Author SHA1 Message Date
Fupan Li
c376ab5de7 runtime-rs: fix the issue of hot-unplug memory smaller
It should do nothing instead of return an error when
hot-unplug the memory to the size smaller than static
plugged memory size.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-11-10 14:17:44 +08:00
Fupan Li
200abc815c tests: fix the issue of missing teardown pods
Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-11-10 10:30:17 +08:00
Fupan Li
333d12dc47 runtime: fix the issue of update interface error
Since the network device hotplug is an asynchronous operation,
it's possible that the hotplug operation had returned, but
the network device hasn't ready in guest, thus it's better to
retry on this operation to wait until the device ready in guest.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-11-07 11:29:57 +08:00
3 changed files with 36 additions and 10 deletions

View File

@@ -603,15 +603,15 @@ impl QemuInner {
}
};
let coldplugged_mem = megs_to_bytes(self.config.memory_info.default_memory);
let coldplugged_mem_mb = self.config.memory_info.default_memory;
let coldplugged_mem = megs_to_bytes(coldplugged_mem_mb);
let new_total_mem = megs_to_bytes(new_total_mem_mb);
if new_total_mem < coldplugged_mem {
return Err(anyhow!(
"asked to resize to {} M but that is less than cold-plugged memory size ({})",
new_total_mem_mb,
bytes_to_megs(coldplugged_mem)
));
warn!(sl!(), "asked to resize to {} M but that is less than cold-plugged memory size ({}), nothing to do",new_total_mem_mb,
bytes_to_megs(coldplugged_mem));
return Ok((coldplugged_mem_mb, MemoryConfig::default()));
}
let guest_mem_block_size = qmp.guest_memory_block_size();

View File

@@ -36,6 +36,7 @@ import (
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/rootless"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils/retry"
ctrAnnotations "github.com/containerd/containerd/pkg/cri/annotations"
crioAnnotations "github.com/cri-o/cri-o/pkg/annotations"
@@ -597,7 +598,31 @@ func (k *kataAgent) updateInterface(ctx context.Context, ifc *pbTypes.Interface)
ifcReq := &grpc.UpdateInterfaceRequest{
Interface: ifc,
}
resultingInterface, err := k.sendReq(ctx, ifcReq)
// Since the network device hotplug is an asynchronous operation,
// it's possible that the hotplug operation had returned, but the network device
// hasn't ready in guest, thus it's better to retry on this operation to
// wait until the device ready in guest.
var resultingInterface interface{}
err := retry.Do(func() error {
if resInterface, nerr := k.sendReq(ctx, ifcReq); nerr != nil {
errMsg := nerr.Error()
if !strings.Contains(errMsg, "Link not found") {
return retry.Unrecoverable(nerr)
}
return nerr
} else {
resultingInterface = resInterface
return nil
}
},
retry.Attempts(20),
retry.LastErrorOnly(true),
retry.Delay(20*time.Millisecond))
if err != nil {
k.Logger().WithFields(logrus.Fields{
"interface-requested": fmt.Sprintf("%+v", ifc),

View File

@@ -82,6 +82,9 @@ setup() {
[ "$total_cpus_container" -eq "$total_cpus" ] && break
sleep 1
done
info "total_cpus_container = $total_cpus_container"
[ "$total_cpus_container" -eq "$total_cpus" ]
# Check the total of requests
@@ -117,10 +120,8 @@ setup() {
teardown() {
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
[ "${KATA_HYPERVISOR}" == "dragonball" ] && skip "test not working see: ${dragonball_limitations}"
[ "${KATA_HYPERVISOR}" == "qemu-runtime-rs" ] && skip "Requires CPU hotplug which isn't supported on ${KATA_HYPERVISOR} yet"
[ "${KATA_HYPERVISOR}" == "qemu-se-runtime-rs" ] && skip "Requires CPU hotplug which isn't supported on ${KATA_HYPERVISOR} yet"
[ "${KATA_HYPERVISOR}" == "cloud-hypervisor" ] && skip "https://github.com/kata-containers/kata-containers/issues/9039"
[ "${KATA_HYPERVISOR}" == "qemu-coco-dev*" ] && skip "test not working see: ${fc_limitations}"
( [ "${KATA_HYPERVISOR}" == "qemu-tdx" ] || [ "${KATA_HYPERVISOR}" == "qemu-snp" ] || \
[ "${KATA_HYPERVISOR}" == "qemu-se" ] ) \
&& skip "TEEs do not support memory / CPU hotplug"