Trilio Site Recovery for OpenStackOpenStack native DR service
Guide

API Layer

WSGI application, routing, and request lifecycle


Overview

This page describes the Trilio Site Recovery WSGI application layer: how the API is structured, how requests flow from an authenticated caller through middleware to a controller and back, and how errors are normalised into a consistent envelope. Understanding this layer helps you diagnose request failures, integrate correctly with the REST API, and configure the service for your deployment. The API is served by the protector-api process on port 8788 and registered in the Keystone service catalogue under the protector service type.


Prerequisites

Before working with the API layer you need:

  • A running Trilio Site Recovery deployment (Juju, Kolla-Ansible, or OpenShift) with protector-api and protector-engine services healthy
  • Keystone credentials with at least the member role; administrative endpoints additionally require dr_site_admin or admin
  • The python3-triliositerecovery Debian package installed on any machine from which you run the openstack dr CLI
  • Network access from your client to port 8788 (protector API) and port 5000 (Keystone) on each site
  • A valid Keystone token — the API validates every request (except GET /) through keystonemiddleware; unauthenticated calls receive HTTP 401
  • OpenStack CLI environment variables set (OS_AUTH_URL, OS_PROJECT_ID, OS_USERNAME, OS_PASSWORD, and so on) or an openrc file sourced

Installation

The API layer is installed as part of the trilio-site-recovery Debian package. The installation path depends on your deployment model.

Juju (Charmed OpenStack)

The charm installs and manages the package automatically when you deploy it:

juju deploy trilio-site-recovery-for-openstack --channel latest/stable

The charm writes /etc/protector/protector.conf, registers the service in Keystone, and runs the initial database migration. You do not need to install the package manually on the controller nodes.

To install the CLI on a separate client machine:

apt-get install python3-triliositerecovery

Kolla-Ansible

The deploy/kolla/install.sh script deploys the protector_api and protector_engine containers from the protector:latest Docker image alongside your existing Kolla-managed services:

bash deploy/kolla/install.sh

The script manages the container lifecycle, writes configuration, and runs protector-manage db sync to apply the schema.

OpenShift (RHOSO18)

Use the provided installer script, which applies all twelve manifests in the correct order and gates each init Job on completion before proceeding:

bash deploy/openshift/scripts/install.sh

The script accepts --namespace, --trilio-ns, --openstack-ns, --image, and --rotate-passwords flags. Do not apply individual manifests from deploy/openshift/manifests/ by hand: the script creates the protector database and RabbitMQ user, registers the Keystone service and endpoints, and runs the schema migration in a specific, gated sequence. Skipping any step leaves the Deployments unable to authenticate tokens, reach the database, or dispatch RPC.

Verify the API is reachable

After installation, confirm the API serves the version document:

curl -s http://<protector-api-host>:8788/

This returns the supported API version list. The root path / is a static version document and cannot reflect database health. Use openstack dr site list or the Juju health-check charm action to confirm full end-to-end connectivity.


Configuration

The API layer is configured in /etc/protector/protector.conf using oslo.config INI syntax. The options below are grouped by their configuration section.

[api] — HTTP server

OptionTypeDefaultPurpose
bind_hoststring0.0.0.0Interface the WSGI server binds to
bind_portinteger8788Port the API listens on
workersinteger4Number of WSGI worker processes

[DEFAULT] — Core service identity

OptionTypeDefaultPurpose
local_sitestring(required)Name of the DR site this instance belongs to. The service cannot participate in any DR operation until this is set.
hoststringlocalhostHostname used for RPC identity
use_mock_storagebooleanfalseUse the in-memory mock storage backend instead of a real array
use_mock_cinderbooleanfalseUse mock Cinder interactions

local_site is the most critical option. Without it the engine cannot determine which site it is executing on, which breaks failover, failback, and all cross-site operations. After a Juju charm upgrade to 1.0.20 or later, the unit enters BLOCKED with the message set local-site, pure-primary-site-name, pure-secondary-site-name until these are set — this is expected behaviour, not a failed upgrade.

[keystone_authtoken] — Keystone middleware

OptionTypePurpose
auth_urlstringKeystone endpoint for token validation
www_authenticate_uristringPublic Keystone URI returned in WWW-Authenticate headers

All other keystonemiddleware options (service token credentials, auth_type, and so on) are set here and passed to AuthProtocol at startup.

[database] — MariaDB/MySQL

OptionTypePurpose
connectionstringSQLAlchemy connection URL for the protector database

[engine] — RPC and workflow settings

OptionTypeDefaultPurpose
topicstringprotector-engineRabbitMQ RPC topic the engine consumes
cross_site_timeoutinteger30Timeout in seconds for cross-site API calls
recovery_point_interval_minutesinteger0Automatic recovery point creation interval (0 = disabled)
recovery_point_max_countinteger20Maximum recovery points to retain per protection group
recovery_point_ttl_hoursinteger24Time-to-live for recovery points
auto_create_security_groupsbooleanfalseAutomatically create missing security groups on the recovery site

If you need to set a configuration key that the Juju charm does not expose directly, use config-flags:

juju config trilio-site-recovery config-flags="engine:cross_site_timeout=60"

Do not edit /etc/protector/protector.conf directly on a Juju-managed node — the charm rewrites it on every hook.

[service_credentials] — Trust and cross-site auth

OptionTypeDefaultPurpose
default_trust_rolesstringmember,dr_operatorRoles delegated by every per-tenant Keystone trust. Both roles must exist in Keystone before the service handles its first DR operation.
default_service_projectstringserviceProject used for service-to-service calls
cafilestringCA bundle for TLS verification of peer sites
insecurebooleanfalseDisable TLS certificate verification

Do not remove member from default_trust_roles. It grants the trust the Nova and Cinder access that every failover and failback needs. Dropping it causes operations to fail at the first instance or volume call, after the storage work is already done.

Annotated sample configuration

[DEFAULT]
# REQUIRED: the name of the DR site this node belongs to
local_site = site-primary

# Storage backend: 'mock' for evaluation, 'pure' for production
use_mock_storage = false

[api]
bind_host = 0.0.0.0
bind_port = 8788
workers = 4

[database]
connection = mysql+pymysql://protector:PASSWORD@db-host/protector

[keystone_authtoken]
auth_url = https://keystone.site-primary.example.com:5000/v3
www_authenticate_uri = https://keystone.site-primary.example.com:5000
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = protector
password = SERVICE_PASSWORD

[engine]
topic = protector-engine
cross_site_timeout = 30

[service_credentials]
# Both roles must exist in Keystone before the first DR operation
# The default is already correct — omit this line unless you have a reason
# default_trust_roles = member,dr_operator
default_service_project = service

[pure_storage]
primary_management_ip = 10.0.1.10
primary_api_token = T-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
primary_site_name = site-primary
secondary_management_ip = 10.0.2.10
secondary_api_token = T-yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
secondary_site_name = site-secondary
verify_ssl = false
default_rpo_seconds = 900
snapshot_interval_seconds = 300

Usage

Request lifecycle

Every authenticated request to POST /v1/{tenant_id}/protection-groups/{pg_id}/action or any other versioned endpoint follows the same path:

  1. CORS — adds cross-origin headers
  2. RequestId — assigns an X-OpenStack-Request-ID to the request for log correlation
  3. VersionMiddleware — reads the OpenStack-API-Version: protector <version> header; rejects out-of-range versions with HTTP 400 and the documented error envelope; defaults to version 1.0 when the header is absent
  4. AuthMiddleware — delegates to keystonemiddleware.auth_token.AuthProtocol; validates the Keystone token and populates HTTP_X_USER_ID, HTTP_X_PROJECT_ID, and HTTP_X_ROLES in the WSGI environ; unauthenticated requests receive HTTP 401
  5. ContextMiddleware — builds a RequestContext from the token claims; sets is_admin when the token carries the admin role (case-insensitive)
  6. FaultMiddleware — catches ProtectorException subclasses, DB integrity errors, and DB connectivity failures and converts them to the standard JSON error envelope before they reach the caller as a bare 500
  7. Controller — enforces RBAC via oslo.policy, reads and sanitises the request body, and dispatches to the engine over RabbitMQ RPC

