Example #1
0
func (r *OCIRuntime) SignalProcess(ctx context.Context, c *execution.Container, id string, sig os.Signal) error {
	process := c.GetProcess(id)
	if process == nil {
		return fmt.Errorf("Make a Process Not Found error")
	}
	return syscall.Kill(int(process.Pid()), sig.(syscall.Signal))
}
Example #2
0
func (r *OCIRuntime) Status(ctx context.Context, c *execution.Container) (execution.Status, error) {
	state, err := r.runc.State(ctx, c.ID())
	if err != nil {
		return "", err
	}
	return execution.Status(state.Status), nil
}
Example #3
0
func (r *OCIRuntime) Delete(ctx context.Context, c *execution.Container) error {
	id := c.ID()
	if err := r.runc.Delete(ctx, id); err != nil {
		return err
	}
	c.StateDir().Delete()
	r.ios[id].cleanup()
	delete(r.ios, id)
	return nil
}
Example #4
0
func (r *OCIRuntime) StartProcess(ctx context.Context, c *execution.Container, o execution.StartProcessOpts) (p execution.Process, err error) {
	oio, err := newOIO(o.Stdin, o.Stdout, o.Stderr, o.Console)
	if err != nil {
		return nil, err
	}
	defer func() {
		if err != nil {
			oio.cleanup()
		}
	}()

	procStateDir, err := c.StateDir().NewProcess(o.ID)
	if err != nil {
		return nil, err
	}
	defer func() {
		if err != nil {
			c.StateDir().DeleteProcess(o.ID)
		}
	}()

	pidFile := filepath.Join(procStateDir, PidFilename)
	if err := r.runc.Exec(ctx, c.ID(), o.Spec, &runc.ExecOpts{
		PidFile: pidFile,
		Detach:  false,
		Console: oio.console,
		Cwd:     o.Spec.Cwd,
		IO:      oio.rio,
	}); err != nil {
		return nil, err
	}

	process, err := newProcess(o.ID, procStateDir, execution.Running)
	if err != nil {
		return nil, err
	}

	c.AddProcess(process, false)

	r.ios[fmt.Sprintf("%s-%s", c.ID(), process.ID())] = oio

	return process, nil
}
Example #5
0
func (r *OCIRuntime) DeleteProcess(ctx context.Context, c *execution.Container, id string) error {
	ioID := fmt.Sprintf("%s-%s", c.ID(), id)
	r.ios[ioID].cleanup()
	delete(r.ios, ioID)
	return c.StateDir().DeleteProcess(id)
}
Example #6
0
func (r *OCIRuntime) Resume(ctx context.Context, c *execution.Container) error {
	return r.runc.Resume(ctx, c.ID())
}