fleet: require a minimum version of the peer at the handshake [CI]
MoShiro__MinAgentVersion makes the backend refuse agents below it at hello (fleet_version_required); fleet.min_server_version or MOSHIRO_MIN_SERVER_VERSION makes the agent drop a backend below it. Either side waits five seconds and shakes hands again, because the other one may be updating.
This commit is contained in:
1 parent
fb3a9c260f
commit
5822285a88
16 files changed
+266
-7
No files matched your search
@@ -16,6 +16,7 @@ public static class GatewayServiceCollectionExtensions
|
||||
public static IServiceCollection AddMoShiroGateway(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IAgentGateway, FleetGateway>();
|
||||
services.AddSingleton<IFleetVersionPolicy, BackendVersionPolicy>();
|
||||
services.AddHostedService<ConnectionShutdown>();
|
||||
services.AddFleetEnrollment();
|
||||
services.AddFleetServer(options => options.NodeIdPrefix = AgentIds.Prefix)
|
||||
@@ -44,3 +45,11 @@ public static class GatewayServiceCollectionExtensions
|
||||
(context, parameters, ct) => services.GetRequiredService<TestService>().OnStatusAsync(context.Node.Id, parameters, ct));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>握手时的版本要求:告诉 Agent 面板的版本,并要求 Agent 不低于配置的最低版本。</summary>
|
||||
internal sealed class BackendVersionPolicy(BackendOptions options) : IFleetVersionPolicy
|
||||
{
|
||||
public string? ServerVersion => BuildInfo.Version;
|
||||
|
||||
public string? MinNodeVersion => string.IsNullOrWhiteSpace(options.MinAgentVersion) ? null : options.MinAgentVersion;
|
||||
}
|
||||
Reference in new issue
Block a user