fix(secrets): hub push sweep isolates each row (scadaproj#45)
Secrets-008: SqlServerSecretSyncService.SweepAsync now catches a per-row push failure, logs it (EventId 4, name only) and continues, like the pull side. One row the hub refuses (a >450-char name, an over-long explicit KEK id) no longer stops every later name from reaching the hub. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
+25
-3
@@ -108,9 +108,25 @@ public sealed partial class SqlServerSecretSyncService : BackgroundService
|
||||
|
||||
foreach (StoredSecret row in rows)
|
||||
{
|
||||
// Verbatim, like the replicator — the hub records the originating node's revision.
|
||||
await _hub.ApplyReplicatedAsync(row, ct).ConfigureAwait(false);
|
||||
pushed++;
|
||||
try
|
||||
{
|
||||
// Verbatim, like the replicator — the hub records the originating node's revision.
|
||||
await _hub.ApplyReplicatedAsync(row, ct).ConfigureAwait(false);
|
||||
pushed++;
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Isolated per row, like the pull side (SecretReplicationReconciler.ApplyAsync).
|
||||
// The push set is recomputed in the same name order every interval, so one row the
|
||||
// hub refuses (a name longer than its NVARCHAR(450) column, an over-long explicit
|
||||
// KEK id) would otherwise stop every name sorting after it from ever reaching the
|
||||
// hub. Log it and keep going; it is retried every sweep.
|
||||
LogPushRowFailed(ex, row.Name.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,4 +171,10 @@ public sealed partial class SqlServerSecretSyncService : BackgroundService
|
||||
Level = LogLevel.Warning,
|
||||
Message = "Discarding replicated secret row {SecretName} that could not be applied locally; the rest of the batch continues.")]
|
||||
private partial void LogRowDiscarded(Exception exception, string secretName);
|
||||
|
||||
[LoggerMessage(
|
||||
EventId = 4,
|
||||
Level = LogLevel.Warning,
|
||||
Message = "The hub refused secret row {SecretName} on push; the rest of the sweep continues and the row is retried next interval.")]
|
||||
private partial void LogPushRowFailed(Exception exception, string secretName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user