Agent Sets
An integration can have a set of agents that provide resilience in the case of agent failure.
The primary agent makes every change on the device. The others are secondaries, they don't make any changes and wait until the primary goes offline. If the primary does go offline, the next secondary in the list takes over seemlessly.
Agent sets protect against losing an Agent, whereas having multipe web nodes protect against losing a Server.
Two limits:
- The device being orchestrated must be reachable over the network: eg. a firewall, a load balancer or a cloud provider. An integration enforced on the Agent's own host (IPSet, nftables, PF, Windows Firewall, HAProxy, Nginx, the Knocknoc reverse proxy or a custom script) can only have one Agent, because a second Agent would be on a second host.
- Every Agent in a set must be on a release that supports sets. Older Agent are unable to be addd to a set and you will seee that the agent needs an upgrade to join a set when trying to pick it into a set.
Failover
When the primary has no connection to any Server, Knocknoc waits a short grace period and then makes the first connected secondary the primary. The new primary seemlessly takes over and prioritises new grants over failover work.
| What happened to the primary | Time until a secondary takes over |
|---|---|
| It shut down cleanly (service stopped, host shut down) | About 10 seconds |
| It died, or lost its network, without closing the connection | 40 to 45 seconds |
| The Server it was connected to stopped | About 40 seconds |
A primary that drops and reconnects within the grace period does not get demoted, so a network blip does not necessarily cause a failover. There is also a server restart grace period where For the first two minutes after a Server starts it replaces no primary that has yet to reconnect, since Agents come back at different moments after a restart.
An integration that uses the Agent's own cloud identity instead of a stored credential needs that identity on every Agent in the set. Give each host the same role or service account as the primary. Knocknoc checks each Agent's identity when it connects and when the integration is saved, and passes over a secondary whose identity failed.
There is no automatic failback. When the old primary returns it stays a secondary, so an Agent that keeps dropping cannot take the role back and forth. To move the role yourself, edit the integration, choose Make primary on the Agent, then Verify and Save. Primary history on the integration's page lists each change of primary and why it happened, for example "agent-2 went offline, so agent-3 took over".
While the primary is offline and nothing has taken over yet, its row reads Offline with "Grants wait until it reconnects or another agent takes over".
Each failover raises an AgentPromotedPrimary event. See SIEM events.
Secure credential handling
Each Agent in a set needs its own copy of the integration's credential (API key, password or token), because they are stored encrypted to that Agent's own key so only that Agent has access to the credential
- When you create the integration, the credential is encrypted for every selected Agent.
- An Agent added later will either require you to re-enter the credential or, when sharing trust is established, an agent in the set that already has the credential can reencrypt it for the new agent. See below for information on establishing the sharing and what that means.
When the Agents cannot reach any Server
An Agent that is cut off from every Server cannot tell whether a secondary has taken over from it. So while it is disconnected, an Agent in a set stops adding entries, and it does not remove ones that expire.
The biggest impact of this is that when agents are in a set access that expires during a full Server outage stays on the device until a Server is reachable again. A user granted before the outage keeps that acces for the length of the outage. When a Server comes back, the primary puts everything right within seconds.
An integration with one Agent has no successor to protect, so it keeps removing expired access on time while the Servers are unreachable. If access that outlasts an outage is not acceptable for a device, keep that integration on one Agent, or run more than one web node so the Agents can always reach a Server.
Troubleshooting Agent sets
A new secondary shows Requires re-entry, and clicking Verify asks for the credential. No Agent with the credential shares with the new secondary, or the one that does is offline. Choose Enable sharing on the row and follow the instructions, or re-type the credential.
A failover skipped a secondary, on an integration that uses the Agent's own identity to authenticate. The skipped secondary has failed connection to the cloud provider. You can run Verify device access to see which Agent fails and why. To fix give its host the same role or service account as the primary, then save the integration.
The old primary came back and is not writing. That is expected, there is no automatic fail back. To revert you can edit the integration, choose Make primary on the agent you want and Save the integration.
Saving says the primary changed since the page was loaded. A failover or another admin moved the primary while you were editing. Nothing was saved, and the page now shows the Agents as they are. Make your change again and save.
Grants fail on one Agent with error 299014. Somehow the agent has no usable copy of the credential. You will need to ether share it again from a connected Agent, or re-enter the credential again on the integration.