Skip to content

Correct logic of FIFO cleanup#4123

Merged
fuweid merged 2 commits intocontainerd:masterfrom
estesp:no-del-rootdir-ios
Mar 30, 2020
Merged

Correct logic of FIFO cleanup#4123
fuweid merged 2 commits intocontainerd:masterfrom
estesp:no-del-rootdir-ios

Conversation

@estesp
Copy link
Copy Markdown
Member

@estesp estesp commented Mar 24, 2020

Fixes: #4019

Only delete files which are FIFOs and only delete directories which are empty after deleting FIFOs.

Also contains a commit to move isFifo() from a private function in pkg/process/io.go to a public function in sys/

Signed-off-by: Phil Estes [email protected]

@estesp
Copy link
Copy Markdown
Member Author

estesp commented Mar 24, 2020

Some additional info from my thinking/digging on this: we have information "loss" of sorts between container create (where we know whether FIFOs are set by the caller versus defaulted or our own "constructors" are used) and delete/close; I don't see any way to connect these information "dots" unless we change the API to return additional details which would then allow for more nuanced approach to the close handler for FIFOs. If anyone else has better ideas, would love any insight.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 24, 2020

Build succeeded.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 24, 2020

Codecov Report

Merging #4123 into master will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4123      +/-   ##
==========================================
- Coverage   42.43%   42.40%   -0.03%     
==========================================
  Files         129      130       +1     
  Lines       14875    14884       +9     
==========================================
  Hits         6312     6312              
- Misses       7644     7653       +9     
  Partials      919      919              
Flag Coverage Δ
#linux 45.73% <0.00%> (-0.04%) ⬇️
#windows 38.17% <ø> (ø)
Impacted Files Coverage Δ
sys/filesys.go 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0d4208...78ab1d1. Read the comment docs.

@crosbymichael
Copy link
Copy Markdown
Member

i'll look at this today

@estesp
Copy link
Copy Markdown
Member Author

estesp commented Mar 24, 2020

Thanks @crosbymichael! To be clear about my comment above, at create time we have a "richer" understanding of FIFOs; by the time we get to the loadFifos stage we only have 3 filepath strings from the task response. So, it seems to me any "closers" set up at the front end are all lost at this point if you started a detached task.

@crosbymichael
Copy link
Copy Markdown
Member

so this getFifoDir is only used to delete the fifos whenever you load a task and attach the IO.

I would almost say we defer this closer to be an opt that the client has to pass because they would know that type of IO they are connecting to. we could also just delete the individual files but we need a check to ensure that it is a fifo and not another type of file.

Maybe this is the best solution for now:

for f in files {
if f.type == fifo {
remove(f)
remove(dir(f)) // if there are still files in there remove will fail and it should be safe.
// if we get to the end and its empty then the dir gets removed
}

}

Make "IsFifo" a public function for use by other parts of containerd
codebase.

Signed-off-by: Phil Estes <[email protected]>
@estesp estesp force-pushed the no-del-rootdir-ios branch from 699197b to 4d64cce Compare March 25, 2020 14:52
@estesp estesp changed the title Don't inadvertently delete root directories on the filesystem Correct logic of FIFO cleanup Mar 25, 2020
@estesp
Copy link
Copy Markdown
Member Author

estesp commented Mar 25, 2020

PTAL @crosbymichael

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 25, 2020

Build succeeded.

Comment thread container.go Outdated
@estesp estesp force-pushed the no-del-rootdir-ios branch from 4d64cce to ef3b01e Compare March 25, 2020 17:34
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 25, 2020

Build succeeded.

Only delete files which are FIFOs and only delete directories
which are empty after deleting FIFOs.

Signed-off-by: Phil Estes <[email protected]>
@estesp estesp force-pushed the no-del-rootdir-ios branch from ef3b01e to 78ab1d1 Compare March 25, 2020 18:00
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 25, 2020

Build succeeded.

@estesp
Copy link
Copy Markdown
Member Author

estesp commented Mar 25, 2020

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@deitch
Copy link
Copy Markdown
Contributor

deitch commented Mar 29, 2020

Most pleased to see this. Thanks @estesp !

Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fuweid fuweid merged commit 89f9b30 into containerd:master Mar 30, 2020
@deitch
Copy link
Copy Markdown
Contributor

deitch commented Mar 31, 2020

I assume this will be in the next release, either 1.3.4 or 1.4.0? Is there an ETA on it?

@estesp
Copy link
Copy Markdown
Member Author

estesp commented Apr 3, 2020

@deitch no ETA, but several issues have been gathering in the 1.3 branch so I expect we will want to make a plan for 1.3.4 soon. 1.4 early alpha/betas should be coming soonish.

@deitch
Copy link
Copy Markdown
Contributor

deitch commented Apr 4, 2020

Thanks Phil!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

starting a task with /dev/null for stdin, stdout or stderr causes entire /dev to be deleted

5 participants