From f4509b806ba9f930129194a0e08bb439a7ed392c Mon Sep 17 00:00:00 2001 From: Dan Mihai Date: Sat, 24 Feb 2024 19:15:57 +0000 Subject: [PATCH] runtime: clh: minimum 10s timeout for CreateVM + BootVM Relax the timeout for calling CLH's CreateVM + BootVM APIs. When hitting the older 1s timeout, killing a half-booted Guest and retrying the same boot sequence could have been wasteful and resulting in unstable CI testing on slower Hosts. Fixes: #9152 Signed-off-by: Dan Mihai --- src/runtime/virtcontainers/clh.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 3a6d5a408a..f39ece6d2d 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -75,6 +75,9 @@ const ( clhTimeout = 10 clhAPITimeout = 1 clhAPITimeoutConfidentialGuest = 20 + // Minimum timout for calling CreateVM followed by BootVM. Executing these two APIs + // might take longer than the value returned by getClhAPITimeout(). + clhCreateAndBootVMMinimumTimeout = 10 // Timeout for hot-plug - hotplug devices can take more time, than usual API calls // Use longer time timeout for it. clhHotPlugAPITimeout = 5 @@ -711,7 +714,11 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error { } clh.state.PID = pid - ctx, cancel := context.WithTimeout(ctx, clh.getClhAPITimeout()*time.Second) + bootTimeout := clh.getClhAPITimeout() + if bootTimeout < clhCreateAndBootVMMinimumTimeout { + bootTimeout = clhCreateAndBootVMMinimumTimeout + } + ctx, cancel := context.WithTimeout(ctx, bootTimeout*time.Second) defer cancel() if err := clh.bootVM(ctx); err != nil {