Prefer ZooKeeper configuration over static config#128
Prefer ZooKeeper configuration over static config#128mithunbharadwaj wants to merge 6 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds ZooKeeper-backed configuration overrides layered onto the existing static config. A new module loads JSON from a configured znode, stringifies and merges values into Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant ZK as ZooKeeper
participant Config as asab.Config
participant Service as LibraryService
App->>App: Load static config
App->>ZK: Create ZooKeeperContainer (if configured)
App->>App: resolve znode path from `[config_zookeeper]`
App->>ZK: read znode content
alt node present & valid JSON
ZK-->>App: JSON payload
App->>App: stringify & validate values
App->>Config: apply overrides (merge into sections)
Config-->>App: config updated
App-->>Service: instantiate with finalized config
else node missing/unavailable or error
ZK-->>App: empty/error
App-->>Service: instantiate with static config
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
README.md (1)
46-48: Document the supportedurlalternative in[config_zookeeper].The implementation accepts both
pathandurlas inputs for resolving the znode path, but this section only showspath. Adding theurlvariant here would keep operator guidance aligned with runtime behavior.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 46 - 48, Update the README's [config_zookeeper] example to document the supported alternative key by showing both path and url variants; mention that the implementation accepts either the path key (path) or the url key (url) for resolving the znode path so operators know both are valid and how to use them when configuring the service.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@asabiris/config_zookeeper.py`:
- Around line 100-110: The code decodes byte znode data to payload_raw and then
calls json.loads even when payload_raw is an empty string, causing a parse
warning; modify the branch that handles bytes (where data is decoded into
payload_raw) to check if payload_raw is empty (e.g., payload_raw == "" or
payload_raw.strip() == "") and if so log the existing L.info message and return
{} immediately (same behavior as the earlier data is None branch) before calling
json.loads; adjust the logic around payload_raw, payload =
json.loads(payload_raw), and the subsequent isinstance(payload, dict) check
accordingly.
- Around line 95-100: Replace the two-step exists()/get() in
load_config_overrides() with a single guarded get() call and handle Kazoo
exceptions locally: wrap zk_client.get(path) in a try/except that catches
kazoo.exceptions.NoNodeError and kazoo.exceptions.KazooException, log a
descriptive message via L (e.g., info/warn) and return {} on those errors so
ZooKeeper race conditions or transient failures don’t propagate; remove the
prior exists() check and ensure only
configparser.Error/ValueError/json.JSONDecodeError are left to be handled by the
outer parser logic.
---
Nitpick comments:
In `@README.md`:
- Around line 46-48: Update the README's [config_zookeeper] example to document
the supported alternative key by showing both path and url variants; mention
that the implementation accepts either the path key (path) or the url key (url)
for resolving the znode path so operators know both are valid and how to use
them when configuring the service.
🪄 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: cc947c6c-0183-412e-8a83-8c48db1e2e77
📒 Files selected for processing (3)
README.mdasabiris/app.pyasabiris/config_zookeeper.py
Summary by CodeRabbit
New Features
Documentation