Merge pull request #9112 from adityaramani/handle-shim-kill
Sandbox: Handle unexpected shim kill events
This commit is contained in:
commit
7a0e6b7e77
@ -393,7 +393,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errdefs.IsNotFound(err) {
|
if !errdefs.IsNotFound(err) && !errdefs.IsUnavailable(err) {
|
||||||
return fmt.Errorf("failed to load task for container: %w", err)
|
return fmt.Errorf("failed to load task for container: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -262,6 +262,12 @@ func (c *controllerLocal) Wait(ctx context.Context, sandboxID string) (sandbox.E
|
|||||||
|
|
||||||
func (c *controllerLocal) Status(ctx context.Context, sandboxID string, verbose bool) (sandbox.ControllerStatus, error) {
|
func (c *controllerLocal) Status(ctx context.Context, sandboxID string, verbose bool) (sandbox.ControllerStatus, error) {
|
||||||
svc, err := c.getSandbox(ctx, sandboxID)
|
svc, err := c.getSandbox(ctx, sandboxID)
|
||||||
|
if errdefs.IsNotFound(err) {
|
||||||
|
return sandbox.ControllerStatus{
|
||||||
|
SandboxID: sandboxID,
|
||||||
|
ExitedAt: time.Now(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sandbox.ControllerStatus{}, err
|
return sandbox.ControllerStatus{}, err
|
||||||
}
|
}
|
||||||
@ -301,7 +307,7 @@ func (c *controllerLocal) Metrics(ctx context.Context, sandboxID string) (*types
|
|||||||
func (c *controllerLocal) getSandbox(ctx context.Context, id string) (runtimeAPI.TTRPCSandboxService, error) {
|
func (c *controllerLocal) getSandbox(ctx context.Context, id string) (runtimeAPI.TTRPCSandboxService, error) {
|
||||||
shim, err := c.shims.Get(ctx, id)
|
shim, err := c.shims.Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errdefs.ErrNotFound
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return sandbox.NewClient(shim.Client())
|
return sandbox.NewClient(shim.Client())
|
||||||
|
@ -144,6 +144,13 @@ func (s *controllerService) Status(ctx context.Context, req *api.ControllerStatu
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return &api.ControllerStatusResponse{}, errdefs.ToGRPC(err)
|
return &api.ControllerStatusResponse{}, errdefs.ToGRPC(err)
|
||||||
}
|
}
|
||||||
|
extra := &anypb.Any{}
|
||||||
|
if cstatus.Extra != nil {
|
||||||
|
extra = &anypb.Any{
|
||||||
|
TypeUrl: cstatus.Extra.GetTypeUrl(),
|
||||||
|
Value: cstatus.Extra.GetValue(),
|
||||||
|
}
|
||||||
|
}
|
||||||
return &api.ControllerStatusResponse{
|
return &api.ControllerStatusResponse{
|
||||||
SandboxID: cstatus.SandboxID,
|
SandboxID: cstatus.SandboxID,
|
||||||
Pid: cstatus.Pid,
|
Pid: cstatus.Pid,
|
||||||
@ -151,10 +158,7 @@ func (s *controllerService) Status(ctx context.Context, req *api.ControllerStatu
|
|||||||
Info: cstatus.Info,
|
Info: cstatus.Info,
|
||||||
CreatedAt: protobuf.ToTimestamp(cstatus.CreatedAt),
|
CreatedAt: protobuf.ToTimestamp(cstatus.CreatedAt),
|
||||||
ExitedAt: protobuf.ToTimestamp(cstatus.ExitedAt),
|
ExitedAt: protobuf.ToTimestamp(cstatus.ExitedAt),
|
||||||
Extra: &anypb.Any{
|
Extra: extra,
|
||||||
TypeUrl: cstatus.Extra.GetTypeUrl(),
|
|
||||||
Value: cstatus.Extra.GetValue(),
|
|
||||||
},
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ func getProcessState(ctx context.Context, p runtime.Process) (*task.Process, err
|
|||||||
|
|
||||||
state, err := p.State(ctx)
|
state, err := p.State(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) || errdefs.IsUnavailable(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.G(ctx).WithError(err).Errorf("get state for %s", p.ID())
|
log.G(ctx).WithError(err).Errorf("get state for %s", p.ID())
|
||||||
|
Loading…
Reference in New Issue
Block a user