flip_api.db.seed.fl_kit_slots
Attributes
Functions
|
Extract the trailing integer from a slot name ( |
|
Resolve the configured FL kit-slot names from their environment's single source. |
|
Insert a row for each slot name not already in the |
|
Populate the |
Module Contents
- flip_api.db.seed.fl_kit_slots._FL_KIT_SLOT_NAMES_PARAMETER = '/flip/fl_kit_slot_names'
- flip_api.db.seed.fl_kit_slots._SLOT_NUMBER_RE
- flip_api.db.seed.fl_kit_slots._NON_NUMERIC_SLOT_NUMBER = 10000
- flip_api.db.seed.fl_kit_slots._slot_number(slot_name: str) int
Extract the trailing integer from a slot name (
Trust_007→7).Slots are conventionally named with a trailing
_<N>so the Flower side can pick a per-supernode key with the matchingsupernode_credentials_<N>suffix. Returns_NON_NUMERIC_SLOT_NUMBERfor names without a trailing integer so they sort after all conventionalTrust_Nslots in the free-slot claim queue.
- flip_api.db.seed.fl_kit_slots.resolve_fl_kit_slot_names() list[str]
Resolve the configured FL kit-slot names from their environment’s single source.
In production the source is the
/flip/fl_kit_slot_namesSSM parameter (a JSON list string, rendered by Terraform from the env file’sFL_KIT_SLOT_NAMES), so the pool can grow via a targeted apply of just that parameter without a task-definition change or restart. In development the source is theFL_KIT_SLOT_NAMESenv var (aDevSettings-only field).Deliberately no prod fallback: a failure to fetch or parse the parameter returns an empty list — the boot seed and the registration reconcile are additive, so existing pool rows and assignments are untouched; the pool simply cannot grow until the parameter is fixed, and nothing stale masks that. The log level splits the two situations: a missing parameter is a not-yet-provisioned source (WARNING); any other AWS error or a malformed value means the source of truth is broken (ERROR).
Note the pre-activation state is ERROR, not WARNING:
make apply-fl-kit-slotscreates the parameter and grants the task role’sssm:GetParameter, so an image deployed before that apply getsAccessDeniedException(ERROR) rather thanParameterNotFound— observed on stag 2026-07-14. Either way the pool is intact and the log names the fix.- Returns:
The configured slot names; empty when none are configured or the parameter is unreadable.
- Return type:
list[str]
- flip_api.db.seed.fl_kit_slots.insert_missing_slots(session: sqlmodel.Session, slot_names: list[str]) list[str]
Insert a row for each slot name not already in the
fl_kit_slotpool.Additive only — never deletes, re-assigns, or un-assigns rows; operators rely on the assignment table to be stable. Does not commit: the caller owns the transaction (boot seeding commits; register_trust’s reconcile shares the registration transaction).
- Parameters:
session (Session) – The SQLModel session used for reads and inserts.
slot_names (list[str]) – The configured slot names to ensure exist.
- Returns:
The slot names that were newly inserted.
- Return type:
list[str]
- flip_api.db.seed.fl_kit_slots.seed_fl_kit_slots(session: sqlmodel.Session) None
Populate the
fl_kit_slotpool from the resolved slot names.Inserts one row per configured slot name if not already present. Never deletes, re-assigns, or un-assigns rows — operators rely on the assignment table to be stable across restarts.
register_trustclaims a free slot atomically when a trust is registered, so the seed has no slot→trust binding to do.- Parameters:
session (Session) – The SQLModel session used for reads and inserts.