Docs Runner Fleet Operations

Runner Fleet Operations

Runners execute tests on behalf of the admin node: API and load tests, browser
tests, mobile tests, security scans. This guide covers a runner’s life from the
operator’s side — connecting a new one, keeping its token valid, taking it out
of service, and upgrading the fleet without losing work.

For the runner settings themselves (pull mode, labels, one-task CI runners), see
Ephemeral Runners and
Runner Labels and Targeting.

When withdrawing a coder runner, a partial-cleanup message means it already stopped receiving new work. Retry the withdrawal to finish canceling its existing work. API callers can repeat the same POST /api/v1/coder/runners/{id}/revoke when the server returns runner_revocation_incomplete.

Connect a new runner

  1. Open Admin Panel > Integrations and click Add Integration.

  2. Choose the type (for example Test Runner), a name and the namespaces the
    runner may serve.

  3. Copy the token. It is shown once, together with ready-made start commands
    for the platform you pick.

  4. Start the runner with the admin URL and the token:

    docker run --rm \
      -e MOCKARTY_ADMIN_URL=https://mockarty.example.com \
      -e MOCKARTY_RUNNER_TOKEN=mki_your_integration_token \
      "$MOCKARTY_RUNNER_IMAGE"
    

MOCKARTY_RUNNER_IMAGE in the example is your own shell variable naming the
runner image; it is not a Mockarty setting. The two MOCKARTY_* variables
prefixed with -e are the container environment the runner itself reads.

The runner connects out to the admin node; nothing needs to reach the runner.
It appears in the Runner fleet view on the same page within seconds, with its
status, capacity, labels and release version.

Several runners can share one token — each process registers separately. Use
one connection per group of runners you want to manage together (for example
per team or per region): its token is what you rotate and revoke.

A runner on your own machine

A runner can also register with your own API key, if that key carries the
runner:register action. The machine then belongs to you: it takes your tasks
and nobody else’s, it lives in your namespace, and it is never part of a shared
fleet however the start command is configured. Nobody can put their work on it
without a grant from you.

Create the key in your profile settings with the runner:register action, then
start the runner with it instead of an integration token:

docker run --rm \
  -e MOCKARTY_ADMIN_URL=https://mockarty.example.com \
  -e MOCKARTY_RUNNER_TOKEN=mk_your_personal_api_key \
  "$MOCKARTY_RUNNER_IMAGE"

A key without runner:register is refused with that reason instead of
registering a runner nobody owns, and revoking the key stops the runner from
claiming new work. Use an integration token when the machine should serve a whole
team; use your own key when the machine should serve you.

When moving a coding conversation, the destination needs a free place for a
hosted session. This limit is set by --max-hosted-sessions on the runner.
A runner can be available for new jobs while its hosted conversations fill all
of those places.

Lending your runner to a colleague

Your machine can take one colleague’s work without losing its ownership: grant it
to that person and their tasks may run there. Only you can grant or revoke, and
revocation takes effect on the next claim — not on the next reconnect.

# Lend this runner to one user (the id is a user UUID), for API collections only.
# Omit capabilities to lend every task type the runner advertises.
curl -s -X POST "$BASE/api/v1/runners/$RUNNER_ID/grants" \
  -H "X-API-Key: $TOKEN" -H "Content-Type: application/json" \
  -d '{"granteeUserId": "11111111-2222-3333-4444-555555555555", "capabilities": ["api_test"]}'

# Withdraw it.
curl -s -X DELETE "$BASE/api/v1/runners/$RUNNER_ID/grants/11111111-2222-3333-4444-555555555555" \
  -H "X-API-Key: $TOKEN"

A grant can be narrowed to the task types you lend: capabilities is the closed set the colleague’s work must match, and an omitted list means every type the runner advertises. An integration runner cannot be lent: it has no owner, and its reach is the integration’s scope instead.

Keep the token valid

A runner token is valid for 90 days from when it was issued or last rotated.
Mockarty warns the administrators 14, 7 and 1 day before a token expires and
again when it has expired, in the notification bell and in the admin node’s log.
The warning names the connection.

To replace a token without interrupting any runner, create a second connection
with the same settings, move the runners to its token one by one, then delete
the old connection. Rotate Token on the connection is faster, but the old
token stops working at once. Both ways are described in
Rotating Keys, Tokens and Certificates.

Connect a personal Coder Runner

Use the enrollment token from the intended Space and the --admin-pubkey for
that installation. The runner verifies the installation’s signed registration
before polling for work or session transfers. Use the final Admin URL because
enrollment does not follow redirects. If you supply --namespace, it must
match the Space that issued the token.

When you request the one-time enrollment token through the API, the response
includes attestationPublicKey if Admin has a signing key. Read it over the
verified HTTPS connection to that Admin and pass the base64 Ed25519 public key
as --admin-pubkey.

A persistent pull-mode runner can reconnect after the one-time enrollment token
expires. Keep its runner ID, installation ID, secret and data directory. An
administrator’s revocation stops that registration from reconnecting.

When a personal Desktop runner advertises folders, the account that enrolled
it needs write access to the same Space. If access is withdrawn, the folders
are unavailable for new moves. A change to a folder’s permission also makes
an earlier selection unavailable. If the registration rejects the folder
catalogue, correct the access and retry with the same unexpired enrollment token.

Runner session controls

In an open Harness session, use the composer’s settings gear and select
Runner session for the available move, recovery and file controls. If you
switch conversations during a transfer, you can see its progress when you return.

Notifications for Harness sessions

The notification bell tells you when a runner completes or fails a turn in
your Harness session. Open the notification to return to the session in its
Space. A turn you stopped does not generate this notice.

Take a runner out of service

In the Runner fleet view, click Drain on the runner and give a reason.
The fleet stops giving it new work; what it is running finishes. The decision
stays in place across restarts until you click Return to rotation, so a
runner you took out for maintenance does not rejoin by itself.

Stopping a runner process gracefully (SIGTERM, docker stop, a Kubernetes pod
deletion) also finishes the current task before the process exits; the fleet
then shows the runner as offline (a one-task CI runner disappears from it).

When a persistent pull-mode Coder Runner stops with saved OpenCode conversations, it keeps its original registration available for recovery. The fleet detects when the process goes offline from missed heartbeats. To return the conversation to Desktop, restart the runner with the same secret, settings and data directory. One-task CI runners close their registration when they exit normally.

Upgrade the fleet

Upgrade the admin nodes first, then the runners. A runner one release behind
the admin keeps working; the fleet view marks it upgrade soon. A runner two
or more releases behind is marked upgrade the runner, and one newer than the
admin upgrade the admin first — both are outside the range the admin keeps
compatible.

To upgrade runners without losing work:

  1. Drain the runner.
  2. When it shows no active tasks, stop it.
  3. Start the new version with the same token and settings.
  4. Click Return to rotation.

On Kubernetes, a rolling update of the runner deployment does steps 2 and 3 for
you: each old pod finishes its task before it exits.

To stop unsupported runners from taking work at all, set on the admin node:

MOCKARTY_RUNNER_VERSION_POLICY=enforce

A runner outside the supported range is then refused when it connects, and its
log names both versions and what to upgrade. The default (warn) lets it
connect and only marks it.