v2: Call shim.Delete at first when create is failed
If the context is cancelled during `shim.Create()`, such as the client disconnects unexpectedly. The created shim will never be deleted. What's more, if the context is cancelled during `openShimLog()`, the fifo will be closed and block the shim output. Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
This commit is contained in:
@@ -235,11 +235,11 @@ func (s *shim) Delete(ctx context.Context) (*runtime.Exit, error) {
|
||||
// this seems dirty but it cleans up the API across runtimes, tasks, and the service
|
||||
s.rtTasks.Delete(ctx, s.ID())
|
||||
if err := s.waitShutdown(ctx); err != nil {
|
||||
log.G(ctx).WithError(err).Error("failed to shutdown shim")
|
||||
log.G(ctx).WithField("id", s.ID()).WithError(err).Error("failed to shutdown shim")
|
||||
}
|
||||
s.Close()
|
||||
if err := s.bundle.Delete(); err != nil {
|
||||
log.G(ctx).WithError(err).Error("failed to delete bundle")
|
||||
log.G(ctx).WithField("id", s.ID()).WithError(err).Error("failed to delete bundle")
|
||||
}
|
||||
if shimErr != nil {
|
||||
return nil, shimErr
|
||||
|
Reference in New Issue
Block a user