Skip to content

Start a forge

The first start of a production forge, from its recovery keys and identity provider to its first administrator, then more nodes, and unsealing after every node has stopped.

af-server --dev is for one developer’s machine. A forge that people and agents rely on is started once with a few decisions made up front, all of them flags of af-server, each also an environment variable. The af-server reference lists every one.

Before the first start

You need:

  • A host name and a TLS certificate for it. Clients connect over WebTransport, with a WebSocket fallback, both on TLS 1.3. Without --tls-cert and --tls-key, the server makes a self-signed certificate for localhost and logs its hash, which clients pin with af --cert-hash.
  • An OpenID Connect identity provider, the issuer your people sign in with, and the forge’s client ID there. The forge keeps no accounts of its own. For an issuer many organizations share, such as Google’s or Microsoft Entra ID’s, also give the claim that names your tenant with --oidc-tenant. Signing people in registers the forge with Google Workspace, Entra ID, Okta or any other provider, and requires a second factor.
  • Your first administrator: the verified email of the person who becomes administrator when they first sign in.
  • Recovery key holders: the people who can bring the cluster’s key back if every node stops at once. See Keys and the vault.

Each recovery key holder makes their key on their own machine. The private key stays there; the .pub file goes to you:

$ af vault key
5e1ab3f3d24b8b4bbb6c63ae73b6af1e2f5bc4ab3cbf7c2ea4fcd7a0c48c2f91 /home/you/.config/atoll-forge/recovery.key.pub

The first start

Give the first start everything at once. With three holders, two of whom are needed to unseal:

af-server \
    --data-dir /var/lib/af-server \
    --listen 0.0.0.0:7777 --quic-listen 0.0.0.0:7777 \
    --tls-cert /etc/af-server/cert.pem --tls-key /etc/af-server/key.pem \
    --oidc-issuer https://accounts.google.com \
    --oidc-client-id <CLIENT_ID> \
    --oidc-tenant hd=example.com \
    --first-administrator ada@example.com \
    --recovery-key ada.pub,bob.pub,carol.pub --recovery-threshold 2 \
    --raft-listen 0.0.0.0:7778 --raft-advertise forge-1.example.com:7778

The first start creates the operator’s organization, operator unless --organization names it, with its first repository, and the cluster’s key, held only in memory and split into one share for each holder. Later starts read these from the data directory: give them the same flags but the recovery keys and the first administrator, which only a first start uses. The identity provider is read from its flags at every start, and with none, nobody can sign in to the operator’s organization.

People then sign in with af auth, which prints an address and a one-time code to enter in any browser. The first administrator’s sign-in makes them administrator.

Until the forge’s first release, a data directory’s databases are not upgraded from one build of af-server to the next. Each records a checksum of its tables’ definitions when it is made: a build whose tables are the same opens it, and one whose tables differ stops before it serves anything, naming the database, and the forge is started again in a new directory.

More organizations

Each organization has its own identity provider, people, roles and keys, isolated from every other. With --domain forge.example, organization acme is served at acme.forge.example, under one wildcard certificate; a platform administrator creates it with af create-organization. See Organizations and repositories. Without a domain, every host name reaches the operator’s organization.

More nodes

A node joins in three steps. On the new machine, af-server --enrollment creates the node’s keys and prints the command that enrolls it:

af-server --data-dir /var/lib/af-server --raft-advertise forge-2.example.com:7778 --enrollment

The printed command also names the node’s machine, --machine: the HMAC-SHA256, in hex, of a fixed text keyed by the machine’s id in /etc/machine-id, never the id itself. A node’s record keeps it, the cluster’s first node’s too, and the forge refuses to enroll an organization’s runner or agent runner on the machine of any live node. --machine-id-file reads the id from another file instead (at least 16 characters that are not whitespace), for a development forge and a runner on one host, and says so on standard error. A machine with no usable /etc/machine-id is on no machine, and says so on standard error too.

A platform administrator runs the printed af enroll-node command, and another approves it unless they are the only one. Once the enrollment takes effect it prints the node’s ID, and the node joins through any member:

af-server --data-dir /var/lib/af-server --join forge-1.example.com:7777 --join-as <NODE_ID> \
    --raft-listen 0.0.0.0:7778 --raft-advertise forge-2.example.com:7778

A client that asks a node that does not lead a question’s group, and waits there for an answer, is sent to the node that does, if that node’s record says where clients reach it. Give --client-advertise forge-2.example.com:7777 to --enrollment (it prints it as --client-address) and to the first node’s own start, a host:port that is never the --raft-advertise address, which is the cluster’s own; a node with none is never named to a client, who asks again where it is, or looks every few seconds. It is approved with the rest of the enrollment and changes only by enrolling the node again.

The node takes the cluster’s key from a live member, sealed to its own key, and every group’s data. Once joined, it restarts without --join. The cluster keeps three voters in each group and makes every other node a learner on its own.

See the cluster’s membership

af cluster peers shows the cluster as the node you reach sees it: each node enrolled, then each group (the platform, each organization, each repository) with the leader that node knows of, the voters and learners in effect, and whether that membership is settled, committed with one set of voters, or still changing. The last line says whether every group is settled with the same voters, each with a leader, and names those voters:

as node 1 (forge-1) sees it
node 1  forge-1  forge-1.example.com:7778  enrolled
node 2  forge-2  forge-2.example.com:7778  enrolled
node 3  forge-3  forge-3.example.com:7778  enrolled
group 1  the platform               leader 1  voters 1 2 3  settled
group 2  organization operator      leader 1  voters 1 2 3  settled
group 3  repository operator/main   leader 1  voters 1 2 3  settled
all 3 groups settled with voters 1 2 3, each with a leader

With two nodes, the second is a learner in every group: the cluster keeps an odd number of voters, and a group of one voter does not wait on a second. Wait for the last line to name every voter you expect before you take a node down: until then, a group may need the node you stop to have a quorum.

It is one node’s view, and says so. Enrolled says nothing of whether a node’s process is running, and a follower’s leader is the one it last heard from; --verbose adds how long ago. Settled membership is not a health check of the other nodes. Your role, and the list of nodes and groups, are confirmed with the leaders of the operator’s organization and of the platform before the node answers, so the command needs those leaders to answer, and a platform administrator to ask.

Worker threads, and nodes that share a machine

A node runs an async worker thread for each CPU its process may use. Those threads carry its requests, its Raft and its lander. The nodes of a cluster that share one machine, as the three of a laptop’s or a test box’s do, then run several times the machine’s CPUs in workers, and workers beyond the CPUs only contend for them. --worker-threads (or AF_WORKER_THREADS) sets the count, from 1 to 1024: give the nodes of one machine counts that add up to no more than its physical cores.

af-server --data-dir /var/lib/af-server --worker-threads 4

The count is read once, at start. It sets the node’s async workers and nothing else: the threads that do blocking work, the repository’s own thread, the code search’s and the Raft log’s are not part of it, so it is not a limit on the node’s CPU. The node’s log says at start how many workers it runs and how many CPUs are available to it, and warns if it has more workers than CPUs. With none set, the node runs a worker for each available CPU.

When every node has stopped

A node that starts while another member is running takes the cluster’s key from it. A node that starts when none is stays sealed: it answers nothing but the vault’s own requests. Enough holders then each give their share, from their own machine:

af vault status
af vault unseal

Each share is opened on its holder’s machine with their recovery key and given to the node, which unseals once it has the threshold. Holders change with af vault rekey, and the cluster’s key is rotated with af vault rotate: see The vault and recovery keys.

Next

Type to search…

↑↓ navigate↵ selectEsc close