OpenStack database auto-cleanup

By design, when deleting a cloud resource, for example, an instance, volume, or router, an OpenStack service does not immediately delete its data but marks it as removed so that it can later be picked up by the garbage collector.

Given that an OpenStack resource is often represented by more than one record in the database, deletion of all of them right away could affect the overall responsiveness of the cloud API. On the other hand, an OpenStack database being severely clogged with stale data is one of the most typical reasons for the cloud slowness.

To keep the OpenStack database small and performance fast, MOSK is pre-configured to automatically clean up the removed database records older than 30 days. By default, the clean up is performed for the following MOSK services every Monday according to the schedule:

The default database cleanup schedule by OpenStack service

Service

Service identifier

Clean up time

Block Storage (OpenStack Cinder)

cinder

12:01 a.m.

Compute (OpenStack Nova)

nova

01:01 a.m.

Image (OpenStack Glance)

glance

02:01 a.m.

Instance HA (OpenStack Masakari)

masakari

03:01 a.m.

Key Manager (OpenStack Barbican)

barbican

04:01 a.m.

Orchestration (OpenStack Heat)

heat

05:01 a.m.

Alarming (OpenStack Aodh)

aodh

06:01 a.m.

Shared File System (OpenStack Manila)

manila

07:01 a.m.

Dashboard (OpenStack Horizon)

horizon

08:01 a.m.

To adjust the default database cleanup schedule for OpenStack services, add the features:database:cleanup parameter block to your OpenStackDeployment custom resource. The configuration parameter list includes:

  • enabled: Toggles automatic database cleanup on (true) or off (false).

  • schedule: Defines the cleanup frequency using a valid cron expression. You can generate and validate expressions using the Cron expression builder.

  • age: Specifies the threshold (in days) after which stale records are deleted.

  • batch: Specifies the maximum number of records to delete per iteration. Supported by Nova, Glance, Masakari, and Heat.

Note

The Dashboard (Horizon) service supports only enabled and schedule parameters. Its cleanup job removes expired session records from the database.

Example configuration for OpenStack database cleanup schedule:

spec:
  features:
    database:
      cleanup:
        <OS-SERVICE-IDENTIFIER>:
          enabled: true
          schedule: "1 0 * * 1"
          age: 30
          batch: 1000