swarm: set an agent's config repo avatar from its icon
The agent module exposes the PNG nix renders from the agent's icon as the read-only option services.hyperhive.agent.iconPng, which the forge and matrix avatar syncs now share. When the builder reads an icon it builds that one attribute with nix build and sends the file, base64, next to the SVG in the meta build reply, so the builder runs no renderer of its own. After recording the icon, the controller sets the avatar of agent-configs/<agent> from the PNG as the forge admin, removes the avatar when the icon is removed, and leaves it alone when the builder sent no PNG. A marker per repo holds the image's fingerprint, so a build whose icon did not change makes no forge call; a forge that refuses the avatar does not fail the build. An old builder sends no PNG, so it changes nothing.
This commit is contained in:
parent
8a0615ccfc
commit
1a31a4cd5a
2 changed files with 499 additions and 25 deletions
|
|
@ -322,15 +322,28 @@ closure record. The same `nix eval` reads the SVG file the option names (the eva
|
|||
applies `builtins.readFile`, so the builder needs no store path), and the reply's
|
||||
`icon` is one of:
|
||||
|
||||
- `set` with the SVG's text, for an option that names a file of at most 256 KiB;
|
||||
- `set` with the SVG's text, for an option that names a file of at most 256 KiB,
|
||||
and `png`, the 512 by 512 pixel PNG nix renders from it
|
||||
(`services.hyperhive.agent.iconPng`, the image the agent uploads as its own
|
||||
avatar). The builder builds that one attribute with `nix build` and reads the
|
||||
file, so it runs no renderer of its own, and the reply carries it as base64
|
||||
when it's at most 256 KiB. A PNG that doesn't build or read back leaves `png`
|
||||
out and still sends the SVG;
|
||||
- `unset`, for a null option or a module that doesn't declare it;
|
||||
- left out, for a failed eval, a timeout, an empty file or an oversize one.
|
||||
|
||||
The controller writes the key `<agent>` of the `agent-icons` KV bucket from a
|
||||
`set`, deletes it on `unset` and leaves it on a missing field. The controller logs a write
|
||||
that fails and doesn't fail the build or the deploy. An agent's icon changes when
|
||||
the swarm builds and deploys its config, not when its container restarts, and an
|
||||
agent that has never run has one as soon as its first build succeeds.
|
||||
`set`, deletes it on `unset` and leaves it on a missing field. The controller
|
||||
logs a write that fails and doesn't fail the build or the deploy. The controller
|
||||
also sets the avatar of the agent's config repo (`agent-configs/<agent>`) from
|
||||
`png`, and removes it on `unset`; a `set` without a `png` leaves the avatar as
|
||||
it is. A marker per repo in the controller's state directory
|
||||
(`forge-repo-avatar-<repo>`) holds the image's SHA-256, so a build whose icon
|
||||
didn't change makes no forge call, and `unset` deletes only an avatar the
|
||||
controller set. A forge that refuses the avatar fails nothing; the next build
|
||||
tries again. An agent's icon changes when the swarm builds and deploys its
|
||||
config, not when its container restarts, and an agent that has never run has one
|
||||
as soon as its first build succeeds.
|
||||
|
||||
Mixed versions:
|
||||
|
||||
|
|
|
|||
|
|
@ -409,6 +409,12 @@ one per hive. It ensures them at start and every five minutes after
|
|||
- the `agent-configs` org avatar
|
||||
(`deploy.swarm-controller.configOrgAvatarPng`).
|
||||
|
||||
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
|
||||
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`).
|
||||
Each has an icon in a hexagonal frame (`branding/service-<login>.svg`, rendered to a PNG
|
||||
|
|
|
|||
Loading…
Reference in a new issue