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

(#596) Update balancer to use Placement preferred #612

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

ploubser
Copy link
Collaborator

Here we update the balancer to use the Placement api in 2.11.

The balancer will now explicitly try to rebalance by setting the 'preferred' placement value to servers who lead less than the even distribution.

We limit this functionality to server version 2.11.0 since preferred placement was not available before then.

const SERVER_VERSION = "v2.11.0"

func checkServerVersion(nc *nats.Conn) error {
version := nc.ConnectedServerVersion()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather use this and look for api level 1

func (m *Manager) MetaApiLevel(refresh bool) (int, error) {

We don’t know what version the meta leader is - the connection machine might be different.

API level checks talk to the machine that is jetstream leader so more reliable.

1 means 2.11

return updated, err
}
}
if apiLvl != 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

check for < 1 as 2.12 might be level 2 etc, each time we add a major API change it would be incremented

Copy link
Collaborator

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

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

LGTM!

Here we update the balancer to use the Placement api in 2.11.

The balancer will now explicitly try to rebalance by setting
the 'preferred' placement value to servers who lead less than
the even distribution.

We limit this functionality to server version 2.11.0 since
preferred placement was not available before then.
@ripienaar ripienaar merged commit 4933286 into nats-io:main Jan 16, 2025
2 checks passed
@ripienaar
Copy link
Collaborator

nice one, thanks

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