TechnitiumSoftware/DnsServer · error · DnsServerException

Failed to ask Secondary node to leave: the Cluster is not in

Error message

Failed to ask Secondary node to leave: the Cluster is not initialized.

What it means

Thrown by AskSecondaryNodeToLeaveClusterAsync when ClusterInitialized is false. Asking a node to leave requires an active cluster with a node list to look up the target Secondary.

Source

Thrown at DnsServerCore/Cluster/ClusterManager.cs:746

            //update cluster catalog zone ACLs and save zone file
            UpdateClusterCatalogZoneOptions();

            //save all changes
            SaveConfigFile();

            //notify all secondary nodes
            TriggerNotifyAllSecondaryNodes();

            //trigger NS and SOA update for member zones
            TriggerRecordUpdateForClusterCatalogMemberZones();

            return secondaryNode;
        }

        public async Task<ClusterNode> AskSecondaryNodeToLeaveClusterAsync(int secondaryNodeId)
        {
            if (!ClusterInitialized)
                throw new DnsServerException("Failed to ask Secondary node to leave: the Cluster is not initialized.");

            if (GetSelfNode().Type != ClusterNodeType.Primary)
                throw new DnsServerException("Failed to ask Secondary node to leave: only a Primary node can ask a Secondary node to leave the Cluster.");

            //find existing secondary node
            if (!_clusterNodes.TryGetValue(secondaryNodeId, out ClusterNode secondaryNode))
                throw new DnsServerException("Failed to ask Secondary node to leave: the specified node does not exist in the Cluster.");

            if (secondaryNode.Type == ClusterNodeType.Primary)
                throw new DnsServerException("Failed to ask Secondary node to leave: the specified node is the Cluster Primary node and cannot be removed.");

            //ask secondary node to leave the cluster
            await secondaryNode.AskSecondaryNodeToLeaveClusterAsync();

            return secondaryNode;
        }

        public ClusterNode DeleteSecondaryNode(int secondaryNodeId)

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Check ClusterManager.ClusterInitialized before calling AskSecondaryNodeToLeaveClusterAsync.
  2. Ensure the operation targets the initialized Primary node.

Example fix

// before
await _clusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);
// after
if (!_clusterManager.ClusterInitialized)
    throw new InvalidOperationException("Cluster is not initialized.");
await _clusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);
Defensive patterns

Strategy: validation

Validate before calling

if (!_dnsWebService.ClusterManager.ClusterInitialized)
    throw new InvalidOperationException("Cluster is not initialized; cannot ask a node to leave.");
await _dnsWebService.ClusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);

Type guard

static bool CanManageClusterNodes(ClusterManager cm) => cm.ClusterInitialized;

Try / catch

try
{
    await _clusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);
}
catch (DnsServerException ex) when (ex.Message.Contains("ask Secondary node to leave") && ex.Message.Contains("not initialized"))
{
    // no cluster — nothing to leave
}

Prevention

When it happens

Trigger: AskSecondaryNodeToLeaveClusterAsync(secondaryNodeId) is called on a server where _clusterNodes is null or empty. The guard at line 745 fires before the node lookup.

Common situations: Calling the leave operation on a non-clustered server; after the cluster was already deleted; on a Secondary that never joined successfully.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/39c66535d7c7e899. Report an issue: GitHub.