Skip to content

Commit 051a16c

Browse files
Use fifo close to prevent leak of top level directory (#752)
Previously the vm agent did clean of fifos by removing each fifo; however, this resulted in a leak of the top level directory of the fifos until the task was deleted. For long running tasks, this resulted in 4096 byte leak on the microvm filesystem until the task was deleted. Signed-off-by: Austin Vazquez <[email protected]>
1 parent fca3b8f commit 051a16c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

agent/service.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ func (ts *TaskService) Create(requestCtx context.Context, req *taskAPI.CreateTas
253253
logger.WithError(err).Error()
254254
return nil, err
255255
}
256+
ts.addCleanup(taskExecID, func() error {
257+
return fifoSet.Close()
258+
})
256259

257260
var stdinConnectorPair *vm.IOConnectorPair
258261
if req.Stdin != "" {
@@ -520,6 +523,9 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
520523
logger.WithError(err).Error()
521524
return nil, err
522525
}
526+
ts.addCleanup(taskExecID, func() error {
527+
return fifoSet.Close()
528+
})
523529

524530
var stdinConnectorPair *vm.IOConnectorPair
525531
if req.Stdin != "" {
@@ -528,9 +534,6 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
528534
ReadConnector: vm.VSockAcceptConnector(extraData.StdinPort),
529535
WriteConnector: vm.WriteFIFOConnector(fifoSet.Stdin),
530536
}
531-
ts.addCleanup(taskExecID, func() error {
532-
return os.RemoveAll(req.Stdin)
533-
})
534537
}
535538

536539
var stdoutConnectorPair *vm.IOConnectorPair
@@ -540,9 +543,6 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
540543
ReadConnector: vm.ReadFIFOConnector(fifoSet.Stdout),
541544
WriteConnector: vm.VSockAcceptConnector(extraData.StdoutPort),
542545
}
543-
ts.addCleanup(taskExecID, func() error {
544-
return os.RemoveAll(req.Stdout)
545-
})
546546
}
547547

548548
var stderrConnectorPair *vm.IOConnectorPair
@@ -552,9 +552,6 @@ func (ts *TaskService) Exec(requestCtx context.Context, req *taskAPI.ExecProcess
552552
ReadConnector: vm.ReadFIFOConnector(fifoSet.Stderr),
553553
WriteConnector: vm.VSockAcceptConnector(extraData.StderrPort),
554554
}
555-
ts.addCleanup(taskExecID, func() error {
556-
return os.RemoveAll(req.Stderr)
557-
})
558555
}
559556

560557
ioConnectorSet = vm.NewIOConnectorProxy(stdinConnectorPair, stdoutConnectorPair, stderrConnectorPair)

0 commit comments

Comments
 (0)