make conmon inherit env from ocid
Signed-off-by: HaoZhang <crazykev@zju.edu.cn>
This commit is contained in:
parent
af55785b53
commit
9c11cc7dba
4 changed files with 16 additions and 3 deletions
|
@ -49,6 +49,11 @@ runtime = "{{ .Runtime }}"
|
|||
# conmon is the path to conmon binary, used for managing the runtime.
|
||||
conmon = "{{ .Conmon }}"
|
||||
|
||||
# conmon_env is the environment variable list for conmon process,
|
||||
# used for passing necessary environment variable to conmon or runtime.
|
||||
conmon_env = [
|
||||
{{ range $env := .ConmonEnv }}{{ printf "\t%q,\n" $env }}{{ end }}]
|
||||
|
||||
# selinux indicates whether or not SELinux will be used for pod
|
||||
# separation on the host. If you enable this flag, SELinux must be running
|
||||
# on the host.
|
||||
|
@ -77,6 +82,9 @@ func DefaultConfig() *server.Config {
|
|||
RuntimeConfig: server.RuntimeConfig{
|
||||
Runtime: "/usr/bin/runc",
|
||||
Conmon: conmonPath,
|
||||
ConmonEnv: []string{
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
},
|
||||
SELinux: selinux.SelinuxEnabled(),
|
||||
},
|
||||
ImageConfig: server.ImageConfig{
|
||||
|
|
|
@ -31,12 +31,13 @@ const (
|
|||
)
|
||||
|
||||
// New creates a new Runtime with options provided
|
||||
func New(runtimePath string, containerDir string, conmonPath string) (*Runtime, error) {
|
||||
func New(runtimePath string, containerDir string, conmonPath string, conmonEnv []string) (*Runtime, error) {
|
||||
r := &Runtime{
|
||||
name: filepath.Base(runtimePath),
|
||||
path: runtimePath,
|
||||
containerDir: containerDir,
|
||||
conmonPath: conmonPath,
|
||||
conmonEnv: conmonEnv,
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
@ -47,6 +48,7 @@ type Runtime struct {
|
|||
path string
|
||||
containerDir string
|
||||
conmonPath string
|
||||
conmonEnv []string
|
||||
}
|
||||
|
||||
// syncInfo is used to return data from monitor process to daemon
|
||||
|
@ -113,7 +115,7 @@ func (r *Runtime) CreateContainer(c *Container) error {
|
|||
cmd.Stderr = os.Stderr
|
||||
cmd.ExtraFiles = append(cmd.ExtraFiles, childPipe)
|
||||
// 0, 1 and 2 are stdin, stdout and stderr
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("_OCI_SYNCPIPE=%d", 3))
|
||||
cmd.Env = append(r.conmonEnv, fmt.Sprintf("_OCI_SYNCPIPE=%d", 3))
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
|
|
|
@ -53,6 +53,9 @@ type RuntimeConfig struct {
|
|||
// Conmon is the path to conmon binary, used for managing the runtime.
|
||||
Conmon string `toml:"conmon"`
|
||||
|
||||
// ConmonEnv is the environment variable list for conmon process.
|
||||
ConmonEnv []string `toml:"conmon_env"`
|
||||
|
||||
// SELinux determines whether or not SELinux is used for pod separation.
|
||||
SELinux bool `toml:"selinux"`
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ func New(config *Config) (*Server, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
r, err := oci.New(config.Runtime, config.ContainerDir, config.Conmon)
|
||||
r, err := oci.New(config.Runtime, config.ContainerDir, config.Conmon, config.ConmonEnv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue