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

Bug fixes and API client experience enhancements #28

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Ephron-WL
Copy link

Bugs:

  1. Implemented idleRun fix so that idle will occur in OnRunLoop
  2. FindMajorityReplicatedIndex now calculates the majority match index when the cluster is degraded. Previously, when degraded the ReplicationStateByNode count was lower than needed to result in the necessary majority match index value.

API Client Experience:

In cases were nodes fail and in cases where nodes are recreated by Kubernetes, calls to Increment might return null and HTTP status 204. This may occur because of one of four types of exceptions that may be thrown when requests are being received during state synchronization. The below changes were made to attempt to notify the client of the reason the API call failed so that the client can 1) understand the issue and 2) handle the issue.

  1. ClusterLeaderRequestDelegatingMiddleware returns a 503 and the ClusterException message.
  2. RaftLeaderState and RequestDelegatingClient convert certain exceptions to a ClusterException that will propagate back to the client.

}
catch (Exception ex)
{
if(ex is ClusterException)
Copy link
Owner

Choose a reason for hiding this comment

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

Please reformat the code. There should be an .editorconfig on the repository.

Copy link
Author

Choose a reason for hiding this comment

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

While your .editorconfig is in the solution, it isn't catching the formatting issue. I assume you mean the space after "if".?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, correct (the space is missing after if).

Sorry for the late response here.

await _requestDelegatingClient.Delegate(context.Request, context.Response, leaderAddress, localPort: context.Connection.LocalPort);
return;
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
context.Response.ContentType = "application/json";
Copy link
Owner

Choose a reason for hiding this comment

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

return;
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
context.Response.ContentType = "application/json";
string payload = JsonSerializer.Serialize(new { ex.Message, ExceptionType = ex.GetType().Name });
Copy link
Owner

Choose a reason for hiding this comment

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

var is the preferred code style

context.Response.ContentType = "application/json";
string payload = JsonSerializer.Serialize(new { ex.Message, ExceptionType = ex.GetType().Name });
context.Response.ContentLength = payload.Length;
await context.Response.WriteAsync(payload);
Copy link
Owner

Choose a reason for hiding this comment

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

Wondering of you forgot top add return.
Just clarifying it we truly want to rethrow when the response is already provided here.


response.StatusCode = (int)delegatedResponse.StatusCode;
if(delegatedResponse.StatusCode == System.Net.HttpStatusCode.NoContent)
Copy link
Owner

Choose a reason for hiding this comment

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

Reformat please

@zarusz
Copy link
Owner

zarusz commented Jan 16, 2025

Hey @Ephron-WL,

Please add a signed-off statement to every commit.
Also once you're done, please squash all your commits into one.

Thanks for your contribution.

@zarusz zarusz mentioned this pull request Jan 16, 2025
@zarusz
Copy link
Owner

zarusz commented Jan 27, 2025

@Ephron-WL let me know if something is unclear, or if you waiting on me here. Just checking.

@Ephron-WL
Copy link
Author

Ephron-WL commented Jan 30, 2025 via email

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