-
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
Modernize AkkaSpec and Akka.Remote DotNetty transport settings #6854
Modernize AkkaSpec and Akka.Remote DotNetty transport settings #6854
Conversation
HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.tcp.connection-timeout", null); | ||
else if (enabledTransports.Contains("akka.remote.dot-netty.ssl")) | ||
HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.ssl.connection-timeout", null); | ||
HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.tcp.connection-timeout", TimeSpan.FromSeconds(15), allowInfinite:false); |
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.
Add default value to config value
else if (enabledTransports.Contains("akka.remote.dot-netty.ssl")) | ||
HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.ssl.connection-timeout", 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.
Removed akka.remote.dot-netty.ssl
, this HOCON path has not been used since 5 years ago
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.
LGTM
else | ||
HandshakeTimeout = config.GetTimeSpan("akka.remote.handshake-timeout", TimeSpan.FromSeconds(20), allowInfinite:false); | ||
HandshakeTimeout = config.GetTimeSpan("akka.remote.handshake-timeout", TimeSpan.FromSeconds(15), allowInfinite:false); |
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.
Change default value to 15 to reflect actual HOCON default
# necessary to keep backwards compatibility | ||
helios.tcp.transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote.Transport.Helios" |
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.
Moved to code since this causes bugs
ssl { | ||
certificate { | ||
# Valid certificate path required | ||
path = "" | ||
# Valid certificate password required | ||
password = "" | ||
# Default key storage flag is "default-key-set" | ||
# Available flags include: | ||
# default-key-set | exportable | machine-key-set | persist-key-set | user-key-set | user-protected | ||
# flags = [ "default-key-set" ] | ||
|
||
# To use a Thumbprint instead of a file, set this to true | ||
# And specify a thumbprint and it's storage location below | ||
use-thumbprint-over-file = false | ||
|
||
# Valid Thumbprint required (if use-thumbprint-over-file is true) | ||
# A typical thumbprint is a format similar to: "45df32e258c92a7abf6c112e54912ab15bbb9eb0" | ||
# On Windows machines, The thumbprint for an installed certificate can be located | ||
# By using certlm.msc and opening the certificate under the 'Details' tab. | ||
thumbprint = "" | ||
|
||
# The Store name. Under windows The most common option is "My", which indicates the personal store. | ||
# See System.Security.Cryptography.X509Certificates.StoreName for other common values. | ||
store-name = "" | ||
|
||
# Valid options : local-machine or current-user | ||
# current-user indicates a certificate stored under the user's account | ||
# local-machine indicates a certificate stored at an operating system level (potentially shared by users) | ||
store-location = "current-user" | ||
} | ||
suppress-validation = false | ||
} |
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.
Move the SSL configuration to its proper place
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.
LGTM
public sealed class DotNettySslSetup: Setup | ||
{ | ||
public DotNettySslSetup(X509Certificate2 certificate, bool suppressValidation) | ||
{ | ||
Certificate = certificate; | ||
SuppressValidation = suppressValidation; | ||
} | ||
|
||
public X509Certificate2 Certificate { get; } | ||
public bool SuppressValidation { get; } | ||
|
||
internal SslSettings Settings => new SslSettings(Certificate, SuppressValidation); | ||
} |
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.
This Setup
class allows users to inject X509Certificate2
instance directly
var heliosFallbackConfig = system.Settings.Config.GetConfig("akka.remote.helios.tcp") | ||
.WithFallback("transport-class = \"Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote.Transport.Helios\""); |
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.
Moved the hard coded HOCON settings from pidgeon.conf here, value only get added when necessary
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 still need to support Helios?
var setup = system.Settings.Setup.Get<DotNettySslSetup>(); | ||
var sslSettings = setup.HasValue ? setup.Value.Settings : null; | ||
Settings = DotNettyTransportSettings.Create(config, sslSettings); |
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.
Setup
class injection
/// <param name="BatchWriterSettings"> | ||
/// Used for performance-tuning the DotNetty channels to maximize I/O performance. | ||
/// </param> | ||
internal sealed record DotNettyTransportSettings( |
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.
Changed to record
, safe API change, internal
var setup = system.Settings.Setup.Get<DotNettySslSetup>(); | ||
var sslSettings = setup.HasValue ? setup.Value.Settings : null; | ||
return Create(config, sslSettings); |
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.
Setup
class injection
var host = config.GetString("hostname"); | ||
if (string.IsNullOrWhiteSpace(host)) | ||
host = IPAddress.Any.ToString(); | ||
|
||
var publicHost = config.GetString("public-hostname"); | ||
var publicPort = config.GetInt("public-port"); |
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 unnecessary default values
ServerSocketWorkerPoolSize: ComputeWorkerPoolSize(config.GetConfig("server-socket-worker-pool")), | ||
ClientSocketWorkerPoolSize: ComputeWorkerPoolSize(config.GetConfig("client-socket-worker-pool")), | ||
MaxFrameSize: ToNullableInt(config.GetByteSize("maximum-frame-size", null)) ?? 128000, | ||
Ssl: enableSsl ? SslSettings.CreateOrDefault(config.GetConfig("ssl"), sslSettings) : SslSettings.Empty, |
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.
the "ssl" path will always be present now since we fix the default HOCON.
floor: config.GetInt("pool-size-min", 2), | ||
scalar: config.GetDouble("pool-size-factor", 1.0), | ||
ceiling: config.GetInt("pool-size-max", 2)); |
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.
Add sensible default values
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.
LGTM
} | ||
namespace Akka.Remote.Transport.DotNetty | ||
{ | ||
public sealed class DotNettySslSetup : Akka.Actor.Setup.Setup |
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.
LGTM - need this for programmatic setup I take it.
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.
LGTM
else if (enabledTransports.Contains("akka.remote.dot-netty.ssl")) | ||
HandshakeTimeout = config.GetTimeSpan("akka.remote.dot-netty.ssl.connection-timeout", 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.
LGTM
ssl { | ||
certificate { | ||
# Valid certificate path required | ||
path = "" | ||
# Valid certificate password required | ||
password = "" | ||
# Default key storage flag is "default-key-set" | ||
# Available flags include: | ||
# default-key-set | exportable | machine-key-set | persist-key-set | user-key-set | user-protected | ||
# flags = [ "default-key-set" ] | ||
|
||
# To use a Thumbprint instead of a file, set this to true | ||
# And specify a thumbprint and it's storage location below | ||
use-thumbprint-over-file = false | ||
|
||
# Valid Thumbprint required (if use-thumbprint-over-file is true) | ||
# A typical thumbprint is a format similar to: "45df32e258c92a7abf6c112e54912ab15bbb9eb0" | ||
# On Windows machines, The thumbprint for an installed certificate can be located | ||
# By using certlm.msc and opening the certificate under the 'Details' tab. | ||
thumbprint = "" | ||
|
||
# The Store name. Under windows The most common option is "My", which indicates the personal store. | ||
# See System.Security.Cryptography.X509Certificates.StoreName for other common values. | ||
store-name = "" | ||
|
||
# Valid options : local-machine or current-user | ||
# current-user indicates a certificate stored under the user's account | ||
# local-machine indicates a certificate stored at an operating system level (potentially shared by users) | ||
store-location = "current-user" | ||
} | ||
suppress-validation = false | ||
} |
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.
LGTM
ActorSystemSetup
constructor variantChanges
AkkaSpec
injects_akkaSpecConfig
into theActorSystemSetup
ctor argumentDotNettyTransportSettings
:record
#nullable enable
Setup
support.DotNettySslSetup
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):