Skip to content

Latest commit

 

History

History
294 lines (251 loc) · 22 KB

API.md

File metadata and controls

294 lines (251 loc) · 22 KB

API mapping

The initial extraction preserves the exporter's selected columns, joins, aggregations, default deletion predicates, and index hints. Method names follow upstream resource terminology; signatures and return projections are Go-specific. This table is an exporter migration map, not a claim that every operation exists with identical semantics upstream.

Package Former exporter query New method
nova/db/main GetInstances InstanceGetAll
nova/db/main GetServices ServiceGetAll
nova/db/main GetComputeNodes ComputeNodeGetAll
nova/db/api GetFlavors FlavorGetAll
nova/db/api GetQuotas QuotaGetAll
nova/db/api GetAggregates AggregateGetAll
nova/db/api GetAggregateHosts AggregateHostGetAll
nova/db/api GetQuotaClassDefaults QuotaClassGetDefaults
nova/db/api GetQuotaUsages QuotaUsageGetAll
cinder/db GetAllServices ServiceGetAll
cinder/db GetProjectQuotaLimits QuotaGetProjectLimits
cinder/db GetProjectQuotaUsages QuotaUsageGetAll
cinder/db GetAllProjectQuotas QuotaGetAllWithUsage
cinder/db GetVolumeTypes VolumeTypeGetAll
cinder/db GetSnapshotCount SnapshotCount
cinder/db GetAllVolumes VolumeGetAllWithAttachments
glance/db GetAllImages ImageGetAll
designate/db ListZonesAndRecordsets (zone details) ZoneGetAll
designate/db ListZonesAndRecordsets (per-zone counts) RecordsetCountByZone
designate/db ListZonesAndRecordsets (recordset details) RecordsetGetAllWithStatus
heat/db GetStackMetrics StackGetAll
ironic/db GetNodeMetrics GetNodeList
keystone/db GetProjectMetrics ListProjects
keystone/db GetDomainMetrics ListDomains
keystone/db GetUserMetrics ListUsers
keystone/db GetRegionMetrics ListRegions
keystone/db GetGroupMetrics ListGroups
magnum/db GetClusterMetrics GetClusterList
manila/db GetShareMetrics ShareGetAllWithInstances
manila/db — ShareGetInventory
neutron/db GetAgents GetAgents
neutron/db GetHARouterAgentPortBindingsWithAgents GetHARouterAgentPortBindingsWithAgents
neutron/db GetRouters GetRouters
neutron/db GetFloatingIPs GetFloatingIPs
neutron/db GetNetworks GetNetworks
neutron/db GetSubnets GetSubnets
neutron/db GetPorts GetPorts
neutron/db GetSecurityGroupCount GetSecurityGroupCount
neutron/db GetNetworkIPAvailabilitiesUsed GetNetworkIPAvailabilitiesUsed
neutron/db GetNetworkIPAvailabilitiesTotal GetNetworkIPAvailabilitiesTotal
neutron/db GetSubnetPools GetSubnetPools
neutron/db GetQuotas GetQuotas
neutron/db GetResourceCountsByProject GetResourceCountsByProject
octavia/db/repositories GetAllPools PoolGetAll
octavia/db/repositories GetAllLoadBalancersWithVip LoadBalancerGetAllWithVIP
octavia/db/repositories GetAllAmphora AmphoraGetAll
octavia/db/repositories — QuotaGetAll (QuotaRepository.GetAll)
octavia/db/repositories — QuotaUsageGetAll (QuotaRepository.GetUsage)
placement/objects GetResourceMetrics GetResourceProviderInventories
placement/objects GetAllocationsByProject GetAllocationsByProject
placement/objects GetConsumerCountByProject GetConsumerCountByProject
placement/objects GetResourceClasses GetResourceClasses
placement/objects GetConsumers GetConsumers

Upstream references

