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 <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2023-08-30 03:01:22 +00:00
parent 21204caf20
commit 2e4c874726

View File

@ -1322,13 +1322,12 @@ func (s *Sandbox) cleanSwap(ctx context.Context) {
} }
func (s *Sandbox) runPrestartHooks(ctx context.Context, prestartHookFunc func(context.Context) error) error { func (s *Sandbox) runPrestartHooks(ctx context.Context, prestartHookFunc func(context.Context) error) error {
hid, err := s.GetHypervisorPid() hid, _ := s.GetHypervisorPid()
if err != nil { // Ignore errors here as hypervisor might not have been started yet, likely in FC case.
s.Logger().Errorf("fail to get hypervisor pid for sandbox %s", s.id) if hid > 0 {
return err
}
s.Logger().Infof("sandbox %s hypervisor pid is %v", s.id, hid) s.Logger().Infof("sandbox %s hypervisor pid is %v", s.id, hid)
ctx = context.WithValue(ctx, HypervisorPidKey{}, hid) ctx = context.WithValue(ctx, HypervisorPidKey{}, hid)
}
if err := prestartHookFunc(ctx); err != nil { if err := prestartHookFunc(ctx); err != nil {
s.Logger().Errorf("fail to run prestartHook for sandbox %s: %s", s.id, err) s.Logger().Errorf("fail to run prestartHook for sandbox %s: %s", s.id, err)