// Create a new sandbox or container with the underlying OCI runtime
Create a new sandbox or container with the underlying OCI runtime
// Create a new sandbox or container with the underlying OCI runtime
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
	start := time.Now()
	defer func() {
		err = toGRPC(err)
		rpcDurationsHistogram.WithLabelValues("create").Observe(float64(time.Since(start).Nanoseconds() / int64(time.Millisecond)))
	}()
	s.mu.Lock()
	defer s.mu.Unlock()
	var c *container
	c, err = create(ctx, s, r)
	if err != nil {
		return nil, err
	}
	c.status = task.StatusCreated
	s.containers[r.ID] = c
	s.send(&eventstypes.TaskCreate{
		ContainerID: r.ID,
		Bundle:      r.Bundle,
		Rootfs:      r.Rootfs,
		IO: &eventstypes.TaskIO{
			Stdin:    r.Stdin,
			Stdout:   r.Stdout,
			Stderr:   r.Stderr,
			Terminal: r.Terminal,
		},
		Checkpoint: r.Checkpoint,
		Pid:        s.pid,
	})
	return &taskAPI.CreateTaskResponse{
		Pid: s.pid,
	}, nil
}
func ( s * service ) Create ( ctx context . Context , r * taskAPI . CreateTaskRequest ) ( _ * taskAPI . CreateTaskResponse , err error ) { start := time . Now ( ) defer func ( ) { err = toGRPC ( err ) rpcDurationsHistogram . WithLabelValues ( " " ) . Observe ( float64 ( time . Since ( start ) . Nanoseconds ( ) / int64 ( time . Millisecond ) ) ) } ( ) s . mu . Lock ( ) defer s . mu . Unlock ( ) var c * container c , err = create ( ctx , s , r ) if err != nil { return nil , err } c . status = task . StatusCreated s . containers [ r . ID ] = c s . send ( & eventstypes . TaskCreate { ContainerID : r . ID , Bundle : r . Bundle , Rootfs : r . Rootfs , IO : & eventstypes . TaskIO { Stdin : r . Stdin , Stdout : r . Stdout , Stderr : r . Stderr , Terminal : r . Terminal , } , Checkpoint : r . Checkpoint , Pid : s . pid , } ) return & taskAPI . CreateTaskResponse { Pid : s . pid , } , nil }
Create a new sandbox or container with the underlying OCI runtime
Create a new sandbox or container with the underlying OCI runtime