2020-10-11 19:35:22 +00:00
|
|
|
// +build !linux
|
|
|
|
|
|
|
|
package runcexecutor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
runc "github.com/containerd/go-runc"
|
|
|
|
"github.com/moby/buildkit/executor"
|
|
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var unsupportedConsoleError = errors.New("tty for runc is only supported on linux")
|
|
|
|
|
2020-10-19 23:47:00 +00:00
|
|
|
func updateRuncFieldsForHostOS(runtime *runc.Runc) {}
|
|
|
|
|
|
|
|
func (w *runcExecutor) run(ctx context.Context, id, bundle string, process executor.ProcessInfo) error {
|
2020-10-11 19:35:22 +00:00
|
|
|
if process.Meta.Tty {
|
2020-10-19 23:47:00 +00:00
|
|
|
return unsupportedConsoleError
|
2020-10-11 19:35:22 +00:00
|
|
|
}
|
2020-10-19 23:47:00 +00:00
|
|
|
_, err := w.runc.Run(ctx, id, bundle, &runc.CreateOpts{
|
2020-10-11 19:35:22 +00:00
|
|
|
IO: &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr},
|
|
|
|
NoPivot: w.noPivot,
|
|
|
|
})
|
2020-10-19 23:47:00 +00:00
|
|
|
return err
|
2020-10-11 19:35:22 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 23:47:00 +00:00
|
|
|
func (w *runcExecutor) exec(ctx context.Context, id, bundle string, specsProcess *specs.Process, process executor.ProcessInfo) error {
|
2020-10-11 19:35:22 +00:00
|
|
|
if process.Meta.Tty {
|
2020-10-19 23:47:00 +00:00
|
|
|
return unsupportedConsoleError
|
2020-10-11 19:35:22 +00:00
|
|
|
}
|
2020-10-19 23:47:00 +00:00
|
|
|
return w.runc.Exec(ctx, id, *specsProcess, &runc.ExecOpts{
|
2020-10-11 19:35:22 +00:00
|
|
|
IO: &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr},
|
|
|
|
})
|
|
|
|
}
|