fix(deploy): #1107 re-send the deploy dispatch to nodes that have not acked
ConfigPublishCoordinator dispatched a deployment exactly once: on DPS a node whose deployments registry entry had not gossiped to central missed it (#1106), on gRPC a failed dial was dropped, and either way the deployment timed out at 120 s. Coordinator: re-sends the same DispatchDeployment at +5/+15/+35 s (bounded by half the remaining deadline) with the new additive TargetNodes naming only expected nodes whose ack has not arrived (an ack still being persisted counts). Stops on last ack, completion, time-out, supersede or schedule end; a recovered in-flight deployment gets the same re-send. Counter otopcua.deploy.redispatched. Transport: CentralCommunicationActor's gRPC fan dials only the named nodes; proto gains repeated target_nodes = 4 (additive). On DPS, non-addressed nodes ignore the re-send. Node (DriverHostActor): a re-send is idempotent per DeploymentId — ignored if not addressed here or mid-apply; ANY copy of a deployment whose Applied ack is held on the address-space outcome no longer starts a second apply; a re-send of a deployment it already acked re-delivers the remembered ack (last 16) instead of re-applying (#601 would otherwise re-apply a degraded revision). Original dispatches are unchanged. Docs: Redundancy.md §Dispatch re-send, Configuration.md, cluster-topology rule.
This commit is contained in:
@@ -7,7 +7,32 @@ namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Deploy;
|
||||
/// <c>DriverHostActor</c>. Tells the node to fetch the deployment artifact identified by
|
||||
/// <paramref name="DeploymentId"/> + <paramref name="RevisionHash"/> and apply it.
|
||||
/// </summary>
|
||||
/// <param name="DeploymentId">The deployment to apply.</param>
|
||||
/// <param name="RevisionHash">The revision (SHA-256 of the artifact bytes) the deployment carries.</param>
|
||||
/// <param name="CorrelationId">Correlation for tracing the apply and its ack.</param>
|
||||
/// <param name="TargetNodes">
|
||||
/// #1107 — <see langword="null"/> (or empty) on the ORIGINAL dispatch, which every node applies. Set only on a
|
||||
/// coordinator RE-SEND, naming the nodes (<c>ClusterNode.NodeId</c>, compared case-insensitively) that have not
|
||||
/// acked this deployment yet: a node not named ignores the re-send, and a named node that already acked (its ack
|
||||
/// was lost) or is still applying it re-sends its ack / keeps applying instead of applying a second time. Additive:
|
||||
/// a pre-#1107 node ignores the member (see <c>docs/Redundancy.md</c> §"Dispatch re-send").
|
||||
/// </param>
|
||||
public sealed record DispatchDeployment(
|
||||
DeploymentId DeploymentId,
|
||||
RevisionHash RevisionHash,
|
||||
CorrelationId CorrelationId);
|
||||
CorrelationId CorrelationId,
|
||||
IReadOnlyList<string>? TargetNodes = null)
|
||||
{
|
||||
/// <summary>Whether this is a coordinator re-send (#1107) rather than the original dispatch.</summary>
|
||||
public bool IsResend => TargetNodes is { Count: > 0 };
|
||||
|
||||
/// <summary>
|
||||
/// Whether the node <paramref name="nodeId"/> should act on this dispatch: always for the original dispatch,
|
||||
/// and for a re-send only when the node is named in <see cref="TargetNodes"/> (case-insensitive, matching the
|
||||
/// coordinator's expected-ack comparison).
|
||||
/// </summary>
|
||||
/// <param name="nodeId">The receiving node's id (<c>host:port</c>).</param>
|
||||
/// <returns><see langword="true"/> when the node should handle it.</returns>
|
||||
public bool IsAddressedTo(string nodeId) =>
|
||||
!IsResend || TargetNodes!.Any(t => string.Equals(t, nodeId, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
@@ -50,12 +50,16 @@ public static class MeshTransportDtoMapper
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(message);
|
||||
|
||||
return new DispatchDeploymentCommand
|
||||
var proto = new DispatchDeploymentCommand
|
||||
{
|
||||
DeploymentId = message.DeploymentId.ToString(),
|
||||
RevisionHash = message.RevisionHash.Value ?? "",
|
||||
CorrelationId = message.CorrelationId.ToString(),
|
||||
};
|
||||
// #1107: only a re-send names targets; the original dispatch leaves the repeated field empty.
|
||||
if (message.TargetNodes is { Count: > 0 } targets)
|
||||
proto.TargetNodes.AddRange(targets.Where(t => !string.IsNullOrWhiteSpace(t)));
|
||||
return proto;
|
||||
}
|
||||
|
||||
/// <summary>Rebuilds the domain record from its wire form.</summary>
|
||||
@@ -70,7 +74,9 @@ public static class MeshTransportDtoMapper
|
||||
return new DispatchDeployment(
|
||||
DeploymentId.Parse(proto.DeploymentId),
|
||||
RevisionHash.Parse(proto.RevisionHash),
|
||||
CorrelationId.Parse(proto.CorrelationId));
|
||||
CorrelationId.Parse(proto.CorrelationId),
|
||||
// #1107: an empty repeated field is the original dispatch (null), never "addressed to nobody".
|
||||
proto.TargetNodes.Count > 0 ? proto.TargetNodes.ToList() : null);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- RestartDriver
|
||||
|
||||
@@ -32,6 +32,11 @@ public static class OtOpcUaTelemetry
|
||||
Meter.CreateCounter<long>("otopcua.deploy.applied", unit: "{deployment}",
|
||||
description: "Deployments applied by a driver-role node (outcome=ack|reject).");
|
||||
|
||||
/// <summary>#1107: dispatch re-sends by the deploy coordinator, counted per targeted (un-acked) node.</summary>
|
||||
public static readonly Counter<long> DeploymentRedispatched =
|
||||
Meter.CreateCounter<long>("otopcua.deploy.redispatched", unit: "{node}",
|
||||
description: "Deployment dispatches re-sent by the coordinator to nodes that had not acked yet.");
|
||||
|
||||
/// <summary>Time from DriverHostActor receiving DispatchDeployment to emitting the ack/reject.</summary>
|
||||
public static readonly Histogram<double> DeploymentApplyDurationSec =
|
||||
Meter.CreateHistogram<double>("otopcua.deploy.apply.duration", unit: "s",
|
||||
|
||||
@@ -92,6 +92,10 @@ message DispatchDeploymentCommand {
|
||||
string deployment_id = 1; // DeploymentId (Guid) in its "N" hex form
|
||||
string revision_hash = 2; // RevisionHash — lowercase 64-char SHA-256 hex
|
||||
string correlation_id = 3; // CorrelationId (Guid) in its "N" hex form
|
||||
// #1107 — ADDITIVE. Empty on the original dispatch (every node applies it); set on a coordinator
|
||||
// re-send to the ClusterNode ids that have not acked yet. Central already dials only those nodes on
|
||||
// this transport, so this is belt-and-braces for the node; a pre-#1107 node ignores the field.
|
||||
repeated string target_nodes = 4;
|
||||
}
|
||||
|
||||
// Mirrors ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin.RestartDriver.
|
||||
|
||||
Reference in New Issue
Block a user