cache: implement filter for diskusage

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-07-25 17:01:37 -07:00
parent d87d9d4c64
commit 0ba24f2a90
5 changed files with 198 additions and 99 deletions

View File

@ -57,6 +57,7 @@ var _ = time.Kitchen
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type PruneRequest struct {
Filter []string `protobuf:"bytes,1,rep,name=filter" json:"filter,omitempty"`
}
func (m *PruneRequest) Reset() { *m = PruneRequest{} }
@ -64,8 +65,15 @@ func (m *PruneRequest) String() string { return proto.CompactTextStri
func (*PruneRequest) ProtoMessage() {}
func (*PruneRequest) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{0} }
func (m *PruneRequest) GetFilter() []string {
if m != nil {
return m.Filter
}
return nil
}
type DiskUsageRequest struct {
Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`
Filter []string `protobuf:"bytes,1,rep,name=filter" json:"filter,omitempty"`
}
func (m *DiskUsageRequest) Reset() { *m = DiskUsageRequest{} }
@ -73,11 +81,11 @@ func (m *DiskUsageRequest) String() string { return proto.CompactText
func (*DiskUsageRequest) ProtoMessage() {}
func (*DiskUsageRequest) Descriptor() ([]byte, []int) { return fileDescriptorControl, []int{1} }
func (m *DiskUsageRequest) GetFilter() string {
func (m *DiskUsageRequest) GetFilter() []string {
if m != nil {
return m.Filter
}
return ""
return nil
}
type DiskUsageResponse struct {
@ -898,6 +906,21 @@ func (m *PruneRequest) MarshalTo(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.Filter) > 0 {
for _, s := range m.Filter {
dAtA[i] = 0xa
i++
l = len(s)
for l >= 1<<7 {
dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
l >>= 7
i++
}
dAtA[i] = uint8(l)
i++
i += copy(dAtA[i:], s)
}
}
return i, nil
}
@ -917,10 +940,19 @@ func (m *DiskUsageRequest) MarshalTo(dAtA []byte) (int, error) {
var l int
_ = l
if len(m.Filter) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintControl(dAtA, i, uint64(len(m.Filter)))
i += copy(dAtA[i:], m.Filter)
for _, s := range m.Filter {
dAtA[i] = 0xa
i++
l = len(s)
for l >= 1<<7 {
dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
l >>= 7
i++
}
dAtA[i] = uint8(l)
i++
i += copy(dAtA[i:], s)
}
}
return i, nil
}
@ -1599,15 +1631,23 @@ func encodeVarintControl(dAtA []byte, offset int, v uint64) int {
func (m *PruneRequest) Size() (n int) {
var l int
_ = l
if len(m.Filter) > 0 {
for _, s := range m.Filter {
l = len(s)
n += 1 + l + sovControl(uint64(l))
}
}
return n
}
func (m *DiskUsageRequest) Size() (n int) {
var l int
_ = l
l = len(m.Filter)
if l > 0 {
n += 1 + l + sovControl(uint64(l))
if len(m.Filter) > 0 {
for _, s := range m.Filter {
l = len(s)
n += 1 + l + sovControl(uint64(l))
}
}
return n
}
@ -1940,6 +1980,35 @@ func (m *PruneRequest) Unmarshal(dAtA []byte) error {
return fmt.Errorf("proto: PruneRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Filter", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowControl
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthControl
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Filter = append(m.Filter, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipControl(dAtA[iNdEx:])
@ -2017,7 +2086,7 @@ func (m *DiskUsageRequest) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Filter = string(dAtA[iNdEx:postIndex])
m.Filter = append(m.Filter, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
default:
iNdEx = preIndex
@ -4511,79 +4580,79 @@ var (
func init() { proto.RegisterFile("control.proto", fileDescriptorControl) }
var fileDescriptorControl = []byte{
// 1176 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4d, 0x6f, 0x23, 0x45,
0x13, 0x7e, 0xc7, 0x76, 0xfc, 0x51, 0x76, 0xa2, 0xbc, 0x0d, 0xac, 0x46, 0x03, 0x24, 0x66, 0x00,
0xc9, 0x5a, 0xed, 0xce, 0x64, 0x03, 0x2b, 0xa1, 0x08, 0xad, 0x76, 0x1d, 0x2f, 0x22, 0x51, 0x22,
0x96, 0xce, 0x86, 0x95, 0xb8, 0x8d, 0xed, 0x8e, 0x77, 0x14, 0x7b, 0x7a, 0xe8, 0xee, 0x09, 0x6b,
0x7e, 0x05, 0x07, 0xfe, 0x09, 0x07, 0xce, 0x1c, 0x90, 0xf6, 0xc8, 0x99, 0x43, 0x16, 0xe5, 0x0e,
0xbf, 0x01, 0xf5, 0xc7, 0xd8, 0xed, 0xd8, 0xf9, 0xdc, 0x53, 0xba, 0x2a, 0x4f, 0x3d, 0x53, 0x5d,
0x4f, 0xb9, 0xab, 0x60, 0xb9, 0x47, 0x13, 0xc1, 0xe8, 0x30, 0x48, 0x19, 0x15, 0x14, 0xad, 0x8e,
0x68, 0x77, 0x1c, 0x74, 0xb3, 0x78, 0xd8, 0x3f, 0x8e, 0x45, 0x70, 0xf2, 0xc0, 0xbb, 0x3f, 0x88,
0xc5, 0xcb, 0xac, 0x1b, 0xf4, 0xe8, 0x28, 0x1c, 0xd0, 0x01, 0x0d, 0x15, 0xb0, 0x9b, 0x1d, 0x29,
0x4b, 0x19, 0xea, 0xa4, 0x09, 0xbc, 0xf5, 0x01, 0xa5, 0x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99, 0xd4, 0x0c, 0x59, 0xc4, 0x64, 0x2f,
0x1b, 0xde, 0xfa, 0x15, 0xc3, 0x07, 0xed, 0x43, 0xd9, 0xfc, 0x9c, 0x17, 0x41, 0xed, 0x49, 0xe1,
0x35, 0x2f, 0x06, 0x68, 0xb2, 0x0d, 0x07, 0xed, 0x4f, 0x36, 0xa9, 0x45, 0xa9, 0xd9, 0x6d, 0xe0,
0x5d, 0xf1, 0xff, 0x96, 0xb3, 0xe1, 0xa0, 0xef, 0xa1, 0x6e, 0x09, 0x8d, 0x16, 0x08, 0x3a, 0xdf,
0x35, 0xde, 0xa7, 0x57, 0xa0, 0x74, 0xb2, 0xed, 0xc6, 0xeb, 0xb3, 0x35, 0xe7, 0xcf, 0xb3, 0x35,
0xe7, 0xef, 0xb3, 0x35, 0xa7, 0x5b, 0x56, 0x7d, 0xff, 0xd9, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff,
0xe1, 0xef, 0xcc, 0xf5, 0x6f, 0x0d, 0x00, 0x00,
// 1171 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x6f, 0x1b, 0x45,
0x14, 0x67, 0x6d, 0xc7, 0xf6, 0x3e, 0x3b, 0x55, 0x18, 0xa0, 0x5a, 0x2d, 0x90, 0x98, 0xe5, 0x8f,
0xac, 0xaa, 0xdd, 0x6d, 0x03, 0x95, 0x50, 0x84, 0xaa, 0xd6, 0x71, 0x11, 0xa9, 0x12, 0x51, 0x26,
0x0d, 0x95, 0xb8, 0xad, 0xed, 0xc9, 0x76, 0x15, 0x7b, 0x67, 0x99, 0x99, 0x0d, 0x35, 0x9f, 0x82,
0x03, 0xdf, 0x84, 0x03, 0x67, 0x0e, 0x48, 0x3d, 0x72, 0xe6, 0x90, 0xa2, 0xdc, 0xe1, 0x33, 0xa0,
0xf9, 0xb3, 0xf6, 0x3a, 0x76, 0xe2, 0x24, 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90, 0x7c,
0xd9, 0x1e, 0xb8, 0x0f, 0xef, 0xcc, 0xa0, 0xcd, 0x2b, 0xf5, 0xd5, 0x99, 0x4d, 0xf0, 0x93, 0xf9,
0x57, 0x43, 0x2d, 0xaa, 0xbe, 0x0e, 0x9c, 0x5d, 0x08, 0x37, 0xff, 0x2d, 0x43, 0x6d, 0x5b, 0xef,
0xe0, 0xe8, 0x19, 0xd8, 0x93, 0x45, 0x13, 0x79, 0xf3, 0x34, 0x67, 0x37, 0x56, 0xf7, 0xe3, 0x0b,
0x31, 0x26, 0xbf, 0x6f, 0x60, 0x45, 0xad, 0xc4, 0x68, 0xc1, 0x33, 0x58, 0xdc, 0x95, 0xdd, 0x8b,
0x57, 0xd8, 0xbb, 0x96, 0x64, 0x52, 0x33, 0x64, 0x11, 0x53, 0x71, 0xd9, 0x70, 0x37, 0x96, 0x0c,
0x1f, 0xb4, 0x07, 0x55, 0xf3, 0x39, 0x2f, 0x82, 0x16, 0x27, 0x85, 0xdb, 0x3a, 0x1f, 0xa0, 0xc9,
0xee, 0x5a, 0x68, 0x6f, 0xb2, 0x49, 0x2d, 0x4a, 0xad, 0xd8, 0x06, 0xee, 0x92, 0xff, 0xb7, 0xad,
0xbb, 0x16, 0xfa, 0x01, 0x1a, 0x05, 0xa1, 0xd1, 0x02, 0x41, 0xe7, 0xbb, 0xc6, 0xfd, 0x74, 0x09,
0x4a, 0x27, 0xdb, 0x69, 0xbe, 0x3a, 0x5d, 0xb7, 0xfe, 0x3a, 0x5d, 0xb7, 0xfe, 0x39, 0x5d, 0xb7,
0x7a, 0x55, 0xd5, 0xf7, 0x9f, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x32, 0x58, 0x96, 0x9a, 0x87,
0x0d, 0x00, 0x00,
}

View File

@ -25,11 +25,11 @@ service Control {
}
message PruneRequest {
// TODO: filter
repeated string filter = 1; // FIXME: not implemented
}
message DiskUsageRequest {
string filter = 1; // FIXME: this should be containerd-compatible repeated string?
repeated string filter = 1;
}
message DiskUsageResponse {

42
cache/manager.go vendored
View File

@ -2,10 +2,10 @@ package cache
import (
"context"
"strings"
"sync"
"time"
"github.com/containerd/containerd/filters"
"github.com/containerd/containerd/snapshots"
"github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/client"
@ -398,6 +398,11 @@ func (cm *cacheManager) prune(ctx context.Context, ch chan client.UsageInfo) err
}
func (cm *cacheManager) DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*client.UsageInfo, error) {
filter, err := filters.ParseAll(opt.Filter...)
if err != nil {
return nil, err
}
cm.mu.Lock()
type cacheUsageInfo struct {
@ -465,10 +470,6 @@ func (cm *cacheManager) DiskUsage(ctx context.Context, opt client.DiskUsageInfo)
var du []*client.UsageInfo
for id, cr := range m {
if opt.Filter != "" && !strings.HasPrefix(id, opt.Filter) {
continue
}
c := &client.UsageInfo{
ID: id,
Mutable: cr.mutable,
@ -480,7 +481,9 @@ func (cm *cacheManager) DiskUsage(ctx context.Context, opt client.DiskUsageInfo)
LastUsedAt: cr.lastUsedAt,
UsageCount: cr.usageCount,
}
du = append(du, c)
if filter.Match(adaptUsageInfo(c)) {
du = append(du, c)
}
}
eg, ctx := errgroup.WithContext(ctx)
@ -571,3 +574,30 @@ func initializeMetadata(m withMetadata, opts ...RefOption) error {
return md.Commit()
}
func adaptUsageInfo(info *client.UsageInfo) filters.Adaptor {
return filters.AdapterFunc(func(fieldpath []string) (string, bool) {
if len(fieldpath) == 0 {
return "", false
}
switch fieldpath[0] {
case "id":
return info.ID, info.ID != ""
case "parent":
return info.Parent, info.Parent != ""
case "description":
return info.Description, info.Description != ""
case "inuse":
return "", info.InUse
case "mutable":
return "", info.Mutable
case "immutable":
return "", !info.Mutable
}
// TODO: add int/datetime/bytes support for more fields
return "", false
})
}

View File

@ -63,10 +63,10 @@ func (c *Client) DiskUsage(ctx context.Context, opts ...DiskUsageOption) ([]*Usa
type DiskUsageOption func(*DiskUsageInfo)
type DiskUsageInfo struct {
Filter string
Filter []string
}
func WithFilter(f string) DiskUsageOption {
func WithFilter(f []string) DiskUsageOption {
return func(di *DiskUsageInfo) {
di.Filter = f
}

View File

@ -16,9 +16,9 @@ var diskUsageCommand = cli.Command{
Usage: "disk usage",
Action: diskUsage,
Flags: []cli.Flag{
cli.StringFlag{
cli.StringSliceFlag{
Name: "filter, f",
Usage: "Filter snapshot ID",
Usage: "Filter records",
},
cli.BoolFlag{
Name: "verbose, v",
@ -33,7 +33,7 @@ func diskUsage(clicontext *cli.Context) error {
return err
}
du, err := c.DiskUsage(commandContext(clicontext), client.WithFilter(clicontext.String("filter")))
du, err := c.DiskUsage(commandContext(clicontext), client.WithFilter(clicontext.StringSlice("filter")))
if err != nil {
return err
}