Skip to content

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

Merged
yongtang merged 1 commit intomoby:masterfrom
tiborvass:buildkit-gc
Sep 22, 2018
Merged

builder: use buildkit's GC for build cache#37846
yongtang merged 1 commit intomoby:masterfrom
tiborvass:buildkit-gc

Conversation

@tiborvass
Copy link
Copy Markdown
Contributor

@tiborvass 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 [email protected]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: remove this, not needed.

@codecov
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: wrap these parse errors

Copy link
Copy Markdown
Contributor

@andrewhsu andrewhsu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@fntlnz fntlnz left a comment

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

@tiborvass tiborvass Sep 20, 2018

Choose a reason for hiding this comment

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

@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
Copy link
Copy Markdown
Contributor Author

@fntlnz updated

@fntlnz
Copy link
Copy Markdown
Contributor

fntlnz commented Sep 20, 2018

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 <[email protected]>
@yongtang
Copy link
Copy Markdown
Member

All tests passed so merging.

@Zeks
Copy link
Copy Markdown

Zeks commented Dec 25, 2019

Can you tell me exactly which config file I need to edit to set the options from the original post?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants