Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
isula-build
提交
eaa6a2a7
I
isula-build
项目概览
openeuler
/
isula-build
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
isula-build
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eaa6a2a7
编写于
9月 04, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
9月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
!73 isula-build: fix frontend hangs when build/save failed
Merge pull request !73 from zklei/fix-hang
上级
460b94fe
b96b1f0e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
11 deletion
+24
-11
daemon/build.go
daemon/build.go
+12
-9
daemon/save.go
daemon/save.go
+12
-2
未找到文件。
daemon/build.go
浏览文件 @
eaa6a2a7
...
...
@@ -17,7 +17,8 @@ import (
"bufio"
"context"
"io"
"io/ioutil"
"os"
"syscall"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
...
...
@@ -64,14 +65,16 @@ func (b *Backend) Build(req *pb.BuildRequest, stream pb.Control_BuildServer) err
var
berr
error
imageID
,
berr
=
builder
.
Build
()
// in case there is error during Build stage, the backend will always waiting for content write into
// the pipeFile, which will cause frontend hangs forever.
// so if the output type is archive(pipeFile is not empty string) and any error occurred, we write the error
// message into the pipe to make the goroutine move on instead of hangs.
if
berr
!=
nil
&&
pipeWrapper
!=
nil
{
pipeWrapper
.
Close
()
if
perr
:=
ioutil
.
WriteFile
(
pipeWrapper
.
PipeFile
,
[]
byte
(
berr
.
Error
()),
constant
.
DefaultRootFileMode
);
perr
!=
nil
{
logrus
.
WithField
(
util
.
LogKeySessionID
,
req
.
BuildID
)
.
Warnf
(
"Write error [%v] in to pipe file failed: %v"
,
berr
,
perr
)
// in case there is error during Build stage, the backend will always waiting for content write into
// the pipeFile, which will cause frontend hangs forever.
// so if the output type is archive(pipeWrapper is not nil) and any error occurred, we try to open and close
// the pipe in O_NONBLOCK flag to make the goroutine move on instead of hangs.
f
,
perr
:=
os
.
OpenFile
(
pipeWrapper
.
PipeFile
,
os
.
O_WRONLY
|
syscall
.
O_NONBLOCK
,
os
.
ModeNamedPipe
)
if
perr
==
nil
&&
f
!=
nil
{
if
cerr
:=
f
.
Close
();
cerr
!=
nil
{
logrus
.
WithField
(
util
.
LogKeySessionID
,
req
.
BuildID
)
.
Warnf
(
"Close pipe file failed: %v"
,
cerr
)
}
}
}
...
...
@@ -96,7 +99,7 @@ func (b *Backend) Build(req *pb.BuildRequest, stream pb.Control_BuildServer) err
buf
:=
make
([]
byte
,
constant
.
BufferSize
,
constant
.
BufferSize
)
for
{
length
,
rerr
:=
reader
.
Read
(
buf
)
if
rerr
==
io
.
EOF
||
pipeWrapper
.
Done
{
if
rerr
==
io
.
EOF
{
break
}
if
rerr
!=
nil
{
...
...
daemon/save.go
浏览文件 @
eaa6a2a7
...
...
@@ -21,6 +21,7 @@ import (
"os"
"path/filepath"
"strings"
"syscall"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
...
...
@@ -173,7 +174,16 @@ func exportHandler(ctx context.Context, opts *saveOptions, cliLogger *logger.Log
}
if
err
:=
exporter
.
Export
(
opts
.
imageID
,
opts
.
output
,
exOpts
,
opts
.
store
);
err
!=
nil
{
opts
.
pipeWrapper
.
Close
()
// in case there is error during export, the backend will always waiting for content write into
// the pipeFile, which will cause frontend hangs forever.
// so if any error occurred, we try to open and close the pipe in O_NONBLOCK flag to make the
// goroutine move on instead of hangs.
f
,
perr
:=
os
.
OpenFile
(
opts
.
pipeWrapper
.
PipeFile
,
os
.
O_WRONLY
|
syscall
.
O_NONBLOCK
,
os
.
ModeNamedPipe
)
if
perr
==
nil
&&
f
!=
nil
{
if
cerr
:=
f
.
Close
();
cerr
!=
nil
{
logrus
.
WithField
(
util
.
LogKeySessionID
,
opts
.
saveID
)
.
Warnf
(
"Close pipe file failed: %v"
,
cerr
)
}
}
logrus
.
Errorf
(
"Save image %s failed: %v"
,
opts
.
imageInfo
,
err
)
return
err
}
...
...
@@ -198,7 +208,7 @@ func dataHandler(req *pb.SaveRequest, stream pb.Control_SaveServer, opts *saveOp
buf
:=
make
([]
byte
,
constant
.
BufferSize
,
constant
.
BufferSize
)
for
{
length
,
err
:=
reader
.
Read
(
buf
)
if
err
==
io
.
EOF
||
opts
.
pipeWrapper
.
Done
{
if
err
==
io
.
EOF
{
break
}
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录