-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add ClusterClient initial contact discovery feature #7260
Add ClusterClient initial contact discovery feature #7260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self review
use-initial-contacts-discovery = false | ||
|
||
discovery | ||
{ | ||
method = <method> | ||
actor-system-name = null | ||
receptionist-name = receptionist | ||
service-name = null | ||
port-name = null | ||
discovery-retry-interval = 1s | ||
discovery-timeout = 60s | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New discovery options
|
||
discovery | ||
{ | ||
method = <method> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If method is null, empty, whitespace, or "<method>" (not set), we'll use the default akka.discovery.method value. If that value also not set, we fall back to "config" method.
discovery | ||
{ | ||
method = <method> | ||
actor-system-name = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if "actor-system-name" is null or whitespace, we fall back to ActorSystem.Name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to log a warning when this happens? Kind of seems like the user should have to specify this value given that these are two separate applications communicating typically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea, I'll do that
_log.Debug($"Config discovery serving: {string.Join(", ", _resolvedServices.Values)}"); | ||
} | ||
|
||
public bool TryRemoveEndpoint(string serviceName, ResolvedTarget target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this so we can add and remove new discovery entry during runtime, used for MNTR testing.
return true; | ||
} | ||
|
||
public bool TryAddEndpoint(string serviceName, ResolvedTarget target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this so we can add and remove new discovery entry during runtime, used for MNTR testing.
@@ -419,7 +607,8 @@ private bool Establishing(object message) | |||
} | |||
else | |||
{ | |||
// ok, use another instead | |||
// prune out actors that failed to be identified | |||
PruneContacts((string) actorIdentify.MessageId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead contact detection, remove the dead contact if it doesn't respond to Identify
@@ -390,16 +578,16 @@ private bool Establishing(object message) | |||
|
|||
switch (message) | |||
{ | |||
case DeadLetter { Message: ClusterReceptionist.GetContacts } dl: | |||
PruneContacts(dl.Recipient.Path.Address.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead contact detection, remove contact from contact list if GetContacts
were redirected to DeadLetters
case ActorIdentity actorIdentify: | ||
// prune out actors that failed to be identified | ||
if (actorIdentify.Subject is null) | ||
PruneContacts((string) actorIdentify.MessageId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continue removal of dead contacts if it doesn't respond to Identify
return true; | ||
|
||
case ClusterReceptionist.ReceptionistShutdown: | ||
{ | ||
if (receptionist.Equals(Sender)) | ||
{ | ||
_log.Info("Receptionist [{0}] is shutting down, reestablishing connection", receptionist); | ||
PruneContacts(Sender.Path.Address.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the receptionist from the contact list if it is shut down
if(_initialContactsSelections.Count == 0 && _contacts.Count == 0) | ||
Rediscover(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch to discovery state if we ran out of contacts in the contact list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me but I did leave some questions for you
...ntrib/cluster/Akka.Cluster.Tools.Tests.MultiNode/ClusterClient/ClusterClientDiscoverySpec.cs
Outdated
Show resolved
Hide resolved
src/contrib/cluster/Akka.Cluster.Tools.Tests/ClusterClient/ClusterClientConfigSpec.cs
Show resolved
Hide resolved
return true; | ||
|
||
case ClusterReceptionist.Contacts: | ||
// ignored, we're re-discovering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we ignore this - does this message contain any valid contacts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could incorporate the result with the possible future discovery result, but this is risky because we're already inside the discovery phase. If there's suddenly a Contacts
message coming when we're in this state, that means something is seriously wrong with the network / configuration and there could be a possible split-brain happening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't care about split brains in this scenario though - the client just needs 1 node to talk to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as someone is answering the phone, that's good enough.
discovery | ||
{ | ||
method = <method> | ||
actor-system-name = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to log a warning when this happens? Kind of seems like the user should have to specify this value given that these are two separate applications communicating typically.
Superceeded by #7261 |
Fixes #7243
Changes
Add ClusterClient initial contact discovery feature