Skip to content
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

builder: use buildkit's GC for build cache #37846

Merged
merged 1 commit into from Sep 22, 2018

Conversation

Projects
None yet
8 participants
@tiborvass
Copy link
Collaborator

tiborvass commented Sep 14, 2018

This allows users to configure the buildkit GC.

The following enables the default GC:

{
  "builder": {
    "gc": {
      "enabled": true
    }
  }
}

The default GC policy has a simple config:

{
  "builder": {
    "gc": {
      "enabled": true,
      "defaultKeepStorage": "30GB"
    }
  }
}

A custom GC policy can be used instead by specifying a list of cache prune rules:

{
  "builder": {
    "gc": {
      "enabled": true,
      "policy": [
        {"keepStorage": "512MB", "filter": ["unused-for=1400h"]]},
        {"keepStorage": "30GB", "all": true}
      ]
    }
  }
}

Signed-off-by: Tibor Vass tibor@docker.com

wopt := mobyworker.Opt{
ID: "moby",
Root: root,

This comment has been minimized.

@tiborvass

tiborvass Sep 14, 2018

Author Collaborator

TODO: remove this, not needed.

@tiborvass tiborvass force-pushed the tiborvass:buildkit-gc branch from e24c7dc to 81363a2 Sep 14, 2018

@codecov

This comment has been minimized.

Copy link

codecov bot commented Sep 14, 2018

Codecov Report

❗️ No coverage uploaded for pull request base (master@b111647). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37846   +/-   ##
=========================================
  Coverage          ?   36.09%           
=========================================
  Files             ?      610           
  Lines             ?    45115           
  Branches          ?        0           
=========================================
  Hits              ?    16284           
  Misses            ?    26591           
  Partials          ?     2240

@tiborvass tiborvass force-pushed the tiborvass:buildkit-gc branch 3 times, most recently from e482e74 to e6ac871 Sep 15, 2018

if conf.GC.DefaultKeepStorage != "" {
defaultKeepStorage, err = units.RAMInBytes(conf.GC.DefaultKeepStorage)
if err != nil {
return nil, err

This comment has been minimized.

@tonistiigi

tonistiigi Sep 17, 2018

Member

nit: wrap these parse errors

@tiborvass tiborvass force-pushed the tiborvass:buildkit-gc branch from e6ac871 to c82df7c Sep 19, 2018

@thaJeztah thaJeztah added this to backlog in maintainers-session Sep 20, 2018

@andrewhsu
Copy link
Contributor

andrewhsu left a comment

LGTM

@fntlnz
Copy link
Member

fntlnz left a comment

I love this, just a few comments but in general looks very good 👼

err error
)

if conf.GC.DefaultKeepStorage != "" {

This comment has been minimized.

@fntlnz

fntlnz Sep 20, 2018

Member

Shouldn't this only be done only if conf.GC.Enabled is true?

}
}
} else {
gcPolicy = mobyworker.DefaultGCPolicy(root, defaultKeepStorage)

This comment has been minimized.

@fntlnz

fntlnz Sep 20, 2018

Member

Why not initializing gcPolicy to this directly instead of having an else statement? then if the user wants to set it the make at 194 can override it

This comment has been minimized.

@tiborvass

tiborvass Sep 20, 2018

Author Collaborator

@fntlnz It's a small matter of preference: with what you're suggesting, in the case where user wants to set it, it would have already called DefaultGCPolicy unnecessarily. The way it is now, only one of the two codepaths is executed once. If readability is what concerns you, I could change it to if conf.GC.Policy == nil { first.

@tiborvass tiborvass force-pushed the tiborvass:buildkit-gc branch from c82df7c to 380f52e Sep 20, 2018

@tiborvass

This comment has been minimized.

Copy link
Collaborator Author

tiborvass commented Sep 20, 2018

@fntlnz updated

@fntlnz

This comment has been minimized.

Copy link
Member

fntlnz commented Sep 20, 2018

LGTM

@fntlnz

fntlnz approved these changes Sep 20, 2018

if err := syscall.Statfs(root, &st); err != nil {
return defaultCap
}
diskSize := st.Bsize * int64(st.Blocks)

This comment has been minimized.

@fntlnz

fntlnz Sep 21, 2018

Member

CI is complaining that on s390x (z linux) Bsize is int32.

https://github.com/golang/go/blob/master/src/syscall/ztypes_linux_s390x.go#L119

07:19:55 builder/builder-next/worker/gc_unix.go:14:23: invalid operation: st.Bsize * int64(st.Blocks) (mismatched types uint32 and int64)

I think we need an int32 version of this too.

This comment has been minimized.

@fntlnz

@tiborvass tiborvass force-pushed the tiborvass:buildkit-gc branch from 380f52e to f341564 Sep 21, 2018

builder: use buildkit's GC for build cache
This allows users to configure the buildkit GC.

The following enables the default GC:
```
{
  "builder": {
    "gc": {
      "enabled": true
    }
  }
}
```

The default GC policy has a simple config:
```
{
  "builder": {
    "gc": {
      "enabled": true,
      "defaultKeepStorage": "30GB"
    }
  }
}
```

A custom GC policy can be used instead by specifying a list of cache prune rules:
```
{
  "builder": {
    "gc": {
      "enabled": true,
      "policy": [
        {"keepStorage": "512MB", "filter": ["unused-for=1400h"]]},
        {"keepStorage": "30GB", "all": true}
      ]
    }
  }
}
```

Signed-off-by: Tibor Vass <tibor@docker.com>
@yongtang

This comment has been minimized.

Copy link
Member

yongtang commented Sep 22, 2018

All tests passed so merging.

@yongtang yongtang merged commit fb7883e into moby:master Sep 22, 2018

7 of 8 checks passed

codecov/patch 0% of diff hit (target 50%)
Details
codecov/project No report found to compare against
Details
dco-signed All commits are signed
experimental Jenkins build Docker-PRs-experimental 42268 has succeeded
Details
janky Jenkins build Docker-PRs 51041 has succeeded
Details
powerpc Jenkins build Docker-PRs-powerpc 11463 has succeeded
Details
windowsRS1 Jenkins build Docker-PRs-WoW-RS1 22322 has succeeded
Details
z Jenkins build Docker-PRs-s390x 11331 has succeeded
Details

@thaJeztah thaJeztah removed this from backlog in maintainers-session Sep 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.