mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Run post-restore hook in the background.
After restorer.restoreDone() returns successfully, the sandbox has been started and the application is running. The caller of restorer.restore() is the "runsc restore" command. Do not hang the "restore" command even after the sandbox has been restored. Do the post-restore work in a separate goroutine. If it fails, log a warning and kill the sandbox. PiperOrigin-RevId: 674366811
This commit is contained in:
+12
-8
@@ -315,15 +315,19 @@ func (r *restorer) restore(l *Loader) error {
|
||||
r.pagesMetadata.Close()
|
||||
}
|
||||
|
||||
if err := postRestoreImpl(l); err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
if err := postRestoreImpl(l); err != nil {
|
||||
log.Warningf("Killing the sandbox after post restore work failed: %w", err)
|
||||
l.k.Kill(linux.WaitStatusTerminationSignal(linux.SIGKILL))
|
||||
return
|
||||
}
|
||||
|
||||
// Restore was successful, so increment the checkpoint count manually. The
|
||||
// count was saved while the previous kernel was being saved and checkpoint
|
||||
// success was unknown at that time. Now we know the checkpoint succeeded.
|
||||
l.k.IncCheckpointCount()
|
||||
log.Infof("Restore successful")
|
||||
// Restore was successful, so increment the checkpoint count manually. The
|
||||
// count was saved while the previous kernel was being saved and checkpoint
|
||||
// success was unknown at that time. Now we know the checkpoint succeeded.
|
||||
l.k.IncCheckpointCount()
|
||||
log.Infof("Restore successful")
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user