fix(grpc-data): X0 node-side re-validation tolerates only the reserved bits; runtime logger via init property
P02 GrpcDataArtifactReadTests pins an arbitrary bit (1<<30) as a malformed row that fails closed; keep that and tolerate only DataOperationSets.Reserved. P07 GrpcDataHotRouteContinuityTests reflects over the runtime constructor shape, so the logger moves from a ctor parameter to an init property.
This commit is contained in:
@@ -21,9 +21,10 @@ public static class DataConnectionValidator
|
||||
|
||||
/// <summary>
|
||||
/// Node-side re-validation of an already-deployed artifact (artifact parse, origin catalog compile). Identical to
|
||||
/// <see cref="Validate(DraftSnapshot)"/> except that operation bits this build does not understand are IGNORED
|
||||
/// rather than rejected (X0 tolerant reader): a newer central may author them, and rejecting would take down every
|
||||
/// data connection/export on the node. Each consumer of the rows keeps only the bits it understands (fail closed).
|
||||
/// <see cref="Validate(DraftSnapshot)"/> except that the X0-RESERVED operation bits (<see cref="DataOperationSets.Reserved"/>)
|
||||
/// are IGNORED rather than rejected: a newer central may author them, and rejecting would take down every data
|
||||
/// connection/export on the node. Each consumer of the rows keeps only the bits it understands (fail closed). A bit
|
||||
/// outside both sets is still a malformed row (nothing can author it).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<ValidationError> ValidateDeployed(DraftSnapshot draft) => Validate(draft, deployed: true);
|
||||
|
||||
@@ -33,8 +34,8 @@ public static class DataConnectionValidator
|
||||
var errors = new List<ValidationError>();
|
||||
void Add(string code, string id, string message) => errors.Add(new(code, message, id));
|
||||
bool Same(string? a, string? b) => Ids.Equals(a, b);
|
||||
bool ValidOps(DataOperations operations) => operations != DataOperations.None &&
|
||||
(deployed || (operations & ~KnownOperations) == 0);
|
||||
var accepted = deployed ? KnownOperations | DataOperationSets.Reserved : KnownOperations;
|
||||
bool ValidOps(DataOperations operations) => operations != DataOperations.None && (operations & ~accepted) == 0;
|
||||
DataOperations Understood(DataOperations operations) => deployed ? operations & DataOperationSets.Understood : operations;
|
||||
bool NodesValid(IEnumerable<string> ids, string owner)
|
||||
{
|
||||
|
||||
@@ -212,7 +212,11 @@ public static class DataConnectionRegistration
|
||||
var eligible = state.Generation > 0 && Enum.TryParse<RedundancyRole>(state.Role, out var actual)
|
||||
&& DataConnectionRoleAdapter.MayAcquire(mode, state.WarmRole, actual);
|
||||
return new DataConnectionConsumerRoleSnapshot(mode, eligible, state.Generation);
|
||||
}, logger: sp.GetService<Microsoft.Extensions.Logging.ILoggerFactory>()?.CreateLogger<DataConnectionDeploymentRuntime>());
|
||||
})
|
||||
{
|
||||
Logger = (Microsoft.Extensions.Logging.ILogger?)sp.GetService<Microsoft.Extensions.Logging.ILoggerFactory>()?.CreateLogger<DataConnectionDeploymentRuntime>()
|
||||
?? Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance,
|
||||
};
|
||||
return runtime;
|
||||
});
|
||||
services.AddSingleton(sp =>
|
||||
|
||||
+4
-4
@@ -49,7 +49,8 @@ public sealed class DataConnectionDeploymentRuntime : IAsyncDisposable
|
||||
UnknownOperationsCounterName, unit: "{row}",
|
||||
description: "Data-connection rows carrying operation bits this node does not understand; the bits were dropped (no grant).");
|
||||
private readonly object _sync = new();
|
||||
private readonly ILogger _log;
|
||||
/// <summary>Diagnostics sink for the X0 dropped-operation warning; optional (an init property keeps the constructor shape).</summary>
|
||||
public ILogger Logger { private get; init; } = NullLogger.Instance;
|
||||
private IReadOnlyDictionary<string, DataOperations> _droppedOperations = new Dictionary<string, DataOperations>();
|
||||
private long _unknownOperationRows;
|
||||
private readonly string _node, _owner;
|
||||
@@ -76,9 +77,8 @@ public sealed class DataConnectionDeploymentRuntime : IAsyncDisposable
|
||||
public DataConnectionDeploymentRuntime(string nodeId, string ownerCluster, IDataConnectionSecurityProvider security,
|
||||
IDataConnectionScopeActivator scopeActivator, int maxConnections, TimeProvider? clock = null,
|
||||
Func<bool>? consumerMayAcquire = null, bool useCompactBatches = true,
|
||||
Func<RedundancyMode, DataConnectionConsumerRoleSnapshot?>? consumerRoleSnapshot = null, ILogger? logger = null)
|
||||
Func<RedundancyMode, DataConnectionConsumerRoleSnapshot?>? consumerRoleSnapshot = null)
|
||||
{
|
||||
_log = logger ?? NullLogger.Instance;
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(nodeId); ArgumentException.ThrowIfNullOrWhiteSpace(ownerCluster);
|
||||
if (maxConnections <= 0) throw new ArgumentOutOfRangeException(nameof(maxConnections));
|
||||
_node = nodeId; _owner = ownerCluster; _security = security ?? throw new ArgumentNullException(nameof(security));
|
||||
@@ -226,7 +226,7 @@ public sealed class DataConnectionDeploymentRuntime : IAsyncDisposable
|
||||
foreach (var (id, bits) in dropped)
|
||||
{
|
||||
UnknownOperationsCounter.Add(1);
|
||||
_log.LogWarning("Data connection {DataConnectionId} in artifact {ArtifactRevision} grants operation bits {UnknownOperations} " +
|
||||
Logger.LogWarning("Data connection {DataConnectionId} in artifact {ArtifactRevision} grants operation bits {UnknownOperations} " +
|
||||
"this node does not implement; they were dropped (no grant). Upgrade this node before relying on them.",
|
||||
id, revision, (int)bits);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user