-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Compact: Display Planned and Running Compactions #7590
base: main
Are you sure you want to change the base?
Changes from 23 commits
6ceb3b7
112bc0d
1dca384
e7c15bf
dbe5d56
d43a456
c6cf932
71b94c6
72942d0
2a486c9
f9777dc
3c7b555
f343a47
a039136
08592ae
ea98f7c
394d56e
7c46fc2
28ec713
97e0886
06cfa3a
87134d3
ee15442
ac2253a
2f19b48
2c7d008
82a07e7
b4ffc90
1046dfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
github.com/Songmu/gotesplit v0.2.1 h1:qJFvR75nJpeKyMQFwyDtFrcc6zDWhrHAkks7DvM8oLo= | ||
github.com/Songmu/gotesplit v0.2.1/go.mod h1:sVBfmLT26b1H5VhUpq8cRhCVK75GAmW9c8r2NiK0gzk= | ||
github.com/jstemmer/go-junit-report v1.0.0 h1:8X1gzZpR+nVQLAht+L/foqOeX2l9DTZoaIPbEQHxsds= | ||
github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= | ||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= | ||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,6 +239,13 @@ func runCompact( | |
consistencyDelayMetaFilter := block.NewConsistencyDelayMetaFilter(logger, conf.consistencyDelay, extprom.WrapRegistererWithPrefix("thanos_", reg)) | ||
timePartitionMetaFilter := block.NewTimePartitionMetaFilter(conf.filterConf.MinTime, conf.filterConf.MaxTime) | ||
|
||
levels, err := compactions.levels(conf.maxCompactionLevel) | ||
if err != nil { | ||
return errors.Wrap(err, "get compaction levels") | ||
} | ||
|
||
tsdbPlanner := compact.NewPlanner(logger, levels, noCompactMarkerFilter) | ||
|
||
var blockLister block.Lister | ||
switch syncStrategy(conf.blockListStrategy) { | ||
case concurrentDiscovery: | ||
|
@@ -288,6 +295,7 @@ func runCompact( | |
cf.UpdateOnChange(func(blocks []metadata.Meta, err error) { | ||
api.SetLoaded(blocks, err) | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should pass in blocksAPI.SetPlanned into UpdateOnPlanned callback? |
||
sy, err = compact.NewMetaSyncer( | ||
logger, | ||
reg, | ||
|
@@ -303,11 +311,6 @@ func runCompact( | |
} | ||
} | ||
|
||
levels, err := compactions.levels(conf.maxCompactionLevel) | ||
if err != nil { | ||
return errors.Wrap(err, "get compaction levels") | ||
} | ||
|
||
if conf.maxCompactionLevel < compactions.maxLevel() { | ||
level.Warn(logger).Log("msg", "Max compaction level is lower than should be", "current", conf.maxCompactionLevel, "default", compactions.maxLevel()) | ||
} | ||
|
@@ -371,7 +374,6 @@ func runCompact( | |
) | ||
var planner compact.Planner | ||
|
||
tsdbPlanner := compact.NewPlanner(logger, levels, noCompactMarkerFilter) | ||
largeIndexFilterPlanner := compact.WithLargeTotalIndexSizeFilter( | ||
tsdbPlanner, | ||
insBkt, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,15 +26,16 @@ import ( | |
|
||
// BlocksAPI is a very simple API used by Thanos Block Viewer. | ||
type BlocksAPI struct { | ||
baseAPI *api.BaseAPI | ||
logger log.Logger | ||
globalBlocksInfo *BlocksInfo | ||
loadedBlocksInfo *BlocksInfo | ||
baseAPI *api.BaseAPI | ||
logger log.Logger | ||
globalBlocksInfo *BlocksInfo | ||
loadedBlocksInfo *BlocksInfo | ||
plannedBlocksInfo *BlocksInfo | ||
|
||
globalLock, loadedLock sync.Mutex | ||
disableCORS bool | ||
bkt objstore.Bucket | ||
disableAdminOperations bool | ||
disableCORS bool | ||
bkt objstore.Bucket | ||
disableAdminOperations bool | ||
} | ||
|
||
type BlocksInfo struct { | ||
|
@@ -90,6 +91,7 @@ func (bapi *BlocksAPI) Register(r *route.Router, tracer opentracing.Tracer, logg | |
|
||
r.Get("/blocks", instr("blocks", bapi.blocks)) | ||
r.Post("/blocks/mark", instr("blocks_mark", bapi.markBlock)) | ||
r.Get("/blocks/plan", instr("blocks_plan", bapi.plannedBlocks)) | ||
} | ||
|
||
func (bapi *BlocksAPI) markBlock(r *http.Request) (interface{}, []error, *api.ApiError, func()) { | ||
|
@@ -146,6 +148,19 @@ func (bapi *BlocksAPI) blocks(r *http.Request) (interface{}, []error, *api.ApiEr | |
return bapi.globalBlocksInfo, nil, nil, func() {} | ||
} | ||
|
||
func (bapi *BlocksAPI) plannedBlocks(r *http.Request) (interface{}, []error, *api.ApiError, func()) { | ||
ctx := r.Context() | ||
|
||
|
||
select { | ||
case <-ctx.Done(): | ||
return nil, []error{ctx.Err()}, nil, func() {} | ||
default: | ||
} | ||
|
||
return bapi.plannedBlocksInfo, nil, nil, func() {} | ||
} | ||
|
||
func (b *BlocksInfo) set(blocks []metadata.Meta, err error) { | ||
if err != nil { | ||
// Last view is maintained. | ||
|
@@ -174,3 +189,9 @@ func (bapi *BlocksAPI) SetLoaded(blocks []metadata.Meta, err error) { | |
|
||
bapi.loadedBlocksInfo.set(blocks, err) | ||
} | ||
|
||
// SetPlanned updates the plan blocks' metadata in the API. | ||
func (bapi *BlocksAPI) SetPlanned(blocks []metadata.Meta, err error) { | ||
amandaguan-ag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
bapi.plannedBlocksInfo.set(blocks, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be a append operation |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -795,6 +795,11 @@ type Planner interface { | |
// Plan returns a list of blocks that should be compacted into single one. | ||
// The blocks can be overlapping. The provided metadata has to be ordered by minTime. | ||
Plan(ctx context.Context, metasByMinTime []*metadata.Meta, errChan chan error, extensions any) ([]*metadata.Meta, error) | ||
UpdateOnPlanned(f func([]metadata.Meta, error)) | ||
} | ||
|
||
func (p *tsdbBasedPlanner) UpdateOnPlanned(f func([]metadata.Meta, error)) { | ||
p.updateOnPlanned = f | ||
} | ||
|
||
type BlockDeletableChecker interface { | ||
|
@@ -1135,6 +1140,9 @@ func (cg *Group) compact(ctx context.Context, dir string, planner Planner, comp | |
var toCompact []*metadata.Meta | ||
if err := tracing.DoInSpanWithErr(ctx, "compaction_planning", func(ctx context.Context) (e error) { | ||
toCompact, e = planner.Plan(ctx, cg.metasByMinTime, errChan, cg.extensions) | ||
planner.UpdateOnPlanned(func(metas []metadata.Meta, err error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's call this on group level, and get plans of every group, and set it once |
||
level.Info(cg.logger).Log("msg", "planner updated", "metas", len(metas), "err", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SetPlanned over here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. planner.UpdateOnPlanned(func(blocks []metadata.Meta, err error) { |
||
}) | ||
return e | ||
}); err != nil { | ||
return false, nil, errors.Wrap(err, "plan compaction") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ type tsdbBasedPlanner struct { | |
ranges []int64 | ||
|
||
noCompBlocksFunc func() map[ulid.ULID]*metadata.NoCompactMark | ||
updateOnPlanned func([]metadata.Meta, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
} | ||
|
||
var _ Planner = &tsdbBasedPlanner{} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{ | ||
"files": { | ||
"main.css": "./static/css/main.17d667f4.css", | ||
"main.js": "./static/js/main.20f9b436.js", | ||
"main.css": "./static/css/main.0cc3dff0.css", | ||
"main.js": "./static/js/main.39be79f4.js", | ||
"static/media/codicon.ttf": "./static/media/codicon.b3726f0165bf67ac6849.ttf", | ||
"index.html": "./index.html", | ||
"static/media/index.cjs": "./static/media/index.cd351d7c31d0d3fccf96.cjs", | ||
"main.17d667f4.css.map": "./static/css/main.17d667f4.css.map", | ||
"main.20f9b436.js.map": "./static/js/main.20f9b436.js.map" | ||
"main.0cc3dff0.css.map": "./static/css/main.0cc3dff0.css.map", | ||
"main.39be79f4.js.map": "./static/js/main.39be79f4.js.map" | ||
}, | ||
"entrypoints": [ | ||
"static/css/main.17d667f4.css", | ||
"static/js/main.20f9b436.js" | ||
"static/css/main.0cc3dff0.css", | ||
"static/js/main.39be79f4.js" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><script>const GLOBAL_PATH_PREFIX="{{ pathPrefix }}"</script><script>const THANOS_COMPONENT="{{ .Component }}",THANOS_QUERY_URL="{{ .queryURL }}",THANOS_TENANT_HEADER="{{ .tenantHeader }}",THANOS_DEFAULT_TENANT="{{ .defaultTenant }}",THANOS_DISPLAY_TENANT_BOX="{{ .displayTenantBox }}"</script><link rel="manifest" href="./manifest.json"/><title>Thanos | Highly available Prometheus setup</title><script defer="defer" src="./static/js/main.20f9b436.js"></script><link href="./static/css/main.17d667f4.css" rel="stylesheet"></head><body class="bootstrap"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><script>const GLOBAL_PATH_PREFIX="{{ pathPrefix }}"</script><script>const THANOS_COMPONENT="{{ .Component }}",THANOS_QUERY_URL="{{ .queryURL }}",THANOS_TENANT_HEADER="{{ .tenantHeader }}",THANOS_DEFAULT_TENANT="{{ .defaultTenant }}",THANOS_DISPLAY_TENANT_BOX="{{ .displayTenantBox }}"</script><link rel="manifest" href="./manifest.json"/><title>Thanos | Highly available Prometheus setup</title><script defer="defer" src="./static/js/main.39be79f4.js"></script><link href="./static/css/main.0cc3dff0.css" rel="stylesheet"></head><body class="bootstrap"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably shouldn't be committing these? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add these files in .gitignore, i got these files everytime i run
make react-app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your GOBIN set to? I think this causes issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my says
/Users/amandaguan/Desktop/Epicodus/thanos/.bin
, as instructed by CONTRIBUTING.mdThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, those are older instructions, usually don't need to.