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

Add ClusterClient initial contact discovery feature #7260

Closed

Conversation

Arkatufus
Copy link
Contributor

Fixes #7243

Changes

Add ClusterClient initial contact discovery feature

Copy link
Contributor Author

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

self review

Comment on lines +98 to +109
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
}
Copy link
Contributor Author

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>
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Contributor Author

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)
Copy link
Contributor Author

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);
Copy link
Contributor Author

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());
Copy link
Contributor Author

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

Comment on lines 696 to 699
case ActorIdentity actorIdentify:
// prune out actors that failed to be identified
if (actorIdentify.Subject is null)
PruneContacts((string) actorIdentify.MessageId);
Copy link
Contributor Author

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());
Copy link
Contributor Author

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

Comment on lines 748 to 749
if(_initialContactsSelections.Count == 0 && _contacts.Count == 0)
Rediscover();
Copy link
Contributor Author

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

@Arkatufus Arkatufus marked this pull request as draft June 20, 2024 18:20
@Arkatufus Arkatufus marked this pull request as ready for review June 21, 2024 13:08
Copy link
Member

@Aaronontheweb Aaronontheweb left a 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

return true;

case ClusterReceptionist.Contacts:
// ignored, we're re-discovering
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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.

@Arkatufus
Copy link
Contributor Author

Superceeded by #7261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Akka.Discovery to be used with Akka.Cluster.Tools.ClusterClient
2 participants