fix(grpc-data): X0 inert all-unknown export rule no longer lowers the principal's limits; ValidateDeployed doc
This commit is contained in:
@@ -23,9 +23,10 @@ public static class DataConnectionValidator
|
||||
/// Node-side re-validation of an already-deployed artifact (artifact parse, origin catalog compile). Identical to
|
||||
/// <see cref="Validate(DraftSnapshot)"/> except that operation bits outside <see cref="DataOperationSets.Understood"/>
|
||||
/// 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. The understood subset is still validated (a row must be non-empty;
|
||||
/// a mapping may not grant an understood operation its connection lacks), and every consumer of the rows masks the
|
||||
/// rest away, so an unknown bit grants nothing (fail closed).
|
||||
/// down every data connection/export on the node. The understood subset is still validated (a mapping may not grant
|
||||
/// an understood operation its connection lacks), and every consumer of the rows masks the rest away, so an unknown bit
|
||||
/// grants nothing (fail closed). A row must carry SOME bit (zero is still invalid), but it may carry only unknown
|
||||
/// bits: such a row is kept and grants nothing.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<ValidationError> ValidateDeployed(DraftSnapshot draft) => Validate(draft, deployed: true);
|
||||
|
||||
|
||||
@@ -182,7 +182,10 @@ public sealed partial class LocalExportCatalog
|
||||
|
||||
internal DataLimits LimitsFor(string principal, DataLimits limits)
|
||||
{
|
||||
var rules = _exports.Where(x => string.Equals(x.Principal, principal, StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
// An inert rule (X0: only operation bits this build does not implement) grants nothing, so it cannot lower the
|
||||
// principal's limits on its other exports either.
|
||||
var rules = _exports.Where(x => string.Equals(x.Principal, principal, StringComparison.OrdinalIgnoreCase)
|
||||
&& x.Operations != DataOperations.None).ToArray();
|
||||
return rules.Length == 0 ? limits : limits with
|
||||
{
|
||||
MaxBatchItems = Math.Min(limits.MaxBatchItems, rules.Min(x => x.Batch)),
|
||||
|
||||
+29
@@ -140,6 +140,35 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
catalog.ExportOperations("other").ShouldBe(DataOperations.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void An_inert_all_unknown_export_does_not_lower_the_principals_limits_on_its_other_exports()
|
||||
{
|
||||
using var fixture = new LocalDataFixture();
|
||||
var snapshot = new DraftSnapshot
|
||||
{
|
||||
GenerationId = 1, ClusterId = "cluster",
|
||||
ServerClusters = [new() { ClusterId = "cluster", Name = "Cluster", Enterprise = "Enterprise", Site = "Site", CreatedBy = "test", RedundancyMode = RedundancyMode.None }],
|
||||
RawFolders = [new() { RawFolderId = "folder", ClusterId = "cluster", Name = "Plant" }],
|
||||
DataExports =
|
||||
[
|
||||
new() { DataExportId = "live", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Raw, RootKind = "Cluster",
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.Browse | DataOperations.Read,
|
||||
MaxBatchItems = 100, MaxPageItems = 100, MaxMonitoredItems = 100, MaxStreams = 10 },
|
||||
new() { DataExportId = "future-only", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = "Cluster",
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.HistoryRead | (DataOperations)(1 << 30),
|
||||
MaxBatchItems = 1, MaxPageItems = 1, MaxMonitoredItems = 1, MaxStreams = 1 },
|
||||
],
|
||||
};
|
||||
var catalog = LocalExportCatalog.Compile(snapshot, fixture.Serving, fixture.Activation.CaptureAuthority());
|
||||
var limits = new DataLimits(1000, 1000, 1_000_000, 1000, 100, 1_000_000, TimeSpan.FromSeconds(15), TimeSpan.FromHours(1), TimeSpan.FromMinutes(1));
|
||||
var effective = catalog.LimitsFor("peer", limits);
|
||||
effective.MaxBatchItems.ShouldBe(100);
|
||||
effective.MaxPageItems.ShouldBe(100);
|
||||
effective.MaxMonitoredItems.ShouldBe(100);
|
||||
effective.MaxStreams.ShouldBe(10);
|
||||
catalog.ExportOperations("peer").ShouldBe(DataOperations.Browse | DataOperations.Read);
|
||||
}
|
||||
|
||||
private static async Task<DataOperations> Lease(DataConnectionDeploymentRuntime runtime, string id)
|
||||
{
|
||||
DataConnectionDeploymentLease? lease = null;
|
||||
|
||||
Reference in New Issue
Block a user