Skip to content

modify balancer.lua to solve issue that discovery Eureka cannot autom… #2793

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

Closed
wants to merge 1 commit into from

Conversation

Hmemories
Copy link

…atically proxy to a new node

What this PR does / why we need it:

to solve issue that discovery Eureka cannot automatically proxy to a new node #1838

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
    When we are getting the cached data, if we match "key" with the data"md5" of up_conf.nodes, we can find the changes of the service.
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible?

@tokers
Copy link
Contributor

tokers commented Nov 20, 2020

@Hmemories CI run is failed, please take a look :).

@tokers
Copy link
Contributor

tokers commented Nov 20, 2020

@Hmemories Missing test cases.

@@ -218,8 +219,9 @@ local function pick_server(route, ctx)
if checker then
version = version .. "#" .. checker.status_ver
end
local cache_key = key..ngx.md5(up_conf.nodes)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: need space on both left and right side of ...

Copy link
Contributor

Choose a reason for hiding this comment

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

The argument type of ngx.md5 is string while up_conf.nodes is an array-like table.

BTW, i don't think calculating the md5sum of nodes is a good way to differentiate the version, it's heavy, what about introducing the version mechanism for up_conf.nodes, either version number or last modify time is OK.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or settling for the second best, just use the up_conf.version.

Copy link
Author

Choose a reason for hiding this comment

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

嗯嗯,我准备在看看,这部分代码已经被我是用在了生产环境我在考虑有没有好的方式优化它

Copy link
Author

Choose a reason for hiding this comment

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

如果md5比较重的话,hash是不是也可以

Copy link
Member

Choose a reason for hiding this comment

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

md5 is good to me

@moonming
Copy link
Member

moonming commented Jan 5, 2021

@Hmemories it will be perfect if you can add test cases

@membphis
Copy link
Member

ping @Hmemories

@github-actions
Copy link

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 Aug 26, 2021
@github-actions
Copy link

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 Sep 24, 2021
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.

4 participants