Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
inclavare-containers
提交
003ec8c8
I
inclavare-containers
项目概览
openanolis
/
inclavare-containers
通知
4
Star
7
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
5
列表
看板
标记
里程碑
合并请求
0
分析
仓库
DevOps
项目成员
Pages
I
inclavare-containers
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
5
Issue
5
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
003ec8c8
编写于
6月 10, 2020
作者:
J
jack.wxz
提交者:
jia zhang
6月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rune: runelet does not use logpipe if rune create in detach mode
Signed-off-by:
N
jack.wxz
<
wangxiaozhe@linux.alibaba.com
>
上级
d2e29fc8
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
33 addition
and
7 deletion
+33
-7
rune/libcontainer/container_linux.go
rune/libcontainer/container_linux.go
+5
-2
rune/libcontainer/factory_linux.go
rune/libcontainer/factory_linux.go
+2
-1
rune/libcontainer/init_linux.go
rune/libcontainer/init_linux.go
+3
-1
rune/libcontainer/process.go
rune/libcontainer/process.go
+2
-0
rune/libcontainer/setns_init_linux.go
rune/libcontainer/setns_init_linux.go
+2
-1
rune/libcontainer/standard_init_linux.go
rune/libcontainer/standard_init_linux.go
+2
-1
rune/libenclave/bootstrap.go
rune/libenclave/bootstrap.go
+3
-1
rune/libenclave/runelet.go
rune/libenclave/runelet.go
+9
-0
rune/utils_linux.go
rune/utils_linux.go
+5
-0
未找到文件。
rune/libcontainer/container_linux.go
浏览文件 @
003ec8c8
...
...
@@ -478,7 +478,7 @@ func (c *linuxContainer) newParentProcess(p *Process) (parentProcess, error) {
}
logFilePair
:=
filePair
{
parentLogPipe
,
childLogPipe
}
cmd
:=
c
.
commandTemplate
(
p
,
childInitPipe
,
childLogPipe
,
p
.
AgentPipe
)
cmd
:=
c
.
commandTemplate
(
p
,
childInitPipe
,
childLogPipe
,
p
.
AgentPipe
,
p
.
Detached
)
if
!
p
.
Init
{
return
c
.
newSetnsProcess
(
p
,
cmd
,
messageSockPair
,
logFilePair
)
}
...
...
@@ -494,7 +494,7 @@ func (c *linuxContainer) newParentProcess(p *Process) (parentProcess, error) {
return
c
.
newInitProcess
(
p
,
cmd
,
messageSockPair
,
logFilePair
)
}
func
(
c
*
linuxContainer
)
commandTemplate
(
p
*
Process
,
childInitPipe
*
os
.
File
,
childLogPipe
*
os
.
File
,
agentPipe
*
os
.
File
)
*
exec
.
Cmd
{
func
(
c
*
linuxContainer
)
commandTemplate
(
p
*
Process
,
childInitPipe
*
os
.
File
,
childLogPipe
*
os
.
File
,
agentPipe
*
os
.
File
,
detached
int
)
*
exec
.
Cmd
{
cmd
:=
exec
.
Command
(
c
.
initPath
,
c
.
initArgs
[
1
:
]
...
)
cmd
.
Args
[
0
]
=
c
.
initArgs
[
0
]
cmd
.
Stdin
=
p
.
Stdin
...
...
@@ -537,6 +537,9 @@ func (c *linuxContainer) commandTemplate(p *Process, childInitPipe *os.File, chi
if
c
.
config
.
Enclave
.
Signer
!=
"server"
{
cmd
.
Env
=
append
(
cmd
.
Env
,
"_LIBCONTAINER_PAL_ROOTFS="
+
string
(
c
.
config
.
Rootfs
))
}
cmd
.
Env
=
append
(
cmd
.
Env
,
fmt
.
Sprintf
(
"_LIBCONTAINER_DETACHED=%d"
,
detached
))
}
// NOTE: when running a container with no PID namespace and the parent process spawning the container is
...
...
rune/libcontainer/factory_linux.go
浏览文件 @
003ec8c8
...
...
@@ -346,6 +346,7 @@ func (l *LinuxFactory) StartInitialization() (err error) {
envLogPipe
=
os
.
Getenv
(
"_LIBCONTAINER_LOGPIPE"
)
envLogLevel
=
os
.
Getenv
(
"_LIBCONTAINER_LOGLEVEL"
)
envAgentPipe
=
os
.
Getenv
(
"_LIBCONTAINER_AGENTPIPE"
)
envDetached
=
os
.
Getenv
(
"_LIBCONTAINER_DETACHED"
)
)
// Get the INITPIPE.
...
...
@@ -417,7 +418,7 @@ func (l *LinuxFactory) StartInitialization() (err error) {
}
}()
i
,
err
:=
newContainerInit
(
it
,
pipe
,
consoleSocket
,
fifofd
,
logPipe
,
envLogLevel
,
agentPipe
)
i
,
err
:=
newContainerInit
(
it
,
pipe
,
consoleSocket
,
fifofd
,
logPipe
,
envLogLevel
,
agentPipe
,
envDetached
)
if
err
!=
nil
{
return
err
}
...
...
rune/libcontainer/init_linux.go
浏览文件 @
003ec8c8
...
...
@@ -73,7 +73,7 @@ type initer interface {
Init
()
error
}
func
newContainerInit
(
t
initType
,
pipe
*
os
.
File
,
consoleSocket
*
os
.
File
,
fifoFd
int
,
logPipe
*
os
.
File
,
logLevel
string
,
agentPipe
*
os
.
File
)
(
initer
,
error
)
{
func
newContainerInit
(
t
initType
,
pipe
*
os
.
File
,
consoleSocket
*
os
.
File
,
fifoFd
int
,
logPipe
*
os
.
File
,
logLevel
string
,
agentPipe
*
os
.
File
,
detached
string
)
(
initer
,
error
)
{
var
config
*
initConfig
if
err
:=
json
.
NewDecoder
(
pipe
)
.
Decode
(
&
config
);
err
!=
nil
{
return
nil
,
err
...
...
@@ -90,6 +90,7 @@ func newContainerInit(t initType, pipe *os.File, consoleSocket *os.File, fifoFd
logPipe
:
logPipe
,
logLevel
:
logLevel
,
agentPipe
:
agentPipe
,
detached
:
detached
,
},
nil
case
initStandard
:
return
&
linuxStandardInit
{
...
...
@@ -101,6 +102,7 @@ func newContainerInit(t initType, pipe *os.File, consoleSocket *os.File, fifoFd
logPipe
:
logPipe
,
logLevel
:
logLevel
,
agentPipe
:
agentPipe
,
detached
:
detached
,
},
nil
}
return
nil
,
fmt
.
Errorf
(
"unknown init type %q"
,
t
)
...
...
rune/libcontainer/process.go
浏览文件 @
003ec8c8
...
...
@@ -81,6 +81,8 @@ type Process struct {
// Provide agent service hosted by main runelet for child runelet.
AgentPipe
*
os
.
File
Detached
int
}
// Wait waits for the process to exit.
...
...
rune/libcontainer/setns_init_linux.go
浏览文件 @
003ec8c8
...
...
@@ -28,6 +28,7 @@ type linuxSetnsInit struct {
logPipe
*
os
.
File
logLevel
string
agentPipe
*
os
.
File
detached
string
}
func
(
l
*
linuxSetnsInit
)
getSessionRingName
()
string
{
...
...
@@ -94,7 +95,7 @@ func (l *linuxSetnsInit) Init() error {
}
}
if
l
.
config
.
Config
.
Enclave
!=
nil
{
err
:=
libenclave
.
StartBootstrap
(
l
.
pipe
,
l
.
logPipe
,
l
.
logLevel
,
-
1
,
l
.
agentPipe
)
err
:=
libenclave
.
StartBootstrap
(
l
.
pipe
,
l
.
logPipe
,
l
.
logLevel
,
-
1
,
l
.
agentPipe
,
l
.
detached
)
if
err
!=
nil
{
return
newSystemErrorWithCause
(
err
,
"libenclave bootstrap"
)
}
...
...
rune/libcontainer/standard_init_linux.go
浏览文件 @
003ec8c8
...
...
@@ -31,6 +31,7 @@ type linuxStandardInit struct {
logPipe
*
os
.
File
logLevel
string
agentPipe
*
os
.
File
detached
string
}
func
(
l
*
linuxStandardInit
)
getSessionRingParams
()
(
string
,
uint32
,
uint32
)
{
...
...
@@ -179,7 +180,7 @@ func (l *linuxStandardInit) Init() error {
return
unix
.
Kill
(
unix
.
Getpid
(),
unix
.
SIGKILL
)
}
if
l
.
config
.
Config
.
Enclave
!=
nil
{
err
:=
libenclave
.
StartBootstrap
(
l
.
pipe
,
l
.
logPipe
,
l
.
logLevel
,
l
.
fifoFd
,
l
.
agentPipe
)
err
:=
libenclave
.
StartBootstrap
(
l
.
pipe
,
l
.
logPipe
,
l
.
logLevel
,
l
.
fifoFd
,
l
.
agentPipe
,
l
.
detached
)
if
err
!=
nil
{
return
err
}
...
...
rune/libenclave/bootstrap.go
浏览文件 @
003ec8c8
...
...
@@ -10,7 +10,7 @@ import (
// environment variable must be staged and then recovered after re-exec. This
// process is so called as libenclave bootstrapping, and the resulting process
// is so called as runelet.
func
StartBootstrap
(
initPipe
*
os
.
File
,
logPipe
*
os
.
File
,
logLevel
string
,
fifoFd
int
,
agentPipe
*
os
.
File
)
(
err
error
)
{
func
StartBootstrap
(
initPipe
*
os
.
File
,
logPipe
*
os
.
File
,
logLevel
string
,
fifoFd
int
,
agentPipe
*
os
.
File
,
detached
string
)
(
err
error
)
{
logrus
.
Debug
(
"bootstrapping libenclave ..."
)
if
err
=
stageFd
(
"_LIBENCLAVE_INITPIPE"
,
initPipe
);
err
!=
nil
{
...
...
@@ -60,5 +60,7 @@ func StartBootstrap(initPipe *os.File, logPipe *os.File, logLevel string, fifoFd
}
}()
os
.
Setenv
(
"_LIBENCLAVE_DETACHED"
,
detached
)
return
nil
}
rune/libenclave/runelet.go
浏览文件 @
003ec8c8
...
...
@@ -10,6 +10,7 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
"io"
"io/ioutil"
"os"
"os/signal"
"strconv"
...
...
@@ -96,6 +97,14 @@ func StartInitialization() (exitCode int32, err error) {
}
}
// If runelet run as detach mode, close logrus before initpipe closed.
envDetach
:=
os
.
Getenv
(
"_LIBENCLAVE_DETACHED"
)
detach
,
err
:=
strconv
.
Atoi
(
envDetach
)
if
detach
!=
0
{
logrus
.
SetOutput
(
ioutil
.
Discard
)
}
os
.
Unsetenv
(
"_LIBENCLAVE_DETACHED"
)
// Close the init pipe to signal that we have completed our init.
// So `rune create` or the upper half part of `rune run` can return.
initPipe
.
Close
()
...
...
rune/utils_linux.go
浏览文件 @
003ec8c8
...
...
@@ -305,6 +305,11 @@ func (r *runner) run(config *specs.Process) (int, error) {
var
(
detach
=
r
.
detach
||
(
r
.
action
==
CT_ACT_CREATE
)
)
if
detach
{
process
.
Detached
=
1
}
// Setting up IO is a two stage process. We need to modify process to deal
// with detaching containers, and then we get a tty after the container has
// started.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录