New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup docker tmp dir on start #31741

Merged
merged 1 commit into from Mar 30, 2017

Conversation

@mlaventure
Contributor

mlaventure commented Mar 10, 2017

Signed-off-by: Kenfe-Mickael Laventure mickael.laventure@gmail.com

--

This should free up some space by removing old build contexts.

@vdemeester

LGTM 🐸

Show outdated Hide outdated daemon/daemon.go Outdated
@AkihiroSuda

This comment has been minimized.

Show comment
Hide comment
@AkihiroSuda

AkihiroSuda Mar 13, 2017

Member

I'm not sure how large the tmpdir would be 😅 , but if it can be large, we could call rename(2) first and then remove it in background for better performance.

Member

AkihiroSuda commented Mar 13, 2017

I'm not sure how large the tmpdir would be 😅 , but if it can be large, we could call rename(2) first and then remove it in background for better performance.

@mlaventure

This comment has been minimized.

Show comment
Hide comment
@mlaventure

mlaventure Mar 13, 2017

Contributor

@AkihiroSuda mine was 2/3 GB, I'll update the PR with your suggestion :)

Contributor

mlaventure commented Mar 13, 2017

@AkihiroSuda mine was 2/3 GB, I'll update the PR with your suggestion :)

Cleanup docker tmp dir on start
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
@vdemeester

This comment has been minimized.

Show comment
Hide comment
@vdemeester
Member

vdemeester commented Mar 26, 2017

var tmpDir string
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
tmpDir = filepath.Join(rootDir, "tmp")
newName := tmpDir + "-old"

This comment has been minimized.

@AkihiroSuda

AkihiroSuda Mar 26, 2017

Member

If a daemon crashes before completely removing tmpDir + "-old", the next daemon execution fails to execute os.Rename(tmpDir, tmpDir+"-old"), and hence the old tmpDir + "-old" will be left alone.

So I think we need os.RemoveAll(tmpDir + "-old") here.

@AkihiroSuda

AkihiroSuda Mar 26, 2017

Member

If a daemon crashes before completely removing tmpDir + "-old", the next daemon execution fails to execute os.Rename(tmpDir, tmpDir+"-old"), and hence the old tmpDir + "-old" will be left alone.

So I think we need os.RemoveAll(tmpDir + "-old") here.

This comment has been minimized.

@mlaventure

mlaventure Mar 29, 2017

Contributor

and what if that one fails? ;-)

@mlaventure

mlaventure Mar 29, 2017

Contributor

and what if that one fails? ;-)

@thaJeztah

LGTM

@thaJeztah thaJeztah merged commit f16d1a4 into moby:master Mar 30, 2017

6 checks passed

dco-signed All commits are signed
experimental Jenkins build Docker-PRs-experimental 31804 has succeeded
Details
janky Jenkins build Docker-PRs 40714 has succeeded
Details
powerpc Jenkins build Docker-PRs-powerpc 515 has succeeded
Details
windowsRS1 Jenkins build Docker-PRs-WoW-RS1 11505 has succeeded
Details
z Jenkins build Docker-PRs-s390x 406 has succeeded
Details

@GordonTheTurtle GordonTheTurtle added this to the 17.05.0 milestone Mar 30, 2017

@mlaventure mlaventure deleted the mlaventure:cleanup-tmp-on-start branch Mar 30, 2017

liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017

Cleanup docker tmp dir on start
(backport from moby#31741)

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Signed-off-by: Wentao Zhang <zhangwentao234@huawei.com>
(cherry-pick from 9c451ad)

Conflicts:
	daemon/daemon.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment