MCPcopy
hub / github.com/firecracker-microvm/firecracker-containerd / CreateTask

Method CreateTask

internal/vm/task.go:175–219  ·  view source on GitHub ↗
(
	reqCtx context.Context,
	req *taskAPI.CreateTaskRequest,
	taskService taskAPI.TaskService,
	ioProxy IOProxy,
)

Source from the content-addressed store, hash-verified

173}
174
175func (m *taskManager) CreateTask(
176 reqCtx context.Context,
177 req *taskAPI.CreateTaskRequest,
178 taskService taskAPI.TaskService,
179 ioProxy IOProxy,
180) (_ *taskAPI.CreateTaskResponse, err error) {
181 taskID := req.ID
182 execID := "" // ExecID of initial process in task is empty string by containerd convention
183
184 proc, err := m.newProc(taskID, execID)
185 if err != nil {
186 return nil, err
187 }
188 proc.proxy = ioProxy
189
190 defer func() {
191 if err != nil {
192 proc.cancel()
193 m.deleteProc(taskID, execID)
194 }
195 }()
196
197 // Begin initializing stdio, but don't block on the initialization so we can send the Create
198 // call (which will allow the stdio initialization to complete).
199 initDone, copyDone := ioProxy.start(proc)
200 proc.ioCopyDone = copyDone
201
202 createResp, err := taskService.Create(reqCtx, req)
203 if err != nil {
204 return nil, err
205 }
206
207 // make sure stdio was initialized successfully
208 err = <-initDone
209 if err != nil {
210 return nil, err
211 }
212
213 proc.logger.WithField("pid_in_vm", createResp.Pid).Info("successfully created task")
214
215 go m.monitorExit(proc, taskService)
216 go monitorIO(copyDone, proc)
217
218 return createResp, nil
219}
220
221func (m *taskManager) ExecProcess(
222 reqCtx context.Context,

Callers

nothing calls this directly

Calls 6

newProcMethod · 0.95
deleteProcMethod · 0.95
monitorExitMethod · 0.95
monitorIOFunction · 0.85
startMethod · 0.65
CreateMethod · 0.45

Tested by

no test coverage detected