Add --task-log option to nova-manage db archive_deleted_rows

The task_log table contains instance usage audit records if
nova-compute has been configured with [DEFAULT]instance_usage_audit =
True. This will be the case if OpenStack Telemetry is being used in the
deployment, as the option causes nova to generate audit information
that Telemetry then retrieves from the server usage audit log API [1].

Historically, there has been no way to delete task_log table records
other than manual database modification. Because of this, task_log
records could pile up over time and operators are forced to perform
manual steps to periodically truncate the table.

This adds a --task-log option to the 'nova-manage db
archive_deleted_rows' CLI to also archive task_log records while
archiving the database. --task-log works in conjunction with --before
if operators desire archving only records that are older than <date>.
The 'updated_at' field is used by --task-log --before <date> to
determine the age of a task_log record for archival.

Closes-Bug: #1877189

[1] https://docs.openstack.org/api-ref/compute/#server-usage-audit-log-os-instance-usage-audit-log

Change-Id: Ibed67854a693c930effd4dba7aca6cd03b65bd92
This commit is contained in:
melanie witt
2021-03-11 23:47:05 +00:00
parent 50fdbc752a
commit bc71331bca
9 changed files with 398 additions and 46 deletions
+16 -1
View File
@@ -216,7 +216,7 @@ db archive_deleted_rows
.. code-block:: shell
nova-manage db archive_deleted_rows [--max_rows <rows>] [--verbose]
[--until-complete] [--before <date>] [--purge] [--all-cells]
[--until-complete] [--before <date>] [--purge] [--all-cells] [--task-log]
Move deleted rows from production tables to shadow tables. Note that the
corresponding rows in the ``instance_mappings``, ``request_specs`` and
@@ -228,6 +228,10 @@ file.
If automating, this should be run continuously while the result is 1,
stopping at 0, or use the :option:`--until-complete` option.
.. versionchanged:: 24.0.0 (Xena)
Added :option:`--task-log` option.
.. rubric:: Options
.. option:: --max_rows <rows>
@@ -272,6 +276,17 @@ stopping at 0, or use the :option:`--until-complete` option.
Run command across all cells.
.. option:: --task-log
Also archive ``task_log`` table records. Note that ``task_log`` records are
never deleted, so archiving them will move all of the ``task_log`` records
up to now into the shadow tables. It is recommended to also specify the
:option:`--before` option to avoid races for those consuming ``task_log``
record data via the `/os-instance_usage_audit_log`__ API (example:
Telemetry).
.. __: https://docs.openstack.org/api-ref/compute/#server-usage-audit-log-os-instance-usage-audit-log
.. rubric:: Return codes
.. list-table::