Reverse-specification of masakari — branch stable/2026.2
Branch
stable/2026.2@ae41528e1ebc— repository https://opendev.org/openstack/masakari — analysed on 2026-10-28
- Repository: https://opendev.org/openstack/masakari (local clone) — specified branch:
stable/2026.2@ae41528e1ebc(22.0.0-2-gae41528, commit of 2026-09-09) — analysed on: 2026-10-28 - Scope: the whole project (API, engine, taskflow driver, database, CLI), plus the rewrite pack (step 8). The client expectations include masakari-monitors
stable/2026.2@b792a7ae040a, openstacksdkinstance_ha@fbdc40381and python-masakariclient @073cd2c. The change history (step 7) was not requested.
Overview
Masakari provides instance high availability for Nova. Detectors (masakari-monitors, or any client) report failures as notifications of three types: a compute host down, an instance crashed, or a process (nova-compute) died. masakari-api records them and casts them to masakari-engine. The engine runs recovery workflows (taskflow) that drive Nova with an admin service account:
- host: disable the compute service, then evacuate the host's instances, either where Nova decides or to reserved spare hosts of the same failover segment;
- instance: stop and start the instance;
- process: disable the compute service.
Segments and hosts are configuration managed through the same API. The engine keeps per-instance evacuation records (vmoves) and per-task progress, and two periodic tasks retry failed notifications and expire old ones. Dependencies are MariaDB (two databases: Masakari and taskflow persistence), RabbitMQ, Keystone, Nova and optionally a tooz backend.
Architecture
flowchart LR
mon[masakari-monitors / detector] -->|HTTPS POST /v1/notifications| api[masakari-api]
admin[Operator / openstack CLI] -->|HTTPS /v1/segments, hosts| api
api -->|SQL| db[(MariaDB masakari)]
api -->|AMQP cast process_notification, call workflow details| mq{{RabbitMQ topic ha_engine}}
mq --> eng[masakari-engine]
eng -->|SQL| db
eng -->|SQL taskflow logbooks| tf[(MariaDB taskflow)]
api -->|REST os-services check| nova[nova-api 2.53]
eng -->|REST services, servers, evacuate, lock, stop/start, aggregates| nova
api -->|token| ks[Keystone]
eng -->|token per Nova call| ks
api -.->|lock create_host_notification| tooz[(tooz backend, optional)]
api -.->|versioned notifications| mq
eng -.->|versioned notifications| mqProcesses
| Process | Entry point | Role | Listens to / consumes |
|---|---|---|---|
| masakari-api | masakari/cmd/api.py:49 (eventlet WSGI server, port 15868) or masakari/wsgi/api.py:24 (uWSGI/mod_wsgi) | REST API /v1 | HTTP |
| masakari-engine | masakari/cmd/engine.py (service.Service.create(binary='masakari-engine', topic=CONF.masakari_topic)) | RPC server, recovery workflows, periodic tasks | AMQP ha_engine, ha_engine.<host>, fanout |
| masakari-manage | masakari/cmd/manage.py | db sync, db version, db purge | — |
| masakari-status | masakari/cmd/status.py:26 | upgrade checks | — |
External dependencies
| System | Protocol | Library | Configuration | Usage |
|---|---|---|---|---|
| MariaDB | SQL | oslo.db | [database]/connection | segments, hosts, notifications, vmoves |
| MariaDB | SQL | taskflow persistence | [taskflow]/connection | workflow logbooks, task progress |
| RabbitMQ | AMQP | oslo.messaging | transport_url, [oslo_messaging_notifications] | RPC api→engine, versioned notifications |
| Keystone | REST v3 | keystonemiddleware, keystoneauth1 | [keystone_authtoken], os_privileged_user_* | incoming tokens; service token for Nova |
| Nova | REST 2.53 | python-novaclient | nova_catalog_admin_info, os_region_name | compute services, servers, evacuation |
| tooz | per backend | tooz | [coordination]/backend_url | API lock per host name (optional) |
Key figures
- 19 REST operations: 17 on resources under
/v1, plusGET /andGET /v1. The 21 routes of_rewrite/routes_stable-2026.2.jsonadd the/v1/and/v1/versions/{id}aliases. The api-ref documents 17 operations. Microversions 1.0–1.3. All policies are admin-only (27 rules). - 2 RPC methods received by the engine (
process_notificationcast 1.0,get_notification_recovery_workflow_detailscall 1.1), 2 periodic tasks, 5 polling loops on Nova inside the workflows. - 8 taskflow tasks (plus
no_op) in 3 flows, recovery methodsauto,reserved_host,auto_priority,rh_priority. - 55 exception classes, 4 tables (+3 taskflow tables), 3 alembic revisions, 11 Nova operations.
- 382 references checked by
check_refs.py(0 problems) ([_verification_stable-2026.2.md](_verification_stable-2026.2.md)); 23 scenarios, 201 HTTP exchanges, 143 Nova requests recorded.
Files
| File | Content |
|---|---|
| 01-rest-api_stable-2026.2.md | endpoints, functional descriptions, lifecycles |
| 02-errors_stable-2026.2.md | exceptions, HTTP translation, asynchronous errors, logs |
| 03-interactions_stable-2026.2.md | Nova, Keystone, RabbitMQ, databases, tooz |
| 04-scenarios_stable-2026.2.md | sequence diagrams of the recovery flows |
| 05-async-processing_stable-2026.2.md | engine: RPC consumers, periodic tasks, workflows |
| 07-rewrite-pack_stable-2026.2.md | rewrite pack: algorithm, client expectations (masakari-monitors), strategies; data in _rewrite/ |
| _verification_stable-2026.2.md | reference check |
Points of attention
- Fallback and retry of host recovery cannot succeed once a vmove has failed (observed): the failed rows of earlier attempts are counted (
masakari/engine/drivers/taskflow/host_failure.py:424).auto_priority/rh_prioritytherefore reporterroreven when the second method evacuated the instance. - Non-HA instances are evacuated first with the default
evacuate_all_instances = true, against the documentation (vmoves read newest first,masakari/engine/drivers/taskflow/host_failure.py:350; observed). - No coordination between engines: the periodic tasks run in every engine, and the per-host lock is process-local (
masakari/engine/manager.py:274). With several engines,errornotifications are retried in parallel. - **A host stays
on_maintenanceforever** after any processed host or process failure, including a process that Masakari does not handle (masakari/engine/manager.py:90). Its next failure is refused with 409, and masakari-monitors drops 409s silently. - Duplicate detection matches any status, uses the sender's clock, and is not atomic. Without tooz, every
POST /notificationssleeps 0–5 s (masakari/ha/api.py:359). - API errors that turn into a misleading or unexpected status:
GET …/vmoves/{id}→ 500 for an unknown notification;- a Nova 5xx during host create → 500;
- a Nova 403 is passed through as 403;
- the microversion 1.3 of vmoves is not enforced;
- pagination markers are integer ids, not UUIDs.
- Nova client: a new Keystone token per call, no timeout, one page of servers (≤ 1000) per host, and an empty service list in the engine →
IndexError→ generic error. - The VM flow restarts instances that were stopped on purpose on an IO error.
PROCESS STOPPEDfor a non-nova-compute process still sets maintenance. - Orphan data: vmoves are never purged, and the taskflow database is never purged.
- For OpenKeel ("Masakari with node health checks"):
masakari-monitorsalready has a Kubernetes host check (masakari-monitors:masakarimonitors/hostmonitor/kubernetes_check/manager.py:36). It sendsCOMPUTE_HOST STOPPED host_status=NORMALkeyed by node name. A Medik8s-based detector must send the same contract, and the Kubernetes node name must equal the Masakari host name and the Nova (KubeVirt) compute host.host_status=NORMALis the assertion that the node is fenced: Masakari never fences, and only refusesUNKNOWN. Self-node-remediation must therefore have completed before the notification is sent [inferred].
Blind spots / [inferred]
- No real Nova, RabbitMQ, MySQL or Keystone was used. Nova timing (service-down detection before evacuation) and multi-engine races are inferred from the code. The scenarios use fakes, with sleeps set to 0 and timeouts to 3 s.
- The functional tests (
masakari/tests/functional, openstacksdk against devstack) were not run. - keystonemiddleware was left out of the scenario pipeline: token validation errors are described from the paste pipeline, not observed.
- Third-party taskflow tasks plugged through
masakari.task_flow.tasksare not covered. - The masakari-dashboard (Horizon plugin) was not read.
Source: reverse-spec-masakari/00-summary_stable-2026.2.md. The _rewrite/ and _inventory/ files are not published on the site.