Search
Varnish Controller

Agent

While agents are one part of the system running as processes alongside the Varnish process they are also a modeling concept. An agent is where a VCL is deployed. An agent is also tagged with one or more tags. The tags are then used by deployments to tell the system where to deploy a specific set of VCL files.

An agent can have the following states:

  • (1) Running - Available for deployments
  • (2) Failing - Unavailable for deployments, Varnish might be unreachable.
  • (3) Down - Brainz does not have contact with the agent, and it is considered as down.
  • (4) ReadOnly - Read-only agent, only reports information, not used for deployment.
  • (5) Locked - Locked agent, only reports information, cannot be deployed to (see “Locked Agents”)

Each agent must have a unique name that is specified during the startup of the agent process. For agents that use different private token (version 5.0+), the name can be the same as long as different tokens are used for the agents.

Locked Agents

Agents becomes Locked when brainz reports wrong unique ID (UID) to them. The brainz UID is created the first time brainz initializes the database. When agents are started for the first time, brainz will provide them with this UID. The agents will then only accept deploy/undeploy/reloads from a brainz instance that uses the same UID.

This functionality is to prevent undeploys if the database becomes reset or destroyed without backups. Starting brainz with a new database, without any data, would otherwise undeploy all VCLs from all agents. This is because the database is empty and brainz will perform deployments based on what is in the database, in this case nothing. So in order to avoid this scenario, the agents that had previous deployments, will become locked.

Locked agents will keep running the previously known VCLs until unlocked.

Unlocking Agents

Before unlocking an agent make sure that the database contains the same settings that should be deployed to the agents. That means, same tags, deployments, domains, vclgroups and that the agents have the same tags as before. Once this is added to the database (via API/UI/CLI) the agents UID file can be removed. The UID file exists in the agents configured base-dir and is called agent.uid. Remove the file and then restart the agent and the agent will become running again. Brainz will then update the agent with correct deployments. If the deployments are the same as before, no undeploys will be made.

However, if the VCLGroup IDs has changed compared to before the database reset, the VCLs will be re-deployed. This will however not remove any cached content and existing sessions will be kept until ended on the previous VCL configuration in Varnish.