randomparity / randomparity/kdive
Add ResourceKind.BYO_HOST, its migration, inventory schema, and provider package skeleton
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 26m
- Merged PRs (30d)
- 311
Description
Part of #1814
## Problem
Nothing in KDIVE can represent a bring-your-own host. There is no `ResourceKind` for it, no
`systems.toml` block that declares one, no reconcile arm that creates the row, and no provider
package the resolver can bind. Every later plane in this epic attaches to that skeleton.
These pieces **cannot be split into separate PRs**: the resource-kind parity tests assert the
database CHECK set and the buildable runtime registry agree exactly, so a migration that admits a
kind with no registered runtime fails CI on the spot.
## Evidence
- `tests/db/test_resource_kind_parity.py:25` — `test_check_admits_all_three_kinds` asserts the
CHECK set by **exact equality**, so widening the CHECK alone reddens it.
- `tests/db/test_resource_kind_parity.py:33` —
`test_every_check_allowed_kind_has_a_buildable_runtime` asserts `allowed <= buildable` and
resolves every admitted kind, so the runtime must exist in the same change.
- `docs/design/m2-remote-libvirt.md:258` states this rule, and M2's issue 1 was cut the same way
(kind + migration + package skeleton + composition registration in one PR).
- `src/kdive/domain/catalog/resources.py:17` — the `ResourceKind` enum.
- `src/kdive/db/schema/0020_resources_kind_remote_libvirt.sql:9` — the CHECK-widen precedent.
- `src/kdive/db/schema/0032_remote_cost_class_coefficient.sql:1-9` — **the record of this exact bug
shipping once**: a cost class with no seeded coefficient made every remote allocation fail closed
with `configuration_error`. BYO must seed its coefficient in the same migration.
- `src/kdive/db/schema/0111_restrict_pinned_job_deletion.sql` — the current head; ADR-0517 requires
strictly ascending migration numbers across merges, so this lands early and alone.
- `src/kdive/inventory/model.py:208` (`RemoteLibvirtInstance`), `:283` (`InventoryDoc` fields).
- `src/kdive/inventory/reconcile/resources.py:150` (`reconcile_resources`), `:246`
(`_remote_libvirt_upsert`) — the reconcile arm precedent.
- `src/kdive/providers/core/discovery_registration.py:39` — `creates` flag; BYO is `creates=False`
(bind-only), because an operator-declared host must never be discovered into existence.
- `src/kdive/providers/assembly/composition.py:228` — the `_RuntimeDescriptor` table.
## Expected outcome
- `ResourceKind.BYO_HOST = "byo-host"`.
- One migration: CHECK widen **plus** a seeded cost-class coefficient (idempotent
`ON CONFLICT DO NOTHING`, matching `0032`).
- `ByoHostInstance` in the inventory model with `name`, `arch`, `ssh_target`, a `[byo_host.oob]`
sub-table (`kind` = `redfish`|`ipmi`|`hmc`, `endpoint`, credential refs, `managed_system` /
`lpar_name` for HMC), `baseline_kernel`, required `vcpus`/`memory_mb`, `cost_class`, `pool`,
`concurrent_allocation_cap`; registered on `InventoryDoc`; reconcile arm; `systems.toml.example`
block with the same documentation density as the existing entries.
- `src/kdive/providers/byo_host/` with a buildable `ProviderRuntime` whose ports are fail-closed
stubs, registered as a `_RuntimeDescriptor` and gated on operator configuration.
- `reconcile-systems --check` accepts a valid block and rejects a malformed one with
`entry.field: msg`, still touching neither Postgres nor S3 (ADR-0121).
- Resource-kind parity tests green.
Blocked by #1815
Contributor guide
Research direction
Start with src/kdive/domain/catalog/resources.py, the cited migration precedents, inventory models, reconcile_resources, and the runtime descriptor table. Run the resource-kind parity tests and inspect the existing remote-libvirt path and systems.toml.example. Done means the migration, inventory and reconcile support, buildable gated provider skeleton, validation behavior, and parity tests all agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 32/100