fix(opcua): an identical re-deploy after a degraded REBUILD repairs instead of reporting clean (#601 review)
A degraded rebuild advances _lastApplied (deliberately), so re-deploying the same revision diffed to an empty plan and reported a CLEAN outcome - the #601 're-deploy re-applies' repair path sealed green over an address space still known partial. The publish actor now remembers that the last advance was degraded and, on an empty plan, re-ensures the whole composition (idempotent, no rebuild), reporting clean only when that pass is clean. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -157,6 +157,15 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
/// protecting. Distinguishes "the artifact went missing under a running server" (issue #485 — warn, and
|
||||
/// hold what is materialised) from "nothing has been deployed here yet" (a quiet no-op at boot).</summary>
|
||||
private bool _hasAppliedComposition;
|
||||
/// <summary>
|
||||
/// Gitea #601 review — <see cref="_lastApplied"/> was advanced by a DEGRADED rebuild (a rebuild advances
|
||||
/// even with swallowed failures, see <see cref="HandleRebuildCore"/>). A re-deploy of the same revision
|
||||
/// then diffs to an EMPTY plan; without this flag that empty plan reported clean, so the "re-deploy
|
||||
/// re-applies" repair path sealed green over an address space still known to be partial. While set, an
|
||||
/// empty plan re-materialises the whole composition (idempotent ensures) and reports clean only when
|
||||
/// that pass is itself clean.
|
||||
/// </summary>
|
||||
private bool _lastAppliedDegraded;
|
||||
private DbHealthProbeActor.DbHealthStatus? _lastDbHealth;
|
||||
private RedundancyStateChanged? _lastSnapshot;
|
||||
private (bool Ok, DateTime At)? _probeAboutMe;
|
||||
@@ -565,6 +574,28 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
|
||||
if (plan.IsEmpty)
|
||||
{
|
||||
if (_lastAppliedDegraded)
|
||||
{
|
||||
// #601 review — the composition is unchanged but the last apply of it was a degraded
|
||||
// rebuild: re-ensure every node (each Ensure* no-ops on a node that stands) so the
|
||||
// re-deploy actually repairs what that rebuild could not place.
|
||||
var repairFailed = _applier.MaterialiseHierarchy(composition)
|
||||
+ MaterialiseNodes(plan, composition, fullComposition: true);
|
||||
if (repairFailed > 0)
|
||||
{
|
||||
OtOpcUaTelemetry.OpcUaApplyFailed.Add(1, new KeyValuePair<string, object?>("kind", "nodes"));
|
||||
_log.Error(
|
||||
"OpcUaPublish: re-apply of a degraded composition is STILL degraded (correlation={Correlation}, failedNodes={FailedNodes})",
|
||||
msg.Correlation, repairFailed);
|
||||
return (true, $"re-apply of a previously degraded address space is still degraded (failedNodes={repairFailed})");
|
||||
}
|
||||
|
||||
_lastAppliedDegraded = false;
|
||||
_log.Info("OpcUaPublish: re-apply repaired the previously degraded address space (correlation={Correlation})",
|
||||
msg.Correlation);
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
_log.Debug("OpcUaPublish: rebuild requested but plan is empty (correlation={Correlation})",
|
||||
msg.Correlation);
|
||||
return (false, null);
|
||||
@@ -610,6 +641,9 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
{
|
||||
_lastApplied = composition;
|
||||
_hasAppliedComposition = true;
|
||||
// #601 review — advanced despite failures only on a rebuild; remember it so an identical
|
||||
// re-deploy repairs instead of short-circuiting clean on the empty plan.
|
||||
_lastAppliedDegraded = outcome.RebuildFailed || failedNodes > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user