提交 bbd13ebf 编写于 作者: X xiadanni

isula-build: fix goroutine leaks because status channel not closed

When parse dockerfile failed, status channel has not been closed,
which causes goroutine leaks.
So cleanup defer function which includes channel close should be put
in the beginning of Build to avoid parse dockerfile or newstagebuilder
returns error.
Signed-off-by: Nxiadanni <xiadanni1@huawei.com>
上级 df2c1730
......@@ -408,6 +408,11 @@ func (b *Builder) Build() (string, error) {
imageID string
)
// 6. defer cleanup
defer func() {
b.cleanup()
}()
// 1. parseFiles
if err = b.parseFiles(); err != nil {
return "", err
......@@ -418,11 +423,6 @@ func (b *Builder) Build() (string, error) {
return "", err
}
// 6. defer cleanup
defer func() {
b.cleanup()
}()
// 3. loop StageBuilders for building
for _, stage := range b.stageBuilders {
stageTimer := b.cliLog.StartTimer(fmt.Sprintf("Stage %d", stage.position))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册