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

Update Discovery.Azure to support multi-config #2595

Merged

Conversation

Arkatufus
Copy link
Contributor

@Arkatufus Arkatufus commented Jun 25, 2024

Changes

  • Add ability to make the plugin read-only. A read-only plugin does not participate in updating the Azure table entries.
  • Add Akka.Hosting support
  • Add multi-config support
    • Make discovery plugin id configurable (was hardcoded)
    • Automatically generate default config fallback for each named discovery id
    • Only plugin with IsDefaultPlugin set to true will be used as akka.discovery.method value

@Arkatufus Arkatufus marked this pull request as draft June 25, 2024 21:06
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.

Left some thoughts

@@ -66,6 +68,7 @@ public void SettingsWithOverrideTest()
var uri = new Uri("https://whatever.com");
var credential = new DefaultAzureCredential();
var settings = AzureDiscoverySettings.Empty
.WithReadOnlyMode(true)
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense - there haven't been any use cases before now where we needed read-only.

failure: e => new DiscoveryStopFailed(sender, e));
Become(Stopping);

if (!_readOnly)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@@ -123,11 +128,17 @@ public static class AkkaHostingExtensions
TableClientOptions? tableClientOptions = null,
string? serviceName = null,
string? publicHostname = null,
int? publicPort = null)
int? publicPort = null,
string discoveryId = "azure",
Copy link
Member

Choose a reason for hiding this comment

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

What does discoveryId mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discovery Id is the HOCON configuration key the final HOCON settings will live in. For example, "azure" the default Id will be placed in "akka.discovery.azure", just like how Akka.Persistence journal Id works. This will allow it to be addressed and loaded by the Akka.Discovery plugin later on.


public static class Extensions
{
public static Configuration.Config MoveTo(this Configuration.Config config, string path)
Copy link
Member

Choose a reason for hiding this comment

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

Can this be made internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

int? publicPort = null,
string discoveryId = "azure",
bool? readOnly = null,
bool isDefaultPlugin = true)
Copy link
Member

Choose a reason for hiding this comment

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

An idea: what if we just used the service-name to alias the HOCON settings, so there's only one moving thing that needs to be tracked? This way, we don't even need to worry about default plugins et al.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That works, but that will break previous behavior.

Copy link
Member

Choose a reason for hiding this comment

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

That would probably be ok as long as we had some way of covering the default case from before

_system.Settings.InjectTopLevelFallback(DefaultConfig);
_settings = AzureDiscoverySettings.Create(system);
var fullConfig = config.WithFallback(DefaultConfig.GetConfig("akka.discovery.azure"));
_settings = AzureDiscoverySettings.Create(system, fullConfig);

var setup = _system.Settings.Setup.Get<AzureDiscoverySetup>();
Copy link
Contributor Author

@Arkatufus Arkatufus Jun 26, 2024

Choose a reason for hiding this comment

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

@Aaronontheweb This line is currently problematic, a single registered AzureDiscoverySetup instance can pollute every instance of this ServiceDiscovery instance. Would need to look at how Akka.Persistence handles this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this using a hack by embedding the discovery id inside the Akka.Hosting generated HOCON config. We can map/corellate which config goes to which setup class this way.

@Arkatufus Arkatufus marked this pull request as ready for review June 27, 2024 14:10
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.

For a real release we'll need to add documentation for these features, but since we're beta-testing them I'm fine shipping as is

// We're going to cheat and embed the config path/discovery id here
// because we need to correlate the setup files with the config
// during run-time
sb.AppendLine($"discovery-id = {ConfigPath}");
Copy link
Member

Choose a reason for hiding this comment

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

LGTM


namespace Akka.Discovery.Azure;

internal sealed class AzureDiscoveryMultiSetup : Setup
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is internal because it's only accessible via Akka.Hosting

# If set to true, the extension will not participate in updating the Azure table.
# Only need to be set to true if the extension is being used by a read only extension
# such as ClusterClient contact discovery.
read-only = false
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) June 27, 2024 14:36
@Aaronontheweb Aaronontheweb merged commit 1d3b408 into akkadotnet:dev Jun 27, 2024
3 checks passed
@Arkatufus Arkatufus deleted the update-discovery-azure-for-multi-config branch July 15, 2024 20:33
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