Skip to content

Commit

Permalink
fix: ReusePorts (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngruelaneo authored Jul 1, 2024
2 parents 0d68ee2 + 4f34b4c commit dfc47b1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArmoniK.Api.Client" Version="3.18.0" />
<PackageReference Include="ArmoniK.Api.Client" Version="3.18.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
Expand Down
24 changes: 23 additions & 1 deletion Client/src/Common/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class Properties
private const string SectionProxy = "Proxy";
private const string SectionProxyUsername = "ProxyUsername";
private const string SectionProxyPassword = "ProxyPassword";
private const string SectionReusePorts = "ReusePorts";

private const string SectionRetryInitialBackoff = "RetryInitialBackoff";
private const string SectionRetryBackoffMultiplier = "RetryBackoffMultiplier";
Expand Down Expand Up @@ -127,6 +128,10 @@ public Properties(TaskOptions options,
/// <param name="retryInitialBackoff">Initial retry backoff delay</param>
/// <param name="retryBackoffMultiplier">Retry backoff multiplier</param>
/// <param name="retryMaxBackoff">Max retry backoff</param>
/// <param name="proxy">Proxy configuration</param>
/// <param name="proxyUsername">Username used for proxy authentication</param>
/// <param name="proxyPassword">Password used for proxy authentication</param>
/// <param name="reusePorts">Enable the option SO_REUSE_UNICASTPORT upon socket opening to limit port exhaustion</param>
/// <exception cref="ArgumentException"></exception>
public Properties(IConfiguration configuration,
TaskOptions options,
Expand All @@ -143,7 +148,8 @@ public Properties(IConfiguration configuration,
TimeSpan retryMaxBackoff = new(),
string? proxy = null,
string? proxyUsername = null,
string? proxyPassword = null)
string? proxyPassword = null,
bool? reusePorts = null)
{
TaskOptions = options;
Configuration = configuration;
Expand Down Expand Up @@ -195,6 +201,17 @@ public Properties(IConfiguration configuration,
Proxy = proxy ?? sectionGrpc[SectionProxy] ?? string.Empty;
ProxyUsername = proxyUsername ?? sectionGrpc[SectionProxyUsername] ?? string.Empty;
ProxyPassword = proxyPassword ?? sectionGrpc[SectionProxyPassword] ?? string.Empty;
ReusePorts = reusePorts ?? sectionGrpc[SectionReusePorts]
?.ToLower() switch
{
null or "" => true,
"true" or "yes" or "enable" => true,
"false" or "no" or "disable" => false,
#pragma warning disable CA2208
var val => throw new ArgumentException($"\"{val}\" is not a valid boolean",
SectionReusePorts),
#pragma warning restore CA2208
};

if (retryInitialBackoff != TimeSpan.Zero)
{
Expand Down Expand Up @@ -393,4 +410,9 @@ public string ConnectionString
/// Password for the proxy
/// </summary>
public string ProxyPassword { get; set; }

/// <summary>
/// Enable the option SO_REUSE_UNICASTPORT upon socket opening to limit port exhaustion
/// </summary>
public bool ReusePorts { get; set; }
}
1 change: 1 addition & 0 deletions Client/src/Common/Submitter/ClientServiceConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static ObjectPool<GrpcChannel> ControlPlaneConnectionPool(Properties
Proxy = properties.Proxy,
ProxyUsername = properties.ProxyUsername,
ProxyPassword = properties.ProxyPassword,
ReusePorts = properties.ReusePorts,
};

return new ObjectPool<GrpcChannel>(ct => new ValueTask<GrpcChannel>(GrpcChannelFactory.CreateChannel(options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArmoniK.Api.Common" Version="3.18.0" />
<PackageReference Include="ArmoniK.Api.Common" Version="3.18.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ArmoniK.Api.Worker" Version="3.18.0" />
<PackageReference Include="ArmoniK.Api.Worker" Version="3.18.1" />
<PackageReference Include="AWSSDK.S3" Version="3.7.106.1" />
<!-- AWSSDK.SecurityToken is used by AWSSDK.S3 to automatically get credentials from pod secrets -->
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.103.16" />
Expand Down

0 comments on commit dfc47b1

Please sign in to comment.