Skip to content

Update ZooKeeper Options Panel Timeout for Validation#7969

Merged
bcarrier merged 4 commits intosleuthkit:developfrom
markmckinnon:change-zookeeper-session-time-value-for-options-panel-validation
Apr 8, 2026
Merged

Update ZooKeeper Options Panel Timeout for Validation#7969
bcarrier merged 4 commits intosleuthkit:developfrom
markmckinnon:change-zookeeper-session-time-value-for-options-panel-validation

Conversation

@markmckinnon
Copy link
Copy Markdown
Contributor

@markmckinnon markmckinnon commented May 30, 2025

Change timeout from 3000 to 15000 for options panel validation. Worked in 4.21.0 but was not long enough for 4.22.1 so I increased it.

Summary by CodeRabbit

  • Performance Improvements

    • Faster, streamlined health checks for coordination services using a lightweight network probe.
    • Quicker detection of server availability and reduced overhead during monitoring.
    • Improved system responsiveness when observing coordination endpoints.
  • Bug Fixes

    • More reliable connectivity detection with clearer timeout behavior.
    • Improved handling of transient connection errors, reducing false-positive availability reports.

Change timeout from 3000 to 15000 for options panel validation
Change code to use ruok/imok
…-session-time-value-for-options-panel-validation
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f116adcf-176c-48f6-86f9-3437b8f20a19

📥 Commits

Reviewing files that changed from the base of the PR and between 5a64432 and 22292ef.

📒 Files selected for processing (1)
  • Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java

📝 Walkthrough

Walkthrough

The isZooKeeperAccessible() method was refactored to use a lightweight TCP socket health probe (ruokimok) instead of creating a ZooKeeper client and waiting for connection events; timeouts and ZooKeeper-specific connection-state handling were removed.

Changes

Cohort / File(s) Summary
ZooKeeper Connectivity Check
Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java
Replaced ZooKeeper client initialization and WatchedEvent-based synchronization with a direct TCP Socket probe. Sends ruok, reads single-line response, returns true only if response contains imok (case-insensitive). Removed ZooKeeper session/connection-timeout constants and explicit client close; socket timeouts now cause method to return false.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I nudged a socket, whispered "ruok" tonight,
A tiny "imok" beamed back in soft moonlight,
No watchers waiting, no sessions to keep,
Just a brisk little hop and the health check is complete. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title refers to updating a ZooKeeper timeout value, but the actual changes involve refactoring the health check mechanism from ZooKeeper-specific logic to socket-based probing with ruok/imok commands. Revise the title to accurately reflect the main change, such as 'Refactor ZooKeeper health check to use socket-based ruok/imok probing' or 'Replace ZooKeeper client connection with socket-based health check'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PMD (7.23.0)
Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java

[ERROR] Cannot load ruleset rulesets/java/basic.xml/SimplifiedTernary: Cannot resolve rule/ruleset reference 'rulesets/java/basic.xml/SimplifiedTernary'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java`:
- Line 35: The ZOOKEEPER_SESSION_TIMEOUT_MILLIS constant still uses 3000; update
the value of ZOOKEEPER_SESSION_TIMEOUT_MILLIS to 15000 (milliseconds) so the
validation timeout increase is applied—locate and modify the declaration of
ZOOKEEPER_SESSION_TIMEOUT_MILLIS in CoordinationServiceUtils to use 15000.
- Around line 49-63: The Socket in
CoordinationServiceUtils.validateZookeeperInstance (the block that creates new
Socket(), connects using hostName and port with
ZOOKEEPER_SESSION_TIMEOUT_MILLIS, writes "ruok", and reads response) must be
wrapped in a try-with-resources so the socket and its streams are always closed
on exceptions; move the socket creation into try (Socket socket = new Socket())
{ ... } and perform the connect(), setSoTimeout(), getOutputStream()/write/flush
and BufferedReader(InputStreamReader(socket.getInputStream()))/readLine() inside
that block, and check the readLine() result for null before calling
toLowerCase() to avoid NPE; keep the existing catch for SocketTimeoutException
to set result = false.
- Around line 60-65: The code reads a line into response via reader.readLine()
and immediately calls response.toLowerCase(), which can NPE if readLine()
returns null; update the logic in CoordinationServiceUtils (around the
response/readLine call) to null-check response before any string ops (e.g., if
(response != null && response.toLowerCase().contains("imok")) { result = true;
}) and handle the null case explicitly (treat as no-response/false or log and
continue) so the SocketTimeoutException catch remains but a potential
NullPointerException is prevented.
- Around line 56-65: The current 4LW "ruok" probe in CoordinationServiceUtils is
unsafe and may produce false negatives; update the probe code to (1) use
try-with-resources for Socket/InputStream/BufferedWriter/BufferedReader to
ensure the socket is always closed, (2) catch broader exceptions (IOException
and general Exception) not just SocketTimeoutException, (3) null-check the
response before calling response.toLowerCase(), and (4) do not treat a failed or
non-"imok" probe as a definitive false — instead return an "inconclusive" result
(e.g., null or a distinct status) so the caller in CoordinationService (which
runs the Curator connection on success) can attempt the Curator-based
connection; reference the probe block in CoordinationServiceUtils and the caller
in CoordinationService to implement the non-fatal behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef62edab-6df6-4298-84e2-928908abc8f6

📥 Commits

Reviewing files that changed from the base of the PR and between 5c46a36 and 5a64432.

📒 Files selected for processing (1)
  • Core/src/org/sleuthkit/autopsy/coordinationservice/utils/CoordinationServiceUtils.java

changes based on coderabbit
@bcarrier bcarrier merged commit 6901fa7 into sleuthkit:develop Apr 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants