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

refactor(blooms): Add RPC service for bloom-planner #13015

Merged
merged 8 commits into from
May 27, 2024

Conversation

salvacorts
Copy link
Contributor

@salvacorts salvacorts commented May 22, 2024

What this PR does / why we need it:
This PR adds a new RPC service implemented by the planner to communicate the planner and the builder. The implementation is pretty similar top the query scheduler.

Special notes for your reviewer:

  • Since we haven't built yet the builder, I implemented a with a builder mock.
  • I'm passing TSDB indentifiers and block refs as strings. We can reconsider defining protos for them in the future.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@salvacorts salvacorts marked this pull request as ready for review May 22, 2024 15:33
@salvacorts salvacorts requested a review from a team as a code owner May 22, 2024 15:33
taskLost: promauto.With(r).NewCounter(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: metricsSubsystem,
Name: "task_lost_total",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be named tasks_lost_total?

if err := services.StartManagerAndAwaitHealthy(ctx, p.subservices); err != nil {
return fmt.Errorf("error starting planner subservices: %w", err)
}

p.metrics.running.Set(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: How meaningful is the running metric?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use it for other components and in the original bloom compactor.
Even though you may use a k82 metric to check if the pod is running:

  • That won't work in non- k82 envs
  • This is set to 1 only when the component is actually ready to start working

So I think that's the usefulness of this metric.

Comment on lines 150 to 152
p.pendingTasksMu.Lock()
inflight := len(p.pendingTasks)
p.pendingTasksMu.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Since we use this pendingTasks every time we use the queue, would it make sense to implement a reusable sync map for pending tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Done

Comment on lines 384 to 395
// Start planner
err = planner.StartAsync(context.Background())
require.NoError(t, err)
require.Eventually(t, func() bool {
return planner.State() == services.Running
}, 15*time.Second, 10*time.Millisecond)
defer func() {
planner.StopAsync()
require.Eventually(t, func() bool {
return planner.State() != services.Running
}, 1*time.Minute, 100*time.Millisecond)
}()
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use functions from the services package for starting and stopping:

err := services.StartAndAwaitRunning(context.Background(), planner)
require.NoError(t, err)
t.Cleanup(func() {
    err := services.StopAndAwaitTerminated(context.Background(), planner)
    require.NoError(t, err)
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice, TIL! Thank you 👍

@salvacorts salvacorts requested a review from chaudum May 27, 2024 09:25
@salvacorts salvacorts merged commit f6529c2 into main May 27, 2024
59 checks passed
@salvacorts salvacorts deleted the salvacorts/bloom-refactor/rpc-service branch May 27, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants