From e0513094a02d196193cf6494ebebb0c1ddbe60cb Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 30 Aug 2023 03:01:22 +0000 Subject: [PATCH] runtime/vc: runPrestartHooks should ignore GetHypervisorPid failure If we are running FC hypervisor, it is not started when prestart hooks are executed. So we should just ignore such error and just go ahead and run the hooks. Signed-off-by: Peng Tao (cherry picked from commit 2e4c874726a9e10b53fcae52bca1a45bc642f689) Signed-off-by: Greg Kurz --- src/runtime/virtcontainers/sandbox.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/runtime/virtcontainers/sandbox.go b/src/runtime/virtcontainers/sandbox.go index a53003fc67..bbbe9ef190 100644 --- a/src/runtime/virtcontainers/sandbox.go +++ b/src/runtime/virtcontainers/sandbox.go @@ -1300,13 +1300,12 @@ func (s *Sandbox) cleanSwap(ctx context.Context) { } func (s *Sandbox) runPrestartHooks(ctx context.Context, prestartHookFunc func(context.Context) error) error { - hid, err := s.GetHypervisorPid() - if err != nil { - s.Logger().Errorf("fail to get hypervisor pid for sandbox %s", s.id) - return err + hid, _ := s.GetHypervisorPid() + // Ignore errors here as hypervisor might not have been started yet, likely in FC case. + if hid > 0 { + s.Logger().Infof("sandbox %s hypervisor pid is %v", s.id, hid) + ctx = context.WithValue(ctx, HypervisorPidKey{}, hid) } - s.Logger().Infof("sandbox %s hypervisor pid is %v", s.id, hid) - ctx = context.WithValue(ctx, HypervisorPidKey{}, hid) if err := prestartHookFunc(ctx); err != nil { s.Logger().Errorf("fail to run prestartHook for sandbox %s: %s", s.id, err)