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

[UPDATED] Add kick leafnode client functionality #5527

Closed
wants to merge 3 commits into from

Conversation

n-holmstedt
Copy link

@n-holmstedt n-holmstedt commented Jun 12, 2024

I was looking for a way to rebalance LeafNodes client connections (k8s loadbalancing) and found the original #1556. I was informed at the slack that the KICK functionality in the API lacked the ability to kick leaf node connections.

  • Changed the KickClientReq struct to include client kind as per suggestion from slack.
  • Defaulted kind to "Client" to keep compability.
  • Added kind as an argument to server DisconnectClientByID
  • Fetched client based on kind before closing connection.

Tested functionality locally & ran tests without issues. Didn't get travis to work tho.

Signed-off-by: Niklas Holmstedt n.holmstedt@gmail.com

@n-holmstedt n-holmstedt requested a review from a team as a code owner June 12, 2024 12:42
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

I wonder if we should just keep the external API the same and if we fail looking up via the client list just check the leafnode list?

@derekcollison derekcollison requested review from jnmoyne and removed request for levb June 12, 2024 13:20
@derekcollison
Copy link
Member

I also think it should work on leafnodes.

Want some input from @ripienaar and @jnmoyne

@n-holmstedt
Copy link
Author

I wonder if we should just keep the external API the same and if we fail looking up via the client list just check the leafnode list?

This was my initial thought as well, i might have misunderstood @ripienaar suggestions tho.

@ripienaar
Copy link
Contributor

There is a risk since IDs are not somehow unique

CID 10 could be there. I aim for it but it disconnects before I kick it and then I disconnect LID 10

@derekcollison
Copy link
Member

They are all unique..

@ripienaar
Copy link
Contributor

They are all unique..

Hmm, ok so if one server cannot have cid:10 and lid:10 at the same time then that's fine then, was not aware

@derekcollison
Copy link
Member

derekcollison commented Jun 12, 2024

All ids are monotonic and come from same server variable under lock, so yes you can never have an id, whether CID, LID, RID or GID overlap or repeat..

@ripienaar
Copy link
Contributor

Great, then yeah lets do as Derek suggest with trying one after the other

@n-holmstedt
Copy link
Author

Updated the PR with the fallback to kicking leafnode client if a client id doesn't exist.

Copy link
Contributor

@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, I suspect the team might want a test or the existing one expanded.

@derekcollison derekcollison self-requested a review June 13, 2024 11:33
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

Let's add a test and also update the PR description which is no longer correct.

Thanks.

@derekcollison
Copy link
Member

Any updates here?

derekcollison added a commit that referenced this pull request Jun 24, 2024
Kick was designed for any client connection but was intended to also
work on leafnodes. This allows for rebalancing etc.

Resolves: #1556 #5527 

Signed-off-by: Derek Collison <derek@nats.io>
@derekcollison
Copy link
Member

Closing in favor of #5587

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.

3 participants