The / path is handled by VersionsController and returns the version document without authentication. Any path under / that is not /v1 and is not an exact match for / returns HTTP 404 — the version controller does not silently accept arbitrary paths.

API versioning

The service supports microversions 1.0 through 1.1. Advertise your desired version with:

OpenStack-API-Version: protector 1.1

Every response carries OpenStack-API-Version and OpenStack-API-Minimum-Version headers regardless of whether you sent the request header.

Error envelope

All errors — whether from application logic, authentication, or the database — are returned in a consistent JSON envelope:

{
  "error": {
    "code": 404,
    "message": "Protection group abc123 not found",
    "type": "ProtectionGroupNotFound"
  }
}

The type field names the exception class. Use it when filing support tickets or searching service logs. Notable types:

TypeHTTPMeaning
ResourceConflict409Unique-constraint violation, often a name held by a soft-deleted resource
ServiceUnavailable503Database connectivity failure — retryable
InvalidState409The resource is in a state that does not permit the requested operation
FailoverNotReady422The protection group is not ready for failover
SiteUnreachable503The peer site did not respond

Triggering a DR operation

DR operations are dispatched through the action endpoint. The request body top-level key selects the operation:

# Failover a protection group
curl -s -X POST \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "OpenStack-API-Version: protector 1.1" \
  -d '{"failover": {"failover_type": "planned", "network_mapping": {"src-net-uuid": "dst-net-uuid"}}}' \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/protection-groups/<pg-id>/action

Valid top-level keys for POST /v1/{tenant_id}/protection-groups/{pg_id}/action:

KeyOperation
failoverFail workloads over to the secondary site
failbackReturn workloads to the primary site
failback_planRead-only: returns the planned failback steps without starting an operation
test_failoverNon-disruptive test of recovery on an isolated network
test_cleanupRemove VMs created by a test failover
reconcileRepair a protection group left inconsistent by an interrupted failover or failback

failback_plan returns HTTP 200 with {"failback_plan": <plan>} and starts no operation. All others return HTTP 202 with an operation_id you can poll.

Polling an operation

curl -s \
  -H "X-Auth-Token: $OS_TOKEN" \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/operations/<operation-id>

The response includes status, progress (0–100), source_site, target_site, started_at, completed_at, and result_data. The source_site and target_site fields show the site name, falling back to its ID. There is no estimated completion time — the service does not compute one.

Observability

The service emits no oslo.messaging notifications. Monitor DR state by polling:

  • openstack dr replication health <pg> — replication link status and RPO compliance
  • openstack dr replication audit — volumes replicated by the array but not covered by any protection group
  • openstack dr recovery point list <pg> — available recovery points
  • openstack dr operation list / openstack dr operation show <id> — operation history and progress

Examples

Version discovery

Retrieve the API version document without authentication:

curl -s http://<protector-api-host>:8788/

List protection groups via the REST API

curl -s \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "OpenStack-API-Version: protector 1.1" \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/protection-groups

Initiate a planned failover

curl -s -X POST \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "OpenStack-API-Version: protector 1.1" \
  -d '{
    "failover": {
      "failover_type": "planned",
      "network_mapping": {
        "prod-net-uuid": "dr-net-uuid"
      },
      "flavor_mapping": {
        "m1.large-uuid": "m1.large-dr-uuid"
      }
    }
  }' \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/protection-groups/<pg-id>/action

