-
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?
Conversation
Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
…tching planned blocks Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
…ndicator, and Blocks component with API integration Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
8cb3769
to
e7c15bf
Compare
af0c7b3
to
c6cf932
Compare
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.
Thanks! Some feedback
pkg/api/blocks/v1.go
Outdated
} | ||
|
||
metasByMinTime := []*metadata.Meta{&mockBlocks[0], &mockBlocks[1]} | ||
plannedMetas, err := bapi.planner.Plan(context.TODO(), metasByMinTime, nil, nil) |
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.
Do we define bapi.planner
anywhere?
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.
Just defined bapi.planner in the BlocksAPI struct
.bin/gopls
Outdated
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.md
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.
I see, those are older instructions, usually don't need to.
if (globalBlocksLoading || planLoading) return <div>Loading...</div>; | ||
if (globalBlocksError) return <UncontrolledAlert color="danger">{globalBlocksError.toString()}</UncontrolledAlert>; | ||
if (planError) return <UncontrolledAlert color="danger">{planError.toString()}</UncontrolledAlert>; | ||
|
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.
Would we need this, I think the WithStatusIndicator
handles this for us?
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.
I see. withStatusIndicator HOC will be handling the loading and error states, i will remove the redundant checks
|
||
if (err) { | ||
return ( | ||
<UncontrolledAlert color="danger">{err.toString()}</UncontrolledAlert> |
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 done with status indicator already?
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.
I will look in withStatusIndicator for this one. I see BlocksContent also has this direct handling
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.
I see withStatusIndicator is handling error in general and Displaying an error message (. I will take off from PlanBlocksContent and maybe from BlocksContent
key={key} | ||
data={blocksPool[key]} | ||
title={`Plan View - ${key}`} | ||
selectBlock={() => { }} // No-op function if selection is not applicable |
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.
Why no-op here?
isLoading={isLoading} | ||
/> | ||
<div> | ||
<h2>Planned Blocks</h2> |
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.
I think...this would make sense as a separate page rather than a component above the Global Blocks screen?
…n assigned to bapi.planner
…ithStatusIndicator HOC should be handling the loading and error states
The selectBlock function is passed down to SourceView where it can be invoked, typically through some user interaction like clicking on a block.
- Add new routes for Global Blocks and Planned Blocks in App.tsx - Update navigation configuration to include links to new pages - Create GlobalBlocks and PlannedBlocks components - Implement separate views for global and planned blocks - Ensure proper routing and prop passing for new components This commit introduces dedicated pages for viewing Global Blocks and Planned Blocks, improving the organization and accessibility of block information in the Thanos UI. Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
c461c53
to
28ec713
Compare
This commit introduces the `UpdateOnPlanned` method in the `tsdbBasedPlanner` struct, allowing for dynamic updates of planned block metadata. The callback mechanism is integrated into the compaction process to handle planned blocks efficiently. The main changes include: - Definition and implementation of `UpdateOnPlanned` in `tsdbBasedPlanner`. - Adjustment in `runCompact` to instantiate `tsdbPlanner` at the beginning of the function, ensuring accessibility throughout the compaction process and avoiding repeated declaration. - Use of `UpdateOnPlanned` to set planned blocks via the API, enhancing the flexibility and responsiveness of block management. By moving the `tsdbPlanner` instantiation earlier in `runCompact`, we avoid duplication and enhance code clarity, ensuring the planner is accessible where needed without multiple initializations. Signed-off-by: amandaguan-ag<amandaguan1314@gmail.com>
…an the tsdbBasedPlanner struct
Signed-off-by: amandaguan-ag <amandaguan1314@gmail.com>
pkg/compact/compact.go
Outdated
@@ -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) { | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
planner.UpdateOnPlanned(func(blocks []metadata.Meta, err error) {
api.SetPlanned(blocks, err)
})
// SetPlanned updates the plan blocks' metadata in the API. | ||
func (bapi *BlocksAPI) SetPlanned(blocks []metadata.Meta, err error) { | ||
|
||
bapi.plannedBlocksInfo.set(blocks, err) |
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 be a append operation
pkg/compact/planner.go
Outdated
@@ -53,6 +54,10 @@ func (p *tsdbBasedPlanner) Plan(_ context.Context, metasByMinTime []*metadata.Me | |||
return p.plan(p.noCompBlocksFunc(), metasByMinTime) | |||
} | |||
|
|||
func (p *tsdbBasedPlanner) UpdateOnPlanned(f func([]metadata.Meta, error)) { | |||
p.updateOnPlanned = f |
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.
updateOnPlanned needs to be called from somewhere..to figure out.
Also, let's do this on the planner interface instead?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe listener
instead of updateOnPlanned?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
We should pass in blocksAPI.SetPlanned into UpdateOnPlanned callback?
pkg/compact/compact.go
Outdated
@@ -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) { | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
SetPlanned over here?
pkg/compact/compact.go
Outdated
@@ -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 comment
The 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
1. Add BlocksAPI to Compact method 2. Update BlocksAPI initialization - Return plannedBlocksInfo in BlocksAPI constructor 3. Enhance compact package - Add blocksAPI parameter to Group.compact method This change improves the integration of BlocksAPI with the compaction process. Signed-off-by: [amandaguan-ag] <amandaguan1314@gmail.com>
61711a7
to
ac2253a
Compare
1. Introduce `blocksAPI` fields to the `BucketCompactor` struct. 2. Implement logic to retrieve metas for the current group and convert them into `[]metadata.Meta`. 3. Invoke `Syncer.SetPlanned` prior to compaction to update the syncer's state. 4. Invoke `BlocksAPI.SetPlanned` to synchronize the API with the planned metas. These updates enhance the tracking and management of planned compactions, streamlining the overall process and ensuring that external systems are informed of upcoming compactions. Signed-off-by: [amandaguan-ag] <amandaguan1314@gmail.com>
groupMetas := g.Metas() | ||
|
||
// Delete before merge: Convert []*metadata.Meta to []metadata.Meta | ||
plannedMetas := make([]metadata.Meta, len(groupMetas)) |
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.
Ok, I think we are just setting blocks of the group, instead of the planned blocks? We need planner.Plan output
} | ||
|
||
// Delete before merge: Call Syncer.SetPlanned before compaction | ||
if err := c.sy.SetPlanned(plannedMetas); err != nil { |
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.
I think this will be overriden on each group
@@ -1475,7 +1490,33 @@ func (c *BucketCompactor) Compact(ctx context.Context, v1 *v1.BlocksAPI) (rerr e | |||
go func() { | |||
defer wg.Done() | |||
for g := range groupChan { | |||
shouldRerunGroup, _, err := g.Compact(workCtx, c.compactDir, c.planner, c.comp, c.blockDeletableChecker, c.compactionLifecycleCallback, v1) | |||
// Delete before merge: Get the metas for the current group | |||
groupMetas := g.Metas() |
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.
do i need change the source from g to planner.plan, move out not for group
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.
read go routine, and channels ->concurrency
Changes
planned blocks
Verification