(ctx context.Context, p runtime.Process)
| 365 | } |
| 366 | |
| 367 | func getProcessState(ctx context.Context, p runtime.Process) (*task.Process, error) { |
| 368 | ctx, cancel := timeout.WithContext(ctx, stateTimeout) |
| 369 | defer cancel() |
| 370 | |
| 371 | state, err := p.State(ctx) |
| 372 | if err != nil { |
| 373 | if errdefs.IsNotFound(err) || errdefs.IsUnavailable(err) || errdefs.IsDeadlineExceeded(err) { |
| 374 | return nil, err |
| 375 | } |
| 376 | log.G(ctx).WithError(err).Errorf("get state for %s", p.ID()) |
| 377 | } |
| 378 | status := task.Status_UNKNOWN |
| 379 | switch state.Status { |
| 380 | case runtime.CreatedStatus: |
| 381 | status = task.Status_CREATED |
| 382 | case runtime.RunningStatus: |
| 383 | status = task.Status_RUNNING |
| 384 | case runtime.StoppedStatus: |
| 385 | status = task.Status_STOPPED |
| 386 | case runtime.PausedStatus: |
| 387 | status = task.Status_PAUSED |
| 388 | case runtime.PausingStatus: |
| 389 | status = task.Status_PAUSING |
| 390 | default: |
| 391 | log.G(ctx).WithField("status", state.Status).Warn("unknown status") |
| 392 | } |
| 393 | return &task.Process{ |
| 394 | ID: p.ID(), |
| 395 | Pid: state.Pid, |
| 396 | Status: status, |
| 397 | Stdin: state.Stdin, |
| 398 | Stdout: state.Stdout, |
| 399 | Stderr: state.Stderr, |
| 400 | Terminal: state.Terminal, |
| 401 | ExitStatus: state.ExitStatus, |
| 402 | ExitedAt: protobuf.ToTimestamp(state.ExitedAt), |
| 403 | }, nil |
| 404 | } |
| 405 | |
| 406 | func (l *local) Get(ctx context.Context, r *api.GetRequest, _ ...grpc.CallOption) (*api.GetResponse, error) { |
| 407 | task, err := l.getTask(ctx, r.ContainerID) |
no test coverage detected
searching dependent graphs…