Skip to content

feat(disvocery): Add zookeeper discovery - #12772

Closed
dongjiang1989 wants to merge 2 commits into
apache:masterfrom
dongjiang1989:add-zookeeper-discovery
Closed

feat(disvocery): Add zookeeper discovery#12772
dongjiang1989 wants to merge 2 commits into
apache:masterfrom
dongjiang1989:add-zookeeper-discovery

Conversation

@dongjiang1989

Copy link
Copy Markdown
Contributor

Description

Which issue(s) this PR fixes:

Fixes #3231 #6687

Add zookeeper discovery

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dongjiang1989 dongjiang1989 changed the title feat: Add zookeeper discovery feat(disvocery): Add zookeeper discovery Nov 24, 2025
@dongjiang1989
dongjiang1989 force-pushed the add-zookeeper-discovery branch from 7bfba46 to 01f70df Compare November 24, 2025 11:43
@dongjiang1989
dongjiang1989 marked this pull request as ready for review November 24, 2025 12:29
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 24, 2025

@Baoyuantop Baoyuantop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @dongjiang1989, thanks for your contribution. Could you add documentation and testing for this feature? You can refer to other service discovery modules for reference.

Comment thread apisix/discovery/zookeeper/schema.lua Outdated
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

Hi @dongjiang1989, thanks for your contribution. Could you add documentation and testing for this feature? You can refer to other service discovery modules for reference.

Thanks @Baoyuantop
Documentation and Testing will coming

@dongjiang1989
dongjiang1989 force-pushed the add-zookeeper-discovery branch 3 times, most recently from 3993d37 to ea3c33e Compare November 26, 2025 02:24
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 26, 2025
@dongjiang1989
dongjiang1989 force-pushed the add-zookeeper-discovery branch from f25602f to 3435db2 Compare November 26, 2025 03:22
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

@Baoyuantop Please review docs, thanks

@Baoyuantop

Copy link
Copy Markdown
Contributor

Hi @dongjiang1989, additional tests are needed to verify that the function works correctly.

Comment thread apisix/discovery/zookeeper/init.lua
Comment thread apisix/discovery/zookeeper/init.lua Outdated
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

Hi @dongjiang1989, additional tests are needed to verify that the function works correctly.

Got it. I'll add UT soon

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Dec 8, 2025
@Baoyuantop

Copy link
Copy Markdown
Contributor

Hi @dongjiang1989, any update?

@dongjiang1989
dongjiang1989 force-pushed the add-zookeeper-discovery branch from 9ce82a8 to 836a97b Compare December 17, 2025 10:47
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 17, 2025
@dongjiang1989
dongjiang1989 force-pushed the add-zookeeper-discovery branch from 448b4c1 to f81575e Compare December 18, 2025 03:28
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
@dongjiang1989
dongjiang1989 force-pushed the add-zookeeper-discovery branch from 80c05ef to 00618b0 Compare December 18, 2025 10:03
@dongjiang1989

Copy link
Copy Markdown
Contributor Author

Hi @dongjiang1989, any update?

Thanks @Baoyuantop
Update. Please re-check it

Comment thread apisix/discovery/zookeeper/utils.lua Outdated
Comment thread apisix/discovery/zookeeper/init.lua Outdated
Comment thread apisix/discovery/zookeeper/init.lua Outdated
end

-- Scheduled fetch of all service instances (full cache update))
local function fetch_all_services()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do not fetch all services from ZooKeeper. This can cause significant network overhead when there are many services in ZooKeeper. It is recommended to refer to the Nacos implementation and use a timer to iterate through the currently configured Upstream, Route, and Service resources of APISIX, collecting all currently used service_names (with discovery_type set to zookeeper). Only perform ZooKeeper queries and cache updates on these "in-use" services.

log.info("zookeeper_conf:", core.json.encode(zookeeper_conf))
-- Start the timer
if not fetch_timer then
fetch_timer = ngx.timer.every(zookeeper_conf.fetch_interval, fetch_all_services)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is recommended that only privileged processes request data from ZooKeeper and write it to the shared dict, while other processes read the data from the shared dict.

Signed-off-by: jiangdong <jiangdong@iflytek.com>
@Baoyuantop

Copy link
Copy Markdown
Contributor

Hi @dongjiang1989, following up on the previous review comments. Please let us know if you have any updates. Thank you.

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Feb 22, 2026
@Baoyuantop

Copy link
Copy Markdown
Contributor

Hi @dongjiang1989, following up on the previous review comments. Please let us know if you have any updates. Thank you.

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @dongjiang1989, thank you for the Zookeeper discovery implementation!

ZooKeeper integration has been requested by the community (#3231, #6687), so there's clear demand. However, at 1088 lines across 12 files, this is a substantial addition.

Key considerations:

  1. Maintenance burden: Adding a new discovery module means ongoing maintenance. Are you or your team willing to help maintain this long-term?
  2. Dependency: Does this introduce new Lua/C library dependencies? If so, they need to be added to .requirements.
  3. Rebase needed: This PR has been inactive for a while and likely has conflicts.
  4. Test completeness: Please ensure tests cover: connection failures, session expiry, node add/remove events, reconnection logic, and authentication (if supported).

If you're still actively working on this, please rebase and let us know. We'd need to evaluate the maintenance commitment before merging a new discovery module. Thank you!

@github-actions

Copy link
Copy Markdown

This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions Bot closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files. stale wait for update wait for the author's response in this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request help: how to use apisix with zookeeper service discovery

3 participants