Deliberate differences

  • Nova ServiceGetAll retains the exporter's requirement that last_seen_up and topic are non-null.
  • The filtered APIs support exact membership and lifetime overlap, not every upstream regex, pagination, eager-loading, or authorization option.
  • Current exporter queries retain their existing deleted/hidden/status predicates; they are not full upstream administrative listings.
  • Errors are Go/database errors; absent single resources return sql.ErrNoRows rather than Python service-specific exceptions.
  • Aggregate queries such as QuotaGetAllWithUsage, GetResourceProviderInventories, GetResourceCountsByProject, and Octavia QuotaUsageGetAll are explicitly library extensions. Octavia QuotaUsageGetAll recounts objects with check_quota_met's predicate; Octavia itself enforces against the cached in_use_* counters that QuotaGetAll returns.
  • Owner filtering follows each service: Neutron keeps empty-string project IDs because Neutron creates real objects with them (for example L3 HA networks and ports), while Octavia excludes them because it rejects empty project IDs.
  • Designate returns canonical zone and recordset UUIDs and excludes soft-deleted zones. RecordsetCountByZone includes zero-count zones and can run without reading individual records. RecordsetGetAllWithStatus uses the child precedence ERROR, PENDING, ACTIVE, DELETED and returns ACTIVE for an empty recordset. Recordsets with a NULL zone_id have no visible zone and are omitted.
  • Cinder quota queries exclude NULL and empty project IDs because Cinder quota rows belong to Keystone projects. The older Cinder exporter quota queries are unchanged.
  • No cross-cell routing or historic schema negotiation is performed. Nova archive access is explicitly selected with InstanceFilters.Archive.

Resource lifecycle and metadata reads

Go operation Upstream naming source Scope
InstanceGetAllByFilters Nova instance_get_all_by_filters Adds explicit archive and extra-metadata options; preserves timestamp fields.
InstanceExtraGetByInstanceUUID Nova instance_extra_get_by_instance_uuid Raw flavor projection, optional shadow table; absent rows return sql.ErrNoRows.
InstanceTypeGetAll Historical Nova instance_type_get_all Legacy type identity projection, Inactive, explicit Archived extension.
VolumeTypeGetAll Cinder volume_type_get_all(inactive=...) Optional Inactive includes deleted types; returns identity rows rather than a keyed Python dictionary.
GetProject Keystone resource backend get_project ID/name/enabled/domain projection; does not implement request authorization or hidden-reference policy.

Instance and image filtered/single-resource APIs return richer record types with lifecycle metadata. Their fixed current-resource queries remain unchanged for exporter consumers. Deleted volume types and legacy type tables are only read when explicitly requested. Legacy table availability is a caller/deployment concern; errors are propagated rather than hidden.

Cinder quota accounting

Go operation Upstream naming source Scope
QuotaGetAllByProject Cinder quota_get_all_by_project Reads quotas for every project at once; raw rows instead of a per-project dictionary.
QuotaUsageGetAllByProject Cinder quota_usage_get_all_by_project Reads quota_usages for every project at once; raw in_use/reserved rows. Usage is Cinder's cached accounting.
QuotaClassGetDefaults Cinder quota_class_get_defaults Reads the default class from quota_classes; raw rows instead of a dictionary.
ParseQuotaResource Cinder VolumeTypeResource key format in cinder/quota.py Splits <part>_<volume type name> keys. Hand-written; re-check the global resource list on Cinder upgrades.

Rows with a NULL or empty project ID are excluded: Cinder quota rows belong to Keystone projects. Results are ordered by project, resource and row ID, so callers that collapse duplicates get a stable result. Duplicate active rows, NULL limits, zero limits and -1 (unlimited) are returned as stored. The existing exporter queries QuotaGetProjectLimits, QuotaUsageGetAll and QuotaGetAllWithUsage keep their behavior.

Limits and usage are read separately, so usage also covers projects that have no limit overrides. Usage is Cinder's cached accounting, not a live count of volumes and snapshots. It can drift from the real resources until Cinder refreshes it. reserved already counts open reservations.

Resource keys are either global (volumes, gigabytes, snapshots, backups, backup_gigabytes, per_volume_gigabytes, groups) or per volume type, built as <part>_<volume type name> where the part is volumes, gigabytes or snapshots. Per-type and global accounting describe the same allocations, so never add them together. Use ParseQuotaResource to split a key. Don't split on the first underscore: that misreads backup_gigabytes and type names that contain underscores. Keys hold the volume type's name, not its ID. Cinder rewrites them when a type is renamed, but keeps them after a type is deleted, so a parsed name may not match any type from VolumeTypeGetAll.

Callers resolve effective limits: a project override, then the default class, then service configuration. The quota_classes schema is a test and code-generation fixture, not a production migration.

Octavia quotas

Go operation Upstream naming source Scope
QuotaGetAll (QuotaRepository.GetAll) Octavia QuotasRepository Stored limits and cached in_use_* counters for every project at once; NULL and empty project IDs excluded.
QuotaUsageGetAll (QuotaRepository.GetUsage) Octavia Repositories.check_quota_met recount predicate Library extension: recounts all seven quota resources for every project; scans seven unindexed object tables.

NewQuotaRepository(db).GetAll(ctx) / QuotaGetAll returns one Quota row per project with the stored limits for load balancers, listeners, pools, health monitors, members, L7 policies and L7 rules, plus Octavia's cached in_use_* counters. Each value is a sql.NullInt32. A NULL limit means no explicit override, and zero and -1 remain distinct values; the caller resolves configured defaults. The in_use_* counters are what Octavia's check_quota_met and decrement_quota enforce against. A NULL or zero counter means Octavia will recount on its next quota check for that project.

QuotaRepository.GetUsage / QuotaUsageGetAll rebuilds project counts for all seven quota resources independently, using the same predicate Octavia uses when it recounts: the object's own project_id and provisioning_status != 'DELETED'. Counts include ERROR and pending statuses. Each object uses its own project and status, including children of deleted parents or parents owned by another project, and there are no parent joins to multiply counts. Results contain only nonzero project/resource groups, including projects without quota rows, with int64 usage.

The two reads answer different questions. in_use_* is what Octavia enforces today, and GetUsage is what those counters should be. Compare them to detect counter drift, which persists until Octavia reconciles it. Octavia defines no index on project_id or provisioning_status, so GetUsage scans all seven object tables. GetAll reads only the quotas table and is cheap enough for every scrape. Run GetUsage as a less frequent drift check on large deployments.

Both reads exclude NULL and empty project IDs. Octavia rejects empty project IDs (MissingProjectID), so such rows can never hold quota. The schema fixtures contain only fields needed for these tests, not a complete OpenStack migration. The MariaDB integration test is TestOctaviaQuotas in tests/ and requires Docker.

Manila share inventory

Go operation Upstream naming source Scope
ShareGetInventory Manila Share.instance One row per logical share with its representative instance. Status ranking copies constants.TRANSITIONAL_STATUSES and must be re-checked on Manila upgrades.

ShareGetInventory returns exactly one row per nondeleted logical share, including shares without instances. It follows Manila's Share.instance: status precedence, active-replica preference, and the replication-change exception. Instance ID resolves otherwise unspecified ties (including writable replication with multiple active replicas). Status, AZ and type all come from the same representative instance, chosen in one pass with window functions. The status ranking copies Manila's constants.TRANSITIONAL_STATUSES; re-check it against manila/common/constants.py and Share.instance in manila/db/sqlalchemy/models.py when moving to a new Manila release, because a missing transitional status would be preferred over the listed ones. Retained is_soft_deleted shares remain in inventory, preserving the existing deletion scope; row-soft-deleted shares and instances are excluded. This is inventory, not quota accounting.

The MariaDB integration test is TestManilaInventory in tests/ and requires Docker.

Manila quota accounting

The Manila quota queries are named after Manila's DB API functions. Each one reads every project at once rather than one project, and returns raw rows rather than a per-project dictionary:

Go operation Upstream naming source Table
QuotaGetAllByProject Manila quota_get_all_by_project quotas
QuotaGetAllByProjectAndUser Manila quota_get_all_by_project_and_user project_user_quotas
QuotaGetAllByProjectAndShareType Manila quota_get_all_by_project_and_share_type project_share_type_quotas
QuotaClassGetDefault Manila quota_class_get_default quota_classes
QuotaUsageGetAllByProject Manila quota_usage_get_all_by_project quota_usages, share_type_id IS NULL
QuotaUsageGetAllByProjectAndShareType Manila quota_usage_get_all_by_project_and_share_type quota_usages, share_type_id IS NOT NULL

