swarm-controller: move the forge concern into its own module
Refs #6897
This commit is contained in:
parent
ca16980a06
commit
a9df331469
37 changed files with 44 additions and 37 deletions
|
|
@ -83,7 +83,7 @@ needs `deploy.forgejo.enable` or a hive on its host.
|
|||
|
||||
## Registration
|
||||
|
||||
1. **swarm-controller** (`swarm-controller/src/forge/runner_token.rs`) reads
|
||||
1. **swarm-controller** (`swarm-controller/src/git_forge/forge/runner_token.rs`) reads
|
||||
the forge's instance-wide token from
|
||||
`GET /api/v1/admin/runners/registration-token` at start and every five
|
||||
minutes, and writes it to the secret store at
|
||||
|
|
@ -163,7 +163,7 @@ warns about it.
|
|||
<!-- vale write-good.Passive = YES -->
|
||||
|
||||
The **swarm controller** seeds the mirror in its swarm-wide forge-objects
|
||||
pass (`swarm-controller/src/forge/objects.rs`), beside the orgs it ensures.
|
||||
pass (`swarm-controller/src/git_forge/forge/objects.rs`), beside the orgs it ensures.
|
||||
`glue-forge-controller.nix` forwards the effective mirror list as
|
||||
`SWARM_CONTROLLER_FORGE_MIRRORS` in the `swarm-controller` service
|
||||
environment (JSON-encoded `[{upstream, dest}]` list). It reads the list of
|
||||
|
|
@ -287,7 +287,7 @@ builder — disk-pressure collection at least runs while nothing is mid-copy.
|
|||
## References
|
||||
|
||||
- `nix/host-modules/swarm-ci-runner.nix`: runner configuration, token fetch, re-registration step, container setup.
|
||||
- `swarm-controller/src/forge/runner_token.rs`: publishes the registration token.
|
||||
- `swarm-controller/src/git_forge/forge/runner_token.rs`: publishes the registration token.
|
||||
- `.forgejo/workflows/ci.yml`: workflow definition.
|
||||
- `docs/5-project/process/gotchas.md`: nix sandboxing limitations in containers.
|
||||
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ drops it unanswered, which reads as a 504. `swarmctl agent agents-md get` and
|
|||
|
||||
The controller also keeps the forge objects that are one per swarm, not
|
||||
one per hive. It ensures them at start and every five minutes after
|
||||
(`swarm-controller/src/forge/objects.rs`):
|
||||
(`swarm-controller/src/git_forge/forge/objects.rs`):
|
||||
|
||||
- the orgs `agent-configs`, `internal` and `agents`, plus each mirror's
|
||||
owner org;
|
||||
|
|
@ -411,12 +411,12 @@ one per hive. It ensures them at start and every five minutes after
|
|||
|
||||
The config repos get the agent's icon too. When a build sets the agent's icon,
|
||||
the controller sets the avatar of `agent-configs/<agent>` from the PNG the
|
||||
builder rendered (`forge/repo_avatar.rs`), as the forge admin, who may edit any
|
||||
builder rendered (`git_forge/forge/repo_avatar.rs`), as the forge admin, who may edit any
|
||||
repo's avatar. A marker per repo (`forge-repo-avatar-<repo>`) holds the image's
|
||||
SHA-256, as for the service accounts below.
|
||||
|
||||
The swarm's own forge accounts (`builder`, `ci-metrics` and `review-classifier`)
|
||||
get an avatar too, from a separate pass in the controller (`forge/service_avatars.rs`).
|
||||
get an avatar too, from a separate pass in the controller (`git_forge/forge/service_avatars.rs`).
|
||||
Each has an icon in a hexagonal frame (`branding/service-<login>.svg`, rendered to a PNG
|
||||
in the assets package) and falls back to the hyperhive logo. Only an account can set its own
|
||||
avatar, so the pass mints a short-lived `write:user` token for it with the admin API, uploads
|
||||
|
|
@ -433,7 +433,7 @@ controller is down the objects stay as they are.
|
|||
|
||||
The controller gives each agent **read** on `internal/docs`. A `GrantDocsRead`
|
||||
node in the agent's create job adds it as a collaborator, unless it already holds read or more. A pass over the
|
||||
store's `hive-agent-*` roster (`forge/docs_grant.rs`, at start and every five
|
||||
store's `hive-agent-*` roster (`git_forge/forge/docs_grant.rs`, at start and every five
|
||||
minutes) adds any agent that isn't one, so an agent whose create-time grant failed
|
||||
gets it within five minutes. The pass only adds: a roster it can't read, a
|
||||
forge read that fails, or an `internal/docs` that doesn't exist (checked once per
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ in
|
|||
lib.mkDefault "https://forge.darkest.space/hyperhive/hyperhive";
|
||||
|
||||
# JSON-encoded list of { upstream, dest }, seeded by the controller's
|
||||
# forge-objects pass (`swarm-controller/src/forge/objects.rs`).
|
||||
# forge-objects pass (`swarm-controller/src/git_forge/forge/objects.rs`).
|
||||
systemd.services.swarm-controller.environment.SWARM_CONTROLLER_FORGE_MIRRORS =
|
||||
builtins.toJSON deployCfg.forgejo.effectiveMirrors;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -220,17 +220,17 @@ let
|
|||
|
||||
# Unconditional: every swarm has a forge, reached by name wherever it runs.
|
||||
# The token is not here: the daemon reads it from the swarm's secret store at
|
||||
# start (`forge.rs`), and re-reads it in the background until it is there.
|
||||
# start (`git_forge/forge.rs`), and re-reads it in the background until it is there.
|
||||
forgeEnv = {
|
||||
SWARM_CONTROLLER_FORGE_URL = "https://${forgeCfg.domain}";
|
||||
# `agent-configs` org avatar for the forge-objects pass
|
||||
# (`forge/objects.rs`). Only meaningful with forge access, hence here.
|
||||
# (`git_forge/forge/objects.rs`). Only meaningful with forge access, hence here.
|
||||
SWARM_CONTROLLER_CONFIG_ORG_AVATAR_PNG =
|
||||
if deployCfg.swarm-controller.configOrgAvatarPng != null then
|
||||
"${deployCfg.swarm-controller.configOrgAvatarPng}"
|
||||
else
|
||||
"${config.services.hyperhive.deploy.hive-controller.assets}/share/hyperhive/branding/agent-configs.png";
|
||||
# The swarm services' own forge accounts' avatars (`forge/service_avatars.rs`).
|
||||
# The swarm services' own forge accounts' avatars (`git_forge/forge/service_avatars.rs`).
|
||||
SWARM_CONTROLLER_SERVICE_ICON_DIR = "${config.services.hyperhive.deploy.hive-controller.assets}/share/hyperhive/branding";
|
||||
};
|
||||
|
||||
|
|
@ -1020,7 +1020,7 @@ in
|
|||
|
||||
# `AF_UNIX` for the socket this daemon serves on, plus what its
|
||||
# outbound clients need: it mints authelia tokens and calls the forge
|
||||
# over HTTPS (`auth.rs`, `forge.rs`) and reaches the queue over NATS
|
||||
# over HTTPS (`auth.rs`, `git_forge/forge.rs`) and reaches the queue over NATS
|
||||
# (`startup.rs`, `status.rs`). `AF_NETLINK` because glibc's
|
||||
# `getaddrinfo` opens a netlink socket to enumerate local addresses
|
||||
# before it will return one.
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ async-nats = { workspace = true, features = ["kv"] }
|
|||
axum.workspace = true
|
||||
# Builds every forgejo-api client (`forge/`), so the construction lives once.
|
||||
forge-client.workspace = true
|
||||
# swarm-controller's own forge client (`forge.rs`) — self-contained,
|
||||
# swarm-controller's own forge client (`git_forge/forge.rs`) — self-contained,
|
||||
# deliberately not sharing code with `hive-c0re::forge` across the crate
|
||||
# boundary (see #3306's design discussion: forcing that split now, over a
|
||||
# few idempotent CRUD-ish calls, is premature plumbing).
|
||||
forgejo-api.workspace = true
|
||||
# `forge.rs` encodes file content for its `repo_change_files` calls and
|
||||
# `git_forge/forge.rs` encodes file content for its `repo_change_files` calls and
|
||||
# decodes blobs it reads: forgejo's content and blob APIs carry base64,
|
||||
# never raw bytes.
|
||||
base64.workspace = true
|
||||
|
|
@ -64,7 +64,7 @@ hive-jobq-metrics.workspace = true
|
|||
opentelemetry.workspace = true
|
||||
opentelemetry_sdk.workspace = true
|
||||
opentelemetry-otlp.workspace = true
|
||||
# The forge webhook HMAC (`webhook.rs`). Kept in this crate rather than
|
||||
# The forge webhook HMAC (`git_forge/webhook.rs`). Kept in this crate rather than
|
||||
# shared with hive-c0re's equivalent: c0re's copy is scheduled to be deleted
|
||||
# with its webhook routes once registration moves here, so the second holder
|
||||
# is departing, not arriving — see that module's docs.
|
||||
|
|
@ -72,7 +72,7 @@ hmac.workspace = true
|
|||
sha2.workspace = true
|
||||
# The `{SHA}` htpasswd line `archive_access.rs` writes for the archive server.
|
||||
sha1.workspace = true
|
||||
# `forge/pull_diff.rs` diffs a PR's changed files itself, at a context width
|
||||
# `git_forge/forge/pull_diff.rs` diffs a PR's changed files itself, at a context width
|
||||
# the forge's own `.diff` does not offer.
|
||||
similar.workspace = true
|
||||
# The `Permission` names `/api/agents/{name}/permissions` accepts, the same
|
||||
|
|
@ -84,7 +84,7 @@ similar.workspace = true
|
|||
# defense-in-depth, not the only gate (per an argus review finding).
|
||||
hive-types.workspace = true
|
||||
# `auth`'s bridge client — same crate the bridge itself uses to define the
|
||||
# request/response shape, so the two ends cannot drift. `forge.rs` also
|
||||
# request/response shape, so the two ends cannot drift. `git_forge/forge.rs` also
|
||||
# uses this directly for `StatusCode` in its error-classification helpers.
|
||||
#
|
||||
# `blocking` on top of the workspace default: `vcs_metrics`'s OTLP exporter
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue