If you are no longer using a Link Agent for testing, you can shut it down from the mabl app, the mabl CLI, or the mabl API. This article explains how to shut down a Link Agent, how to remove one tunnel from an agent that serves several, and how to clean up tunnels you create for short-lived environments.
Once you shut down a Link Agent, you can't start it back up from the mabl app. If your goal is to take an agent out of service for a while, such as to patch its host, use maintenance mode instead. To stop routing a test environment's traffic through Link, see disabling mabl Link for a test environment.
Before you shut down a Link Agent
Review the Tunnels table on Settings > Networking. If the tunnel is associated with a mabl environment and this is its last agent, update the environment settings to use a different tunnel or no tunnel at all. Otherwise tests in those environments start to fail.
Let running tests finish first
To shut down an agent without interrupting tests that are already running through it, put it into maintenance mode first. The agent stops accepting new connections and lets its current ones finish.
- In the Agents table, open the agent's Manage menu and choose Enter maintenance.
- Confirm with Enter maintenance.
- Wait for the agent's status to change from Draining, while its connections finish, to Drained, when it has none left.
Once the agent shows Drained, shut it down as described in the next section. To return it to service instead, choose Manage > Exit maintenance.
Shutting down a Link Agent
- Go to Settings > Networking. For an agent that serves a company tunnel, use the Networking page of the company dashboard.
- In the Agents table, open the agent's Manage menu and choose Shut down.
- Confirm with Shut down.
The agent stops, and tests that need it fail until another agent serves its tunnel.
Only workspace owners can shut down agents on workspace tunnels, and only company admins can shut down agents on company tunnels.
You can also shut down Link Agents with the mabl CLI or the mabl API:
-
mabl CLI: use the
mabl link-agents terminate {agent-id}command. - mabl API: use the terminate link agent endpoint.
If a Link Agent serves several tunnels, shutting down one of them leaves the others running. Link Agents older than version 3.0 behave differently: shutting down any one tunnel shuts down the whole agent and every tunnel it serves.
Removing one tunnel from a Link Agent
To stop serving one tunnel on an agent that serves several, remove that tunnel's entry from the Link Agent configuration file and save the file. The agent stops taking new connections on that tunnel and lets its current ones finish, so running tests aren't interrupted. The tunnel then waits until you shut it down from the mabl app, or until the agent restarts.
Cleaning up tunnels for short-lived environments
If you start Link Agents for temporary environments, such as a preview environment for each pull request, remove the tunnel when the environment goes away:
mabl link-agents delete {tunnel-name}
The command shuts down every agent on that workspace tunnel, removes the tunnel, and blocks new agents with the same name for 15 minutes.
Terminating Kubernetes-based Link Agents
If you shut down a Kubernetes-based Link Agent from the mabl app, the Kubernetes deployment starts a replacement Link Agent within seconds to maintain your specified number of replicas. Similarly, pod-based Link Agents attempt to restart based on their Restart Policy.
To terminate a Kubernetes-based Link Agent, use the kubectl delete command:
- For pod-based Link Agents:
kubectl delete pod mabl-link-agent -n {YOUR-NAMESPACE} - For deployment-based Link Agents:
kubectl delete deployment mabl-link-agent-deployment -n {YOUR-NAMESPACE}