Rows with a NULL or empty project ID are excluded. Results are ordered by their identifying columns and row ID, so callers that collapse duplicates get a stable result.

Usage rows are not aggregated. in_use and reserved are returned as stored, including NULL, so callers can tell malformed rows from zero usage. To get Manila's project totals, sum QuotaUsageGetAllByProject rows by project and resource; this matches _quota_usage_get_all, which sums users (including legacy NULL-user rows) and excludes share-type rows. Share-type accounting describes the same allocations: read it with QuotaUsageGetAllByProjectAndShareType and never add it to project totals. reserved already counts open reservations; do not add reservations again.

The share-type queries left-join share_types. When a share type is deleted or missing, its limits and usage are still returned with a NULL ShareTypeName, so per-type totals reconcile with project totals.

The generated quota models use sql.NullInt32 for integer Deleted fields: active rows have 0, and soft-deleted rows store their row ID. The fixture has no database default for these columns; Manila supplies 0 through SQLAlchemy. Share and instance deletion markers retain their existing string representation.

User overrides live in project_user_quotas, separately from project overrides in quotas and type overrides in project_share_type_quotas. Never sum limits or substitute user limits for project limits. A NULL hard limit is preserved so callers can detect invalid or legacy data; Manila enforces numeric limits, using -1 for unlimited. The caller supplies service configuration defaults and resolves missing limits: share-type override → project override → persisted default class → service configuration. Non-default classes need request-context information that these database tables do not provide.

These queries read Manila's quota accounting, not rebuilt object counts or physical storage use. Stale accounting, including usage left after object removal, remains visible until Manila reconciles it. No writes or reconciliation are performed. The schema files are test fixtures, not production migrations.

The MariaDB integration test is TestManilaQuotas in tests/ and requires Docker.

Neutron quota reservations

Go operation Upstream naming source Scope
GetReservationsForResources Neutron get_reservations_for_resources(..., expired=False) All projects instead of one; raw per-delta rows instead of a per-resource sum.

neutron/db.Queries.GetReservationsForResources(ctx, resources) returns one row per active reservation delta: ReservationID, ProjectID, Expiration, Resource, and Amount. Rows are ordered by project, resource, and reservation ID. Amounts are returned as stored, including NULL and negative values; summing them and deciding how to treat malformed amounts is the caller's job.

A reservation is active when expiration >= UTC_TIMESTAMP(), the same inclusive boundary Neutron uses. The comparison runs on the database clock, so skew between the caller and the Neutron servers does not change the result. Neutron writes expirations in UTC, so the comparison uses UTC_TIMESTAMP() rather than the session-time-zone NOW(). NULL expirations are never active.

resources is a positional argument, not a ...Filters struct, and follows upstream: a nil or empty list matches nothing rather than every resource. Pass the resources to monitor explicitly, for example floatingip, network, port, rbac_policy, router, security_group, security_group_rule, subnet, and subnetpool.

NULL owners are excluded and empty-string owners are kept. GetQuotas and GetResourceCountsByProject use the same owner policy, so limits, usage, and reservations can be joined on ProjectID without special cases. GetQuotas returns rows ordered by project, resource, and quota ID, so callers that collapse duplicate project/resource rows get a stable result.

Upstream Neutron defines no index on reservations.expiration or reservations.project_id; the schema fixture mirrors that. Each call therefore scans reservations and joins resourcedeltas through the index InnoDB creates for its reservation_id foreign key. This is the same access path Neutron's own quota engine uses, and the table stays small while Neutron's expired-reservation cleanup runs. If cleanup stalls, the table and this query's cost grow together.

The schema tables are local fixtures, not production migrations. Separate reads do not share a snapshot unless the caller uses WithTx with a suitable isolation level. Query, scan, row-iteration, and context errors propagate through the generated API; an error must never be treated as zero reservations.