Skip to content

Commit e8a1da0

Browse files
author
Michal Tichák
committed
[executor] properly closing pipes in basic common task when in error
1 parent 6f582db commit e8a1da0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

executor/executable/basictaskcommon.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ func (t *basicTaskBase) startBasicTask() (err error) {
155155
}).
156156
Error("failed to run basic task")
157157

158+
closePipeWriters(stdoutLog, stderrLog)
159+
158160
return err
159161
}
160162
log.WithField("partition", t.knownEnvironmentId.String()).
@@ -174,12 +176,7 @@ func (t *basicTaskBase) startBasicTask() (err error) {
174176
err = taskCmd.Wait()
175177
// ^ when this unblocks, the task is done
176178

177-
if stdoutLog != nil {
178-
stdoutLog.Close()
179-
}
180-
if stderrLog != nil {
181-
stderrLog.Close()
182-
}
179+
closePipeWriters(stdoutLog, stderrLog)
183180

184181
pendingState := mesos.TASK_FINISHED
185182
var tciCommandStr string
@@ -252,6 +249,15 @@ func (t *basicTaskBase) startBasicTask() (err error) {
252249
return err
253250
}
254251

252+
func closePipeWriters(stdoutLog *io.PipeWriter, stderrLog *io.PipeWriter) {
253+
if stdoutLog != nil {
254+
stdoutLog.Close()
255+
}
256+
if stderrLog != nil {
257+
stderrLog.Close()
258+
}
259+
}
260+
255261
func (t *basicTaskBase) ensureBasicTaskKilled() (err error) {
256262
if t.taskCmd == nil {
257263
return nil

0 commit comments

Comments
 (0)