Skip to content

Commit 2febd7d

Browse files
authored
feat(web): make a pool step by step, with what each cloud needs (#645)
## Summary Making a pool now follows the Runners tab's step-by-step setup, as #615's design asks. New pool asks in three steps: name it; its labels and machines (labels, placement, sessions each machine runs, runners at once, offline removal, approval, expiry); and where it runs (your own machines, AWS, Google Cloud, Azure or Kubernetes). A live summary says what the pool will do, and a preview shows its card once its first runner is online. Choosing a cloud removes runners once offline and packs sessions, as autoscaled machines want. Once the pool is made, the dialog shows the token once, then the steps for where its machines run, with every value of this instance and this pool filled in: - **Your own machines:** install fctl, then enroll with the token at the chosen capacity. - **AWS:** the token in a file, fctl's Terraform module (named after the pool, with the instance, its version, the capacity and a `max_size` a few below the pool's limit; the VPC and subnets left to fill in), then `terraform apply`. - **Google Cloud:** build the image with Packer, fill in the example's `terraform.tfvars` (the token stays out of it), then apply with the token in `TF_VAR_enrollment_token`. - **Azure:** make the image's resource group, gallery and image definition, named after the pool, then build the image into that gallery with Packer (the template now takes `azure_gallery`). Then fill in `terraform.tfvars` from the same shell (the subscription, the location, the image's ID, and a resource group of the scale set's own) and apply with the token in `TF_VAR_enrollment_token`. - **Kubernetes:** the token in a secret, the host as a Deployment (linking to the role and the preStop hook in Self-hosting), and a TriggerAuthentication with a ScaledObject whose metrics-api trigger reads the pool's demand. I verified it with unit tests that check each place's steps hold the instance, the token and the pool's values (and `YOUR_FCTL_VERSION`, with where to find it, while the app hasn't heard the instance's version), a component test of the steps from the form to the AWS setup, and in `cargo xtask dev` in both themes and at a phone's width. The Azure commands follow the guide's step 7, but nothing ran in a real cloud account. It is stacked on #644. The AWS, Google Cloud and Azure steps use `deploy/cloud` and its Terraform, which #639 added. Refs #615 - #644 - #639 - hyperstructure/design#80 ## Screenshots At d62c20b, from `cargo xtask dev`. New pool, with AWS chosen, then what it shows once made, light: | The steps | Once made | |---|---| | ![New pool: 1 Name it, 2 Choose its labels and machines, 3 Choose where it runs (AWS), the live summary, and the preview of AWS large's card with its first runner](https://app.fctl.sh/api/v1/published/IJGQePCaZumJt7heP4CYrTDJpbHnMpbxAK7qtchWVHk/new-aws-form.png) | ![AWS large is ready: the token once, then Bring it online on AWS: keep the token in a file, fctl's module filled in, terraform apply](https://app.fctl.sh/api/v1/published/TN8dikKMhOrgmYnKTs0vFuRGxwjMKYmNeod29I42S1c/new-aws-created.png) | Kubernetes in the dark theme, and Google Cloud at a phone's width: | Kubernetes | Google Cloud, 390 px | |---|---| | ![Kubernetes large is ready: the secret, the Deployment, and the KEDA TriggerAuthentication and ScaledObject](https://app.fctl.sh/api/v1/published/G95Ghw2y2bqV8o8o1EAObOu4x9xic1v0auJKRYNozJm/new-k8s-created.png) | ![Google Cloud large is ready, at 390 px: the image, the example's values, terraform apply](https://app.fctl.sh/api/v1/published/nJlVwaCXJEWaifcqR0dx8tL7UTyULBn6q5JYhFmm7mb/new-google-phone-created.png) | ## Worth confirming - **Decision:** "Sessions each machine runs" is in the form though it isn't the token's: it only shapes the commands and Terraform it gives to copy (`--capacity`, `capacity`). - **Decision:** the AWS module's source isn't pinned to the instance's version, because a release before #639 has no module; the step says to pin it with `?ref=`. - **Decision:** Kubernetes gets the secret and KEDA's objects in full but the host's Deployment only in words with a link, since running the host's sandboxes in a cluster is the Kubernetes driver's work (#617). - **Decision:** choosing a cloud switches "When they go offline" from Keep them to Remove after 5 minutes, and with it the placement to packed, until someone changes them. [fctl session](https://app.fctl.sh/s/ses_01M84BNFZPNEXTHDT8WGN1Q6JY) <!-- FCTL_REVIEW_SUMMARY --> --- > [!NOTE] > **Low risk.** It adds a step-by-step new-pool dialog and generated setup text to the web app, and a template variable for the Azure image build; nothing here touches stored data or permissions. > > **What it does.** Making a pool in the Runners tab now goes in three steps (name, labels and machines, where it runs), with a live summary and a preview of the pool's card. Once the pool is made, the dialog shows the token once and then the steps for the chosen place (own machines, AWS, Google Cloud, Azure or Kubernetes), with the instance's values and the pool's settings filled in. Azure's steps make the image's gallery first, and the Packer template takes it as a new `azure_gallery` variable. > > **Packer template.** `deploy/cloud/fctl-runner.pkr.hcl` gets an `azure_gallery` variable that defaults to the old `acme_runners`, so the guide keeps working; the guide's copy of the template changes with it. > > <sub>[fctl review](https://app.fctl.sh/s/ses_01M869JFYMV5K3XNY5YZN1325F)'s first look at [`d92acb9`](d92acb9) · 12 files, +831 −156 · [Review agent settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub> <!-- /FCTL_REVIEW_SUMMARY --> --------- Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
1 parent c336ff8 commit 2febd7d

12 files changed

Lines changed: 831 additions & 156 deletions

File tree

‎deploy/cloud/fctl-runner.pkr.hcl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ variable "gcp_zone" { default = "europe-north1-a" }
1313
variable "azure_subscription" { default = "" }
1414
variable "azure_resource_group" { default = "acme-runners" }
1515
variable "azure_location" { default = "swedencentral" }
16+
variable "azure_gallery" { default = "acme_runners" }
1617

1718
locals { name = "fctl-runner-${replace(var.fctl_version, ".", "-")}" }
1819

@@ -64,7 +65,7 @@ source "azure-arm" "fctl-runner" {
6465
shared_image_gallery_destination {
6566
subscription = var.azure_subscription
6667
resource_group = var.azure_resource_group
67-
gallery_name = "acme_runners"
68+
gallery_name = var.azure_gallery
6869
image_name = "fctl-runner"
6970
image_version = var.fctl_version
7071
target_region { name = var.azure_location }

‎docs/getting-started.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ signing in on them, enroll themselves with one of the workspace's
281281
create`): a name, its labels and placement, how long it works, how many
282282
runners it may enroll at once, whether each waits for an admin's
283283
approval, and whether runners that stay offline are removed. The token is
284-
shown once. On each machine, from its boot script
284+
shown once, with what to copy where its machines run, the token and the
285+
instance filled in: the commands below for machines of your own, fctl's
286+
Terraform module for AWS, its Google Cloud and Azure examples, or a KEDA
287+
`ScaledObject` for Kubernetes ([Runners in your cloud](runners-in-your-cloud.md)). On each machine, from its boot script
285288
(cloud-init's user data, a launch template) or a shell:
286289

287290
```sh

‎docs/llms.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Each recipe says who does what: some steps take a person with a role in the proj
226226
- **Pull requests** (`/pulls`): the pull requests agents opened, each once with its sessions, archived sessions' too; open ones sorted by what each needs next (waiting for your answer, with the agent's question and its answers to click, then ready for review, checks failing, agents at work, merge queue, drafts), merged and closed ones by day; each with its checks, fctl's review and its size; a filter whose matches each tab counts, a workspace or project, Mine (on until you turn it off, which the browser keeps; the sidebar's counts follow it); opened again from the sidebar, it shows the tab and the filter it had; `j`/`k`, Enter, `o` for GitHub, `c` to copy its link, `/` to filter, the arrows between tabs.
227227
- **Session page** (`/s/<id>`, `r`, `c` and `d` for the message box, the changes and the details, `j`/`k` from turn to turn): the live transcript (tool calls fold into lines, edits show highlighted; the images the agent read show small under them for 7 days), the composer to message the agent (with its owner's lists for the model and effort level it works at from its next step: a new model, which reads the conversation again without Claude's prompt cache, asks first), Interrupt, Stop and Resume, Share, the follow bell, Changes (the files the branch changed; a file opens every file's diff, highlighted, one after the other at that file, with the list of files beside them marking the one in view: `j`/`k` or the arrow keys in the list go from file to file, `n`/`p` from change to change, ⌘F finds in all the diffs (Enter and Shift+Enter, ⌘G, Alt+C/W/R for case, whole words and regular expressions), `s` lays them out side by side, `w` wraps lines; as the agent changes the files, its changes come in where the reader looks while the lines in view stay put, and a button goes to those out of sight), pull requests with checks, context and usage, retrospectives (the transcript shows each with a line for each part, which opens to all it says, and marks what an update changed), ⌘F to find in the transcript, Open in Claude. The page reads the session in turns: a cover with the session at a glance (turns, the agent's time, steps, changes, pull requests, a ribbon of the turns), then each message opens a card, the agent's work hangs from it on a thread, and each turn ends with its time, steps and the files it edited (each opens its diff), and copies as Markdown or a link to it (`/s/<id>?turn=<seq>`); the agent's plan (its TodoWrite list) stays in the details; a line above the message box says what the agent does now and where it is in its plan, or that it's the reader's turn, and while the agent waits for its background tasks, names them in a list that goes to the call that started each (whose line says it runs in the background, then how long it ran); a bar under the header says which turn the reader is in and lists them all (the details list the newest six and the one the reader is in, the earlier ones a click away), a button goes back to the newest work or up to what came while the reader was away, and the conversation alone shows without the agent's work.
228228
- **Project page** (`/p/<slug>`): Sessions, Autopilot (where the workspace lets projects have one: putting the project on autopilot, then where it stands, what it asks you, notes to steer it, its direction, plan, files, sessions and log), Schedules, Reviews, Memory (its notes, `?tab=memory`, and its retrospectives, `?tab=retrospectives`), Repositories, Members and Settings tabs. Settings is a page each, `?tab=`: General (`general`: name, description, icon, default branch, deleting it), Agents (`agents`: instructions, model and effort, the context size Claude compacts near, access on GitHub and to claude.ai, memory and retrospectives), Pull requests (`pull-requests`: opening them, commit credits, screenshots, follow-ups), Tickets (`tickets`), Sandbox (`sandbox`: setup script, caches, image, size, idle timeout, environment) and Secrets (`secrets`); owners and maintainers see and change them all, and everyone else in the project reads Tickets there. Each page saves on its own. Without a page, a phone lists them and a wider screen opens General beside them.
229-
- **Workspace page** (`/w/<slug>`): Projects, People, Runners (with the command and token that add one, the runners that wait for your approval, and the enrollment tokens: every one for admins, members' own for members), GitHub, Linear, Settings (its name, address, avatar image, and the color its avatar shows without one: yellow, pink, blue, ink or one of its own, as `fctl workspaces set --color '#2a9d8f'` sets it), and the Audit log for admins.
229+
- **Workspace page** (`/w/<slug>`): Projects, People, Runners (with the command and token that add one, its pools with what each needs now and their runners, a new pool made step by step with what its cloud needs and every value filled in, the runners that wait for your approval, and the enrollment tokens: every one for admins, members' own for members), GitHub, Linear, Settings (its name, address, avatar image, and the color its avatar shows without one: yellow, pink, blue, ink or one of its own, as `fctl workspaces set --color '#2a9d8f'` sets it), and the Audit log for admins.
230230
- **Settings** (`/settings`, a page each, `?tab=`): Profile (`profile`: name and picture; without one, your Gravatar unless you turn it off), Email addresses (`emails`, with commit emails), Workspaces (`workspaces`: which Claude connection, leaving), Claude (`claude`), Linear (`linear`, your Linear account), Notifications (`notifications`), Appearance (`appearance`: dark or light, a 12- or 24-hour clock), App log (`log`: what the app did in this browser lately, kept only there, to copy into a report), Security (`security`: password and Google, passkeys, two-factor sign-in, devices), Access tokens (`tokens`) and Your data (`data`: one export a week, unless admins chose another wait, and deleting your account). Without `?tab=`, a phone lists the pages and a wider screen opens Profile beside them. **Admin** (`/admin`, instance admins): people, access (allowlist), sign-in (`?tab=sign-in`: how people sign in, the providers with their redirect URIs, the domains that require one, whether signing in makes accounts, two-factor sign-in), early access, workspaces, GitHub, runners, settings (with reserved addresses, Gravatar for everyone, how often people can export their data, and admin tokens where the instance takes them), audit.
231231
- Notifications are Web Push to browsers where people turned them on (on iPhone and iPad, fctl added to the Home Screen): a followed session waits for a reply, pauses on a usage limit, or fails; an autopilot's own session, and those it starts while it is on, only when they ask something, or when the autopilot's own sessions failed four times in a row, and each day they go on failing (fctl doesn't pause it for failures: it tries again 5, 15 and 60 minutes later, then every hour until one works).
232232

‎docs/runners-in-your-cloud.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ variable "gcp_zone" { default = "europe-north1-a" }
314314
variable "azure_subscription" { default = "" }
315315
variable "azure_resource_group" { default = "acme-runners" }
316316
variable "azure_location" { default = "swedencentral" }
317+
variable "azure_gallery" { default = "acme_runners" }
317318
318319
locals { name = "fctl-runner-${replace(var.fctl_version, ".", "-")}" }
319320
@@ -365,7 +366,7 @@ source "azure-arm" "fctl-runner" {
365366
shared_image_gallery_destination {
366367
subscription = var.azure_subscription
367368
resource_group = var.azure_resource_group
368-
gallery_name = "acme_runners"
369+
gallery_name = var.azure_gallery
369370
image_name = "fctl-runner"
370371
image_version = var.fctl_version
371372
target_region { name = var.azure_location }

‎web/src/components/workspace/runners.test.tsx‎

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,35 @@ import type * as G from "@/gen";
66
import { keys } from "@/lib/queries";
77
import { EnrollmentTokens, WaitingRunners } from "./runners";
88

9-
// No request is answered: the sections show what the cache holds.
9+
// No request is answered but making a pool: the sections show what the cache holds.
1010
vi.mock("@/lib/api", () => {
1111
const pending = new Proxy({}, { get: () => () => new Promise(() => {}) });
12-
return { api: pending, workspaces: pending, ApiFailure: class extends Error {} };
12+
const workspaces = new Proxy(
13+
{},
14+
{
15+
get: (_, name) =>
16+
name === "createEnrollmentToken"
17+
? (_id: string, b: G.CreateEnrollmentTokenRequest) =>
18+
Promise.resolve({
19+
token: {
20+
id: "enr_new",
21+
name: b.name,
22+
personal: false,
23+
approval: false,
24+
created_at: 0,
25+
runners: 0,
26+
pending: 0,
27+
labels: b.labels,
28+
placement: b.placement,
29+
max_runners: b.max_runners,
30+
remove_offline_after_minutes: b.remove_offline_after_minutes,
31+
},
32+
secret: "fctl_et_shown_once",
33+
})
34+
: () => new Promise(() => {}),
35+
},
36+
);
37+
return { api: pending, workspaces, ApiFailure: class extends Error {} };
1338
});
1439

1540
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
@@ -20,10 +45,16 @@ afterEach(() => {
2045
document.body.innerHTML = "";
2146
});
2247

23-
function show(node: React.ReactNode, tokens?: G.EnrollmentToken[], demand?: G.WorkspaceDemand) {
48+
function show(
49+
node: React.ReactNode,
50+
tokens?: G.EnrollmentToken[],
51+
demand?: G.WorkspaceDemand,
52+
instance?: Partial<G.InstanceInfo>,
53+
) {
2454
const client = new QueryClient();
2555
if (tokens) client.setQueryData<G.EnrollmentTokenList>(keys.enrollmentTokens(acme.id), { tokens });
2656
if (demand) client.setQueryData<G.WorkspaceDemand>(keys.workspaceDemand(acme.id), demand);
57+
if (instance) client.setQueryData(keys.instance, instance);
2758
const container = document.createElement("div");
2859
document.body.append(container);
2960
const root = createRoot(container);
@@ -263,3 +294,55 @@ describe("pools", () => {
263294
);
264295
});
265296
});
297+
298+
describe("making a pool", () => {
299+
const type = (input: HTMLInputElement, text: string) =>
300+
act(() => {
301+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(input, text);
302+
input.dispatchEvent(new Event("input", { bubbles: true }));
303+
});
304+
const field = (label: string) => {
305+
const l = [...document.querySelectorAll("dialog label")].find((e) => e.textContent === label);
306+
return document.querySelector(`[id="${(l as HTMLLabelElement | undefined)?.htmlFor}"]`) as HTMLElement;
307+
};
308+
309+
it("goes step by step, and a cloud brings what its machines need", async () => {
310+
vi.useFakeTimers();
311+
try {
312+
show(<EnrollmentTokens w={acme} admin onRunners={false} />, [], undefined, { version: "0.38.0" });
313+
act(() => button("New pool").click());
314+
const dialog = () => document.querySelector("dialog[open]")?.textContent ?? "";
315+
expect(dialog()).toContain("Name it");
316+
expect(dialog()).toContain("Choose its labels and machines");
317+
expect(dialog()).toContain("Choose where it runs");
318+
// A preview of the pool once a runner is online, named as the form says.
319+
type(field("Name") as HTMLInputElement, "AWS large");
320+
type(field("Labels") as HTMLInputElement, "aws, large");
321+
expect(dialog()).toContain("Once its first runner is online:");
322+
expect(dialog()).toContain("Idle: its runner runs nothing.");
323+
// A cloud's machines go without uninstalling: they're removed when offline, and packed.
324+
act(() => field("Its machines").click());
325+
const aws = [...document.querySelectorAll<HTMLElement>('[role="option"]')].find((o) =>
326+
o.textContent?.startsWith("AWS"),
327+
);
328+
act(() => aws?.click());
329+
act(() => vi.advanceTimersByTime(1000));
330+
const summary = document.querySelector("dialog [aria-live]")?.textContent ?? "";
331+
expect(summary).toContain("are removed once they have been offline for 5 minutes");
332+
expect(summary).toContain(
333+
"Its runners carry the labels aws and large. Packed: fills one runner before the next, so that idle ones can go.",
334+
);
335+
await act(async () => button("Create pool").click());
336+
expect(dialog()).toContain("AWS large is ready");
337+
expect(dialog()).toContain("Bring it online on AWS");
338+
expect(dialog()).toContain("Add fctl's module to your Terraform");
339+
const code = [...document.querySelectorAll("dialog code")].map((c) => c.textContent).join("\n");
340+
expect(code).toContain("fctl_et_shown_once");
341+
expect(code).toContain('module "fctl_aws_large"');
342+
// The image installs the version this instance runs.
343+
expect(code).toContain('fctl_version = "0.38.0"');
344+
} finally {
345+
vi.useRealTimers();
346+
}
347+
});
348+
});

0 commit comments

Comments
 (0)