mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-14 22:24:14 +00:00
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>
(cherry picked from commit 2e4c874726
)
Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
c17cbd30f0
commit
e0513094a0
@ -1300,13 +1300,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)
|
||||||
|
Loading…
Reference in New Issue
Block a user