Note: --network-mapping and --flavor-mapping in the CLI use = as the separator (source-id=dest-id). At the REST API level there is no separator — mappings are plain JSON objects.

Reconcile an inconsistent protection group

curl -s -X POST \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "OpenStack-API-Version: protector 1.1" \
  -d '{"reconcile": {}}' \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/protection-groups/<pg-id>/action

This is equivalent to openstack dr protection group reconcile <pg>. The operation is recorded in dr_operations with operation_type=reconcile.

Poll an operation until complete

curl -s \
  -H "X-Auth-Token: $OS_TOKEN" \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/operations/<operation-id>

Initiate a site-level failover

curl -s -X POST \
  -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-Type: application/json" \
  http://<protector-api-host>:8788/v1/$OS_PROJECT_ID/sites/<site-id>/action\
  -d '{"failover": {"failover_type": "unplanned"}}'

The request body top-level key must be failover or failback — no other keys are accepted by this endpoint.

Python client — list protection groups

from keystoneauth1 import identity, session
from keystoneauth1.adapter import Adapter
from triliositerecovery.v1.client import Client

auth = identity.Password(
    auth_url='https://keystone.example.com:5000/v3',
    username='myuser',
    password='mypassword',
    project_name='myproject',
    user_domain_name='Default',
    project_domain_name='Default',
)
ks = session.Session(auth=auth)
adapter = Adapter(
    session=ks,
    service_type='protector',
    interface='public',
)
endpoint = adapter.get_endpoint()

client = Client(session=adapter, endpoint=endpoint)

# Returns a list of plain dicts — use dict access, not attribute access
groups = client.protection_groups.list()
for pg in groups:
    print(pg['id'], pg['name'])

Python client — trigger failover

# pg_id is a positional argument, not a keyword argument
operation = client.operations.failover(
    pg['id'],
    network_mapping={'prod-net-uuid': 'dr-net-uuid'},
    flavor_mapping={'m1.large-uuid': 'm1.large-dr-uuid'},
)
print(operation['id'], operation['status'])

Python client — reconcile a protection group

# reconcile() is on client.operations, not client.protection_groups
result = client.operations.reconcile(pg['id'])
print(result)

Python client — check replication health with probe

# probe=True asks the recovery site whether networks, security groups,
# and flavors resolve there as the project the group recovers into.
# It does not test the storage backend or replication lag.
health = client.protection_groups.replication_health(pg['id'], probe=True)
print(health)

Troubleshooting

HTTP 401 on every request

Symptom: All API calls return {"error": {"code": 401, ...}}.

Likely cause: The Keystone token is missing, expired, or the [keystone_authtoken] section in /etc/protector/protector.conf points at the wrong Keystone endpoint.

Fix: Re-source your openrc file to get a fresh token. Confirm auth_url in [keystone_authtoken] matches the Keystone public endpoint. On Juju, verify the identity-credentials relation is active: juju status trilio-site-recovery.


HTTP 400 — Invalid API version

Symptom: Requests with an OpenStack-API-Version header return {"error": {"code": 400, "message": "Invalid API version ..."}} even though your version looks correct.

Likely cause: The service name in the header is wrong or misspelled. The header must be OpenStack-API-Version: protector <version> with the service identifier protector.

Fix: Use OpenStack-API-Version: protector 1.1 (or 1.0). Supported range is 1.0 to 1.1.


HTTP 503 — Database temporarily unavailable

Symptom: API calls return {"error": {"code": 503, "type": "ServiceUnavailable", "message": "Database temporarily unavailable"}}.

Likely cause: The protector-api process cannot reach the MariaDB/MySQL server. This is a connectivity failure, not a schema error — it is retryable.

Fix: Check that the database service is running and that [database] connection in protector.conf is correct. On Juju, inspect the shared-db relation. Under Kolla, check the protector_api container logs: docker logs protector_api. Under OpenShift, retrieve logs with:

oc -n trilio-site-recovery logs -l app.kubernetes.io/name=trilio-site-recovery,app.kubernetes.io/component=api

HTTP 409 — ResourceConflict

Symptom: A create request returns {"error": {"code": 409, "type": "ResourceConflict", "message": "The request conflicts with an existing resource. A name may still be held by a deleted resource."}}.

Likely cause: A soft-deleted resource still holds the name you are trying to reuse.

Fix: Choose a different name, or use the Juju purge-database charm action to clean up soft-deleted rows (this is destructive — confirm you do not need the history):

juju run trilio-site-recovery/leader purge-database

HTTP 409 — InvalidState on an action endpoint

Symptom: POST /v1/{tenant_id}/protection-groups/{pg_id}/action returns HTTP 409 with type: InvalidState.

Likely cause: The protection group is in a state that does not permit the requested operation (for example, attempting a failover on a group that is already failed_over, or a failback on a group in active state).

Fix: Check the current group status with openstack dr protection group show <pg>. If the group is stuck in an inconsistent state after an interrupted failover or failback, use reconcile:

openstack dr protection group reconcile <pg>

local_site not set — service blocked

Symptom: After upgrading the Juju charm, the unit enters BLOCKED with the message set local-site, pure-primary-site-name, pure-secondary-site-name. DR operations return errors referencing site identity.

Likely cause: The charm requires local_site to be explicitly configured. It does not infer which site it belongs to — this matters most on the recovery site, which is where failover executes.

Fix: Set the required configuration:

juju config trilio-site-recovery local-site=site-primary
# When using Pure Storage:
juju config trilio-site-recovery \
  pure-primary-site-name=site-primary \
  pure-secondary-site-name=site-secondary

SiteAlreadyExists when registering a site with a leading space

Symptom: Registering a second site with what looks like a unique name fails with a 409, or cross-site operations fail with Site <uuid> not found.

Likely cause: A site was registered with a leading or trailing space in its auth_url or name (for example, by pasting a URL with an extra space). The API sanitises new values on input, but previously stored values with whitespace cause exact-match failures.

Fix: Delete and re-create the affected site, ensuring there is no surrounding whitespace in any field. The request sanitiser (applied since 1.0.x) strips whitespace from all non-secret fields automatically on new registrations.


OpenShift pods not found by label selector

Symptom: oc logs -l app=trilio-site-recovery-api -n trilio-site-recovery returns No resources found.

Likely cause: The OpenShift manifests do not use a bare app label. Using it selects zero pods.

Fix: Use the correct label selectors. The app.kubernetes.io/name and app.kubernetes.io/component labels are both required:

# API pods
oc -n trilio-site-recovery logs -l \
  app.kubernetes.io/name=trilio-site-recovery,app.kubernetes.io/component=api

# Engine pods
oc -n trilio-site-recovery logs -l \
  app.kubernetes.io/name=trilio-site-recovery,app.kubernetes.io/component=engine

Under OpenShift the service logs to stdout only — there is no /var/log/protector/ to fall back to.


Failover fails with HTTP 403 on volume operations

Symptom: A failover operation starts, completes storage work, then fails mid-way with Policy doesn't allow volume_extension:volume_manage to be performed (HTTP 403).

Likely cause: The Cinder policy on the recovery site has not been relaxed to allow the member role (via Keystone trust) to manage and unmanage volumes. The service runs as a tenant, not as admin, so stock Cinder denies these calls.

Fix: Apply the following five Cinder policy relaxations on both sites:

"volume_extension:volume_manage": "rule:admin_or_owner"
"volume_extension:volume_unmanage": "rule:admin_or_owner"
"volume_extension:services:index": "rule:admin_or_owner"
"volume_extension:type_get": "rule:admin_or_owner"
"volume_extension:type_get_all": "rule:admin_or_owner"

On a Juju-managed Cinder, attach the policy override:

juju attach-resource cinder policyd-override=cinder-policy-override.zip