Repository navigation
feat(compute): write clusters and machines down once in compute.yaml - #1762
Merged
Merged
Conversation
A cluster exists whether or not a daemon uses it, but it could only be written down inside a daemon's workspace, once per workspace. compute.yaml, read from home only, now holds the clusters and standalone machines sessions run on, and a workspace names its compute with `compute`. Loading resolves each such workspace with its compute's kind and connection: a cluster's kubeconfig, context, namespace, mode and gateway_env, or a machine's address, token and tls. A workspace that repeats a key its compute sets, sets its own kind, or names compute that is not defined fails at startup. Workspaces that carry their own connection work as before. Every workspace on one standard-mode cluster now shares that cluster's Gateway and credentials Secret, labelled with the cluster, instead of deploying one each. A workspace without compute keeps the Gateway it always had. infer daemon workspaces shows the compute each workspace runs on. Refs #1761
4 tasks
edenreich
added a commit
that referenced
this pull request
Nov 8, 2026
…1763) Closes #1761 Follows #1762, which is merged. This branch is rebased onto `main` with only its own two commits. ## Summary Compute gets its own bounded context, and the CLI gets commands for it. - `internal/compute` holds the GPU model and its rules in `domain/`. `infrastructure/runpod` translates RunPod's API into that domain, and `infrastructure/kubernetes` connects to a cluster and checks it. - `infer compute clusters` and `infer compute machines` add, list, check and remove what is in `compute.yaml`. - `infer gpu` becomes `infer compute gpus`, and the old name stays as a hidden, deprecated alias. ```text infer compute clusters add | list | status | remove infer compute machines add | list | status | remove infer compute gpus provision | list | status | destroy ``` ## Changes - **GPUs** - `internal/provisioner` moves to `internal/compute/infrastructure/runpod`. RunPod's JSON stays in private wire structs, and every method returns domain values: GPU types, instances and provision requests. - `internal/compute/domain` has the GPU rules: the hourly price (community, else secure), the spending cap, and uptime and spend so far. `infer gpu` repeated the price rule in two places, and both now use the domain's. - The RunPod API key is `RUNPOD_API_KEY` in the environment or `~/.infer/auth.yaml`, and a key asked for on first use is saved there by the new `config.SetAuthKey`, which keeps the other entries and the file at `0600`. GPU defaults and `max_hourly` move under `gpus` in `compute.yaml`. - The old `provisioner` block and key in `config.yaml`, or `INFER_PROVISIONER_RUNPOD_API_KEY`, still work with a warning that points at the new place. - The commands print through the command instead of `fmt.Printf`, so tests can capture their output. - **Clusters and machines** - `internal/compute/infrastructure/kubernetes` builds a cluster's clients, checks it runs the operator, reads its Kubernetes version and reports its status. The agent's Kubernetes workspace now connects and checks through it, and its errors read word for word as before. - Each session's Orchestrator is labelled with its cluster, so `infer compute clusters status` counts the sessions of every workspace on it. - `add` and `remove` edit `compute.yaml` as written, through a loader that does not expand `${VAR}`, so a reference is saved back as a reference and never as the secret. `remove` refuses compute a workspace in `daemon.yaml` still runs on. - `status` checks every cluster or machine at once, each with its own timeout and its own result slot. A machine is probed the way the daemon probes a daemon-kind workspace. `machines list` never prints a token. - A cluster name must be a Kubernetes label value, because it labels the Gateway and the sessions. - **Wiring** - The depguard rule for client-go also allows compute's Kubernetes adapter. - `infer --help` lists compute under a Platform group. - AGENTS.md lists the compute context and the `computedomain` alias. - **Docs:** the commands reference, the configuration reference and the `gpu-provisioning` example move to `infer compute`. ## Verification - An in-memory test drives `infer compute` through a fresh state and `SetArgs`. It adds a cluster and a machine, refuses a duplicate name and a missing namespace, keeps a `${VAR}` token as written and out of `machines list`, refuses to remove a cluster a workspace uses, and removes a machine. - Unit tests cover the domain rules, the RunPod adapter, RunPod key precedence, GPU settings with the legacy fallback, `SetAuthKey`, cluster status against a fake cluster with and without the operator, the compute label on Orchestrators, and concurrent checks keeping their order. - A smoke run against a throwaway home added, listed and removed compute, and reported an unreachable cluster and machine as rows. - `go test ./...` passes, the new packages pass under `-race`, the pre-commit hook passes, and `task test:e2e` passes. ## Not done here - `examples/gpu-provisioning/.env.example` still names `INFER_PROVISIONER_RUNPOD_API_KEY`, which works with a warning. My permissions do not allow reading files named `.env*`, so renaming it to `RUNPOD_API_KEY` is left to a follow-up. - The desktop still writes each workspace's connection itself. inference-gateway/desktop#474 moves its Compute tab onto `compute.yaml`. Docs follow-up: inference-gateway/docs#1131.
Contributor
|
🎉 This PR is included in version 0.249.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1761
Summary
A cluster exists whether or not a daemon uses it, but it could only be written down inside a daemon's workspace, once per workspace. Twelve agents on one cluster meant twelve copies of its context, namespace and gateway keys, and twelve Gateways, because every standard-mode workspace deployed its own.
~/.infer/compute.yamlnow holds the clusters and standalone machines sessions run on, and a workspace names its compute withcompute:This is the first of two PRs for #1761. The second, stacked on this one, adds the
internal/computecontext and theinfer computecommands.Changes
config/compute.go:ComputeConfigholdsclusters(name,kubeconfig,context,namespace,mode,gateway_env) andmachines(name,address,token,tls).Validaterequires unique names across both, a namespace on every cluster, an address on every machine, and a valid mode.ResolveComputefills every workspace that names its compute with that compute's kind and connection. A workspace that sets its own kind, repeats a key its compute sets, or names compute that is not defined fails at startup. The gateway_env slice is copied, so workspaces on one cluster never share it.cmd/runtime:compute.yamlis a home-only sidecar, andloadConfigvalidates it and resolves the workspaces before the full validation. Startup and the in-chat reload both run it on a freshly decoded config.config/daemon.go:WorkspaceEntrygainscompute, and the mode check is shared with clusters.internal/agent/infrastructure/kubernetes:inference-gateway.com/computeinstead of with one workspace's name.computekeeps the Gateway name it always had, so existing Gateways are untouched.infer daemon workspacesgains a COMPUTE column, from a newcomputefield on the workspace status.docs/daemon.md, andcompute.yamlin the configuration reference and the directory structure.Verification
compute.yamlfrom home, ignores a project one, and resolves a workspace throughloadConfig.ensureGatewayand finds one Gateway with both sessions as owners and the cluster label. A workspace named like the cluster but with its own connection keeps its own Gateway.go test ./...passes, the new packages pass under-race, and the pre-commit hook passes.task test:e2epasses on the stacked branch, which contains this commit.Docs follow-up: inference-gateway/docs#1131.