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

fix: don't fail on startup if disk usage monitor is disabled #10749

Merged
merged 4 commits into from Oct 18, 2022

Conversation

oleschoenburg
Copy link
Member

@oleschoenburg oleschoenburg commented Oct 18, 2022

Some components try to register themselves as disk usage listener on startup. When disk usage monitoring was disabled, these components would fail with an NPE during startup.

Instead of checking for null everywhere the monitor is used, we register a no-op disk usage monitor that other components can use for registering but that won't deliver any notifications.

closes #10735

Allows us to swap out the disk usage monitor with alternative
implementations.
Some components try to register themselves as disk usage listener on
startup. When disk usage monitoring was disabled, these components would
fail with an NPE during startup.

Instead of checking for null everywhere the monitor is used, we register
a no-op disk usage monitor that other components can use for
registering but that won't deliver any notifications.
@github-actions
Copy link
Contributor

github-actions bot commented Oct 18, 2022

Test Results

   861 files   - 78     861 suites   - 78   1h 4m 13s ⏱️ - 40m 51s
7 387 tests +57  7 379 ✔️ +56  7 💤 ±0  1 +1 
7 526 runs  +  5  7 516 ✔️ +  4  9 💤 ±0  1 +1 

For more details on these failures, see this check.

Results for commit aafcdef. ± Comparison against base commit ff72a85.

♻️ This comment has been updated with latest results.

@oleschoenburg
Copy link
Member Author

I tested manually and considered adding a test but writing a full integration test for this specific case felt a bit heavy-handed. Happy to be convinced otherwise though :)

@oleschoenburg oleschoenburg marked this pull request as ready for review October 18, 2022 13:59
Copy link
Contributor

@deepthidevaki deepthidevaki left a comment

Choose a reason for hiding this comment

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

LGTM. Please take a look at the comment before merging.

@@ -23,14 +27,43 @@ void startupInternal(
final ActorFuture<BrokerStartupContext> startupFuture) {

final var data = brokerStartupContext.getBrokerConfiguration().getData();

if (!data.isDiskUsageMonitoringEnabled()) {
brokerStartupContext.setDiskSpaceUsageMonitor(new DisabledDiskUsageMonitor());
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

final ActorFuture<BrokerStartupContext> shutdownFuture) {

final var diskSpaceUsageMonitor = brokerShutdownContext.getDiskSpaceUsageMonitor();
if (diskSpaceUsageMonitor instanceof DiskSpaceUsageMonitorActor actor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 It would be better to add a close method to the DiskSpaceUsageMonitorInterface interface.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, good point 👍 I've just added an extends AsyncClosable to the DiskUsageMonitor interface to implement this.

This simplifies the logic around stopping the monitor and prevents that
potential new implementations would not be closed if we would forget to
add them as a special case to the startup step.
@oleschoenburg
Copy link
Member Author

bors r+

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit 26146bd into main Oct 18, 2022
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the 10735-optional-disk-usage-monitoring branch October 18, 2022 14:59
@backport-action
Copy link
Collaborator

Backport failed for stable/8.0, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin stable/8.0
git worktree add -d .worktree/backport-10749-to-stable/8.0 origin/stable/8.0
cd .worktree/backport-10749-to-stable/8.0
git checkout -b backport-10749-to-stable/8.0
ancref=$(git merge-base ff72a85d563b4c4dfa272e168c57d4bbaefe0964 aafcdef8a567e01810b94321c19eaec6a3b7163c)
git cherry-pick -x $ancref..aafcdef8a567e01810b94321c19eaec6a3b7163c

@backport-action
Copy link
Collaborator

Successfully created backport PR #10751 for stable/8.1.

zeebe-bors-camunda bot added a commit that referenced this pull request Oct 18, 2022
10751: [Backport stable/8.1] fix: don't fail on startup if disk usage monitor is disabled r=oleschoenburg a=backport-action

# Description
Backport of #10749 to `stable/8.1`.

relates to #10735

Co-authored-by: Ole Schönburg <ole.schoenburg@gmail.com>
@korthout korthout added the version:8.1.3 Marks an issue as being completely or in parts released in 8.1.3 label Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version:8.1.3 Marks an issue as being completely or in parts released in 8.1.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broker startup fails when disk usage monitoring is disabled
4 participants