Add runtimeArgs to pass to shim
This allows you to pass options like: ```bash containerd --debug --runtime-args "--debug" --runtime-args "--systemd-cgroup" ``` Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
5f0f162c62
commit
6e4d5b385c
7 changed files with 65 additions and 49 deletions
|
@ -91,10 +91,10 @@ func (p *process) start() error {
|
|||
return err
|
||||
}
|
||||
logPath := filepath.Join(cwd, "log.json")
|
||||
args := []string{
|
||||
args := append([]string{
|
||||
"--log", logPath,
|
||||
"--log-format", "json",
|
||||
}
|
||||
}, p.state.RuntimeArgs...)
|
||||
if p.state.Exec {
|
||||
args = append(args, "exec",
|
||||
"--process", filepath.Join(cwd, "process.json"),
|
||||
|
|
|
@ -50,6 +50,11 @@ var daemonFlags = []cli.Flag{
|
|||
Value: "runc",
|
||||
Usage: "name of the OCI compliant runtime to use when executing containers",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "runtime-args",
|
||||
Value: &cli.StringSlice{},
|
||||
Usage: "specify additional runtime args",
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -71,6 +76,7 @@ func main() {
|
|||
context.String("state-dir"),
|
||||
10,
|
||||
context.String("runtime"),
|
||||
context.StringSlice("runtime-args"),
|
||||
); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
@ -80,7 +86,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func daemon(address, stateDir string, concurrency int, runtimeName string) error {
|
||||
func daemon(address, stateDir string, concurrency int, runtimeName string, runtimeArgs []string) error {
|
||||
// setup a standard reaper so that we don't leave any zombies if we are still alive
|
||||
// this is just good practice because we are spawning new processes
|
||||
s := make(chan os.Signal, 2048)
|
||||
|
@ -88,7 +94,7 @@ func daemon(address, stateDir string, concurrency int, runtimeName string) error
|
|||
if err := osutils.SetSubreaper(1); err != nil {
|
||||
logrus.WithField("error", err).Error("containerd: set subpreaper")
|
||||
}
|
||||
sv, err := supervisor.New(stateDir, runtimeName)
|
||||
sv, err := supervisor.New(stateDir, runtimeName, runtimeArgs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ func NewStdio(stdin, stdout, stderr string) Stdio {
|
|||
}
|
||||
|
||||
// New returns a new container
|
||||
func New(root, id, bundle, runtimeName string, labels []string) (Container, error) {
|
||||
func New(root, id, bundle, runtimeName string, runtimeArgs, labels []string) (Container, error) {
|
||||
c := &container{
|
||||
root: root,
|
||||
id: id,
|
||||
|
@ -91,6 +91,7 @@ func New(root, id, bundle, runtimeName string, labels []string) (Container, erro
|
|||
labels: labels,
|
||||
processes: make(map[string]*process),
|
||||
runtime: runtimeName,
|
||||
runtimeArgs: runtimeArgs,
|
||||
}
|
||||
if err := os.Mkdir(filepath.Join(root, id), 0755); err != nil {
|
||||
return nil, err
|
||||
|
@ -104,6 +105,7 @@ func New(root, id, bundle, runtimeName string, labels []string) (Container, erro
|
|||
Bundle: bundle,
|
||||
Labels: labels,
|
||||
Runtime: runtimeName,
|
||||
RuntimeArgs: runtimeArgs,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -126,6 +128,7 @@ func Load(root, id string) (Container, error) {
|
|||
bundle: s.Bundle,
|
||||
labels: s.Labels,
|
||||
runtime: s.Runtime,
|
||||
runtimeArgs: s.RuntimeArgs,
|
||||
processes: make(map[string]*process),
|
||||
}
|
||||
dirs, err := ioutil.ReadDir(filepath.Join(root, id))
|
||||
|
@ -170,6 +173,7 @@ type container struct {
|
|||
id string
|
||||
bundle string
|
||||
runtime string
|
||||
runtimeArgs []string
|
||||
processes map[string]*process
|
||||
labels []string
|
||||
oomFds []int
|
||||
|
|
|
@ -38,5 +38,6 @@ func populateProcessStateForEncoding(config *processConfig, uid int, gid int) Pr
|
|||
Stdin: config.stdio.Stdin,
|
||||
Stdout: config.stdio.Stdout,
|
||||
Stderr: config.stdio.Stderr,
|
||||
RuntimeArgs: config.c.runtimeArgs,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ type state struct {
|
|||
Stdout string `json:"stdout"`
|
||||
Stderr string `json:"stderr"`
|
||||
Runtime string `json:"runtime"`
|
||||
RuntimeArgs []string `json:"runtimeArgs"`
|
||||
}
|
||||
|
||||
type ProcessState struct {
|
||||
|
@ -67,6 +68,7 @@ type ProcessState struct {
|
|||
Stdin string `json:"containerdStdin"`
|
||||
Stdout string `json:"containerdStdout"`
|
||||
Stderr string `json:"containerdStderr"`
|
||||
RuntimeArgs []string `json:"runtimeArgs"`
|
||||
|
||||
PlatformProcessState
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ type StartTask struct {
|
|||
|
||||
func (s *Supervisor) start(t *StartTask) error {
|
||||
start := time.Now()
|
||||
container, err := runtime.New(s.stateDir, t.ID, t.BundlePath, s.runtime, t.Labels)
|
||||
container, err := runtime.New(s.stateDir, t.ID, t.BundlePath, s.runtime, s.runtimeArgs, t.Labels)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ const (
|
|||
)
|
||||
|
||||
// New returns an initialized Process supervisor.
|
||||
func New(stateDir string, runtimeName string) (*Supervisor, error) {
|
||||
func New(stateDir string, runtimeName string, runtimeArgs []string) (*Supervisor, error) {
|
||||
startTasks := make(chan *startTask, 10)
|
||||
if err := os.MkdirAll(stateDir, 0755); err != nil {
|
||||
return nil, err
|
||||
|
@ -40,6 +40,7 @@ func New(stateDir string, runtimeName string) (*Supervisor, error) {
|
|||
tasks: make(chan Task, defaultBufferSize),
|
||||
monitor: monitor,
|
||||
runtime: runtimeName,
|
||||
runtimeArgs: runtimeArgs,
|
||||
}
|
||||
if err := setupEventLog(s); err != nil {
|
||||
return nil, err
|
||||
|
@ -106,6 +107,7 @@ type Supervisor struct {
|
|||
stateDir string
|
||||
// name of the OCI compatible runtime used to execute containers
|
||||
runtime string
|
||||
runtimeArgs []string
|
||||
containers map[string]*containerInfo
|
||||
startTasks chan *startTask
|
||||
// we need a lock around the subscribers map only because additions and deletions from
|
||||
|
@ -198,6 +200,7 @@ func (s *Supervisor) Start() error {
|
|||
logrus.WithFields(logrus.Fields{
|
||||
"stateDir": s.stateDir,
|
||||
"runtime": s.runtime,
|
||||
"runtimeArgs": s.runtimeArgs,
|
||||
"memory": s.machine.Memory,
|
||||
"cpus": s.machine.Cpus,
|
||||
}).Debug("containerd: supervisor running")
|
||||
|
|
Loading…
Reference in a new issue