Name the sizes a node can ask for

Raw cpus and gpus are a property of the machines an installation has, so a node
written against a cluster quietly stops meaning anything when the cluster is
replaced. A node says "gpu-small" instead, and what that is stored here —
editable, and read again every time the node is built, so changing the flavor
changes what the next run gets.

Memory joins the schema properly (`ram`, in MB, accepting "2G"), along with
`duration_s` for how long a node is expected to take. That one is recorded and
shown and nothing else yet: a statement for whoever is planning around the node,
not a limit — the limit is still `timeout`.

A flavor and a number for the same thing is refused, compared by value so an
editor writing the whole object back with its defaults still round-trips. A name
nothing stores is refused at the save, which covers the canvas and `fluksio
sync` at once, and deleting one a node still asks for says which node.

Four sizes are seeded on an installation that has none, and never re-seeded:
re-adding one somebody deliberately removed is an argument nobody wins.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A6HeySA27EkGANZN95QySW
This commit is contained in:
2026-08-27 08:59:10 +02:00
co-authored by Claude Opus 5
parent 6ff56533f5
commit a82f88cf0a
15 changed files with 720 additions and 19 deletions
+52
View File
@@ -462,3 +462,55 @@ class RunArtifact(SQLModel, table=True):
default_factory=lambda: datetime.now(UTC),
sa_type=UTCDateTime,
)
# -----------------------------------------------------------------------------
# Flavors
# -----------------------------------------------------------------------------
class FlavorBase(SQLModel):
"""A named amount of machine, so a node can ask for one by name.
The point is not to save typing. Cores and megabytes are a property of the
machines an installation actually has, and they change when those machines
do — so a node saying "gpu-small" keeps meaning something after the cluster
is replaced, where a node saying 8 and 16384 quietly stops.
"""
cpus: int = Field(default=1, ge=1)
gpus: int = Field(default=0, ge=0)
#: Megabytes. A flavor always says, which is what a node asking for one is
#: buying — the raw form leaves memory unstated and unaccounted.
ram: int = Field(default=2048, ge=1)
description: str = Field(default="", max_length=255)
class Flavor(FlavorBase, table=True):
"""A resource size somebody named, stored so nodes can refer to it."""
__tablename__ = "flavor"
name: str = Field(primary_key=True, max_length=64)
class FlavorCreate(FlavorBase):
name: str = Field(max_length=64)
class FlavorUpdate(SQLModel):
"""Everything but the name: renaming would orphan the nodes that ask."""
cpus: int | None = Field(default=None, ge=1)
gpus: int | None = Field(default=None, ge=0)
ram: int | None = Field(default=None, ge=1)
description: str | None = Field(default=None, max_length=255)
class FlavorPublic(FlavorBase):
name: str
class FlavorsPublic(SQLModel):
data: list[FlavorPublic]
count: int