[Bug 2104322] Re: cinder-manager quota sync is not working

Alan Baghumian 2104322 at bugs.launchpad.net
Wed Apr 1 21:46:54 UTC 2026


** Also affects: cinder (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: cinder (Ubuntu)
   Importance: Undecided => High

** Also affects: cinder (Ubuntu Noble)
   Importance: Undecided
       Status: New

** Also affects: cloud-archive
   Importance: Undecided
       Status: New

** Also affects: cloud-archive/caracal
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to cinder in Ubuntu.
https://bugs.launchpad.net/bugs/2104322

Title:
  cinder-manager quota sync is not working

Status in Cinder:
  Fix Released
Status in Ubuntu Cloud Archive:
  New
Status in Ubuntu Cloud Archive caracal series:
  New
Status in cinder package in Ubuntu:
  New
Status in cinder source package in Noble:
  New

Bug description:
  # Environment
  - OSP: zed
  - sample project: lms-test-test-test(76d24d96f319472ab56a76ab70a4f090)

  # test

  ```sh
  # login
  $ mysql -ucinder -p -hXXX.XXX.XXX
  $ MariaDB > use cinder;

  # get project cinder quota_usages 1
  $ MariaDB [cinder]> select * from quota_usages where project_id = '76d24d96f319472ab56a76ab70a4f090';
  +---------------------+---------------------+------------+---------+-----+----------------------------------+-----------------------+--------+----------+---------------+----------------+
  | created_at          | updated_at          | deleted_at | deleted | id  | project_id                       | resource              | in_use | reserved | until_refresh | race_preventer |
  +---------------------+---------------------+------------+---------+-----+----------------------------------+-----------------------+--------+----------+---------------+----------------+
  | 2024-08-07 05:10:13 | 2025-03-26 08:02:12 | NULL       |       0 | 154 | 76d24d96f319472ab56a76ab70a4f090 | volumes               |      1 |        0 |          NULL |              1 |
  | 2024-08-07 05:10:13 | 2025-03-26 08:02:12 | NULL       |       0 | 157 | 76d24d96f319472ab56a76ab70a4f090 | gigabytes             |      2 |        0 |          NULL |              1 |
  | 2024-08-07 05:10:13 | 2025-03-26 08:02:12 | NULL       |       0 | 160 | 76d24d96f319472ab56a76ab70a4f090 | volumes___DEFAULT__   |      1 |        0 |          NULL |              1 |
  | 2024-08-07 05:10:13 | 2025-03-26 08:02:12 | NULL       |       0 | 163 | 76d24d96f319472ab56a76ab70a4f090 | gigabytes___DEFAULT__ |      2 |        0 |          NULL |              1 |
  +---------------------+---------------------+------------+---------+-----+----------------------------------+-----------------------+--------+----------+---------------+----------------+

  # insert sample
  $ INSERT INTO volumes (
      created_at, updated_at, deleted_at, deleted, id, ec2_id,
      user_id, project_id, host, size, availability_zone, status,
      attach_status, scheduled_at, launched_at, terminated_at,
      display_name, display_description, provider_location, provider_auth,
      snapshot_id, volume_type_id, source_volid, bootable, provider_geometry,
      _name_id, encryption_key_id, migration_status, replication_status,
      replication_extended_status, replication_driver_data, consistencygroup_id,
      provider_id, multiattach, previous_status, cluster_name, group_id,
      service_uuid, shared_targets, use_quota
  )
  SELECT
      created_at, updated_at, deleted_at, deleted,
      '053164f4-7be3-4001-a481-d1c05a1b399',  -- 새 id 생성
      ec2_id, user_id
      , project_id
      , host, size, availability_zone, status,
      attach_status, scheduled_at, launched_at, terminated_at,
      display_name, display_description, provider_location, provider_auth,
      snapshot_id, volume_type_id, source_volid, bootable, provider_geometry,
      _name_id, encryption_key_id, migration_status, replication_status,
      replication_extended_status, replication_driver_data, consistencygroup_id,
      provider_id, multiattach, previous_status, cluster_name, group_id,
      service_uuid, shared_targets, use_quota
  FROM volumes
  WHERE deleted = 0 and status = 'available' and project_id = '76d24d96f319472ab56a76ab70a4f090'
  LIMIT 1;

  # get project cinder quota_usages 2 (not changed yet)
  MariaDB [cinder]> select * from volumes where id = '053164f4-7be3-4001-a481-d1c05a1b399';
  +---------------------+---------------------+------------+---------+-------------------------------------+--------+----------------------------------+----------------------------------+--------------------------+------+-------------------+-----------+---------------+---------------------+---------------------+---------------+--------------+---------------------+--------------------------+---------------+-------------+--------------------------------------+--------------+----------+-------------------+----------+-------------------+------------------+--------------------+-----------------------------+-------------------------+---------------------+-------------+-------------+-----------------+--------------+----------+--------------------------------------+----------------+-----------+
  | created_at          | updated_at          | deleted_at | deleted | id                                  | ec2_id | user_id                          | project_id                       | host                     | size | availability_zone | status    | attach_status | scheduled_at        | launched_at         | terminated_at | display_name | display_description | provider_location        | provider_auth | snapshot_id | volume_type_id                       | source_volid | bootable | provider_geometry | _name_id | encryption_key_id | migration_status | replication_status | replication_extended_status | replication_driver_data | consistencygroup_id | provider_id | multiattach | previous_status | cluster_name | group_id | service_uuid                         | shared_targets | use_quota |
  +---------------------+---------------------+------------+---------+-------------------------------------+--------+----------------------------------+----------------------------------+--------------------------+------+-------------------+-----------+---------------+---------------------+---------------------+---------------+--------------+---------------------+--------------------------+---------------+-------------+--------------------------------------+--------------+----------+-------------------+----------+-------------------+------------------+--------------------+-----------------------------+-------------------------+---------------------+-------------+-------------+-----------------+--------------+----------+--------------------------------------+----------------+-----------+
  | 2025-03-26 08:02:12 | 2025-03-26 08:02:15 | NULL       |       0 | 053164f4-7be3-4001-a481-d1c05a1b399 | NULL   | c7a26c5ad639484db777de6905d6a90d | 76d24d96f319472ab56a76ab70a4f090 | hci-01 at nfs_test#nfs_test |    2 | nova              | available | detached      | 2025-03-26 08:02:13 | 2025-03-26 08:02:15 | NULL          | test         |                     | 172.17.21.91:/mnt/cinder | NULL          | NULL        | 20ae6451-0f17-4911-aa6d-76b970e9a942 | NULL         |        0 | NULL              | NULL     | NULL              | NULL             | NULL               | NULL                        | NULL                    | NULL                | NULL        |           0 | NULL            | NULL         | NULL     | 12fd13d2-303e-41c5-82e6-96ac32c7ec2c |              0 |         1 |
  +---------------------+---------------------+------------+---------+-------------------------------------+--------+----------------------------------+----------------------------------+--------------------------+------+-------------------+-----------+---------------+---------------------+---------------------+---------------+--------------+---------------------+--------------------------+---------------+-------------+--------------------------------------+--------------+----------+-------------------+----------+-------------------+------------------+--------------------+-----------------------------+-------------------------+---------------------+-------------+-------------+-----------------+--------------+----------+--------------------------------------+----------------+-----------+

  # RUN cinder-manage quota sync (Looks like a success)
  $ ./cinder-manage --debug --log-file test.log quota sync --project-id 76d24d96f319472ab56a76ab70a4f090
  Processing quota usage for project 76d24d96f319472ab56a76ab70a4f090
          volumes: invalid usage saved=1 actual=2 - fixed
          gigabytes: invalid usage saved=1 actual=4 - fixed
          volumes___DEFAULT__: invalid usage saved=1 actual=2 - fixed
          gigabytes___DEFAULT__: invalid usage saved=1 actual=4 - fixed
          volumes_rbd_volumes: invalid usage saved=1 actual=0 - fixed
          gigabytes_rbd_volumes: invalid usage saved=1 actual=0 - fixed
  Action successfully completed

  # get project cinder quota_usages 3 (Still not changed yet!!)
  MariaDB [cinder]> select * from volumes where id = '053164f4-7be3-4001-a481-d1c05a1b399';
  +---------------------+---------------------+------------+---------+-------------------------------------+--------+----------------------------------+----------------------------------+--------------------------+------+-------------------+-----------+---------------+---------------------+---------------------+---------------+--------------+---------------------+--------------------------+---------------+-------------+--------------------------------------+--------------+----------+-------------------+----------+-------------------+------------------+--------------------+-----------------------------+-------------------------+---------------------+-------------+-------------+-----------------+--------------+----------+--------------------------------------+----------------+-----------+
  | created_at          | updated_at          | deleted_at | deleted | id                                  | ec2_id | user_id                          | project_id                       | host                     | size | availability_zone | status    | attach_status | scheduled_at        | launched_at         | terminated_at | display_name | display_description | provider_location        | provider_auth | snapshot_id | volume_type_id                       | source_volid | bootable | provider_geometry | _name_id | encryption_key_id | migration_status | replication_status | replication_extended_status | replication_driver_data | consistencygroup_id | provider_id | multiattach | previous_status | cluster_name | group_id | service_uuid                         | shared_targets | use_quota |
  +---------------------+---------------------+------------+---------+-------------------------------------+--------+----------------------------------+----------------------------------+--------------------------+------+-------------------+-----------+---------------+---------------------+---------------------+---------------+--------------+---------------------+--------------------------+---------------+-------------+--------------------------------------+--------------+----------+-------------------+----------+-------------------+------------------+--------------------+-----------------------------+-------------------------+---------------------+-------------+-------------+-----------------+--------------+----------+--------------------------------------+----------------+-----------+
  | 2025-03-26 08:02:12 | 2025-03-26 08:02:15 | NULL       |       0 | 053164f4-7be3-4001-a481-d1c05a1b399 | NULL   | c7a26c5ad639484db777de6905d6a90d | 76d24d96f319472ab56a76ab70a4f090 | hci-01 at nfs_test#nfs_test |    2 | nova              | available | detached      | 2025-03-26 08:02:13 | 2025-03-26 08:02:15 | NULL          | test         |                     | 172.17.21.91:/mnt/cinder | NULL          | NULL        | 20ae6451-0f17-4911-aa6d-76b970e9a942 | NULL         |        0 | NULL              | NULL     | NULL              | NULL             | NULL               | NULL                        | NULL                    | NULL                | NULL        |           0 | NULL            | NULL         | NULL     | 12fd13d2-303e-41c5-82e6-96ac32c7ec2c |              0 |         1 |
  +---------------------+---------------------+------------+---------+-------------------------------------+--------+----------------------------------+----------------------------------+--------------------------+------+-------------------+-----------+---------------+---------------------+---------------------+---------------+--------------+---------------------+--------------------------+---------------+-------------+--------------------------------------+--------------+----------+-------------------+----------+-------------------+------------------+--------------------+-----------------------------+-------------------------+---------------------+-------------+-------------+-----------------+--------------+----------+--------------------------------------+----------------+-----------+
  ```

  # find bug
  - [git > cinder > cinder/cmd/manage.py#L512](https://opendev.org/openstack/cinder/src/commit/8d17d5b8b825f171e341c8bff07d8cd0d6162024/cinder/cmd/manage.py#L512)
  - "cinder-manage quota check" and "cinder-manage quota sync" uses "@db_api.main_context_manager.reader" annotation.
  - "@db_api.main_context_manager.reader" annotation does not perform a commit.

  # test (fix source and test)
  ```sh
  # fix source
  $ cat /openstack/venvs/cinder-XX.X.X/lib/python3.10/site-packages/cinder/cmd/manage.py
      @db_api.main_context_manager.writer #@db_api.main_context_manager.reader
      def _check_project_sync(self, context, project, do_fix, resources):

  # add(for python running)
  if __name__ == '__main__':
      import sys
      sys.argv = [
          'manage.py',
          '--debug',
          '--log-file',
          'test.log',
          'quota',
          'sync',
          '--project-id', '76d24d96f319472ab56a76ab70a4f090'
      ]

  $ /openstack/venvs/cinder-XX.X.X/bin# . activate
  (cinder-27.1.0) root at hci-01:/openstack/venvs/cinder-XX.X.X/lib/python3.10/site-packages/cinder/cmd# python3 manage.py

  # get project cinder quota_usages 4 (finally changed!)
  MariaDB [cinder]> select * from quota_usages where project_id = '76d24d96f319472ab56a76ab70a4f090';
  +---------------------+---------------------+------------+---------+-----+----------------------------------+-----------------------+--------+----------+---------------+----------------+
  | created_at          | updated_at          | deleted_at | deleted | id  | project_id                       | resource              | in_use | reserved | until_refresh | race_preventer |
  +---------------------+---------------------+------------+---------+-----+----------------------------------+-----------------------+--------+----------+---------------+----------------+
  | 2024-08-07 05:10:13 | 2025-03-26 09:58:45 | NULL       |       0 | 154 | 76d24d96f319472ab56a76ab70a4f090 | volumes               |      2 |        0 |          NULL |              1 |
  | 2024-08-07 05:10:13 | 2025-03-26 09:58:45 | NULL       |       0 | 157 | 76d24d96f319472ab56a76ab70a4f090 | gigabytes             |      4 |        0 |          NULL |              1 |
  | 2024-08-07 05:10:13 | 2025-03-26 09:58:45 | NULL       |       0 | 160 | 76d24d96f319472ab56a76ab70a4f090 | volumes___DEFAULT__   |      2 |        0 |          NULL |              1 |
  | 2024-08-07 05:10:13 | 2025-03-26 09:58:45 | NULL       |       0 | 163 | 76d24d96f319472ab56a76ab70a4f090 | gigabytes___DEFAULT__ |      4 |        0 |          NULL |              1 |
  | 2025-03-26 08:15:39 | 2025-03-26 09:58:45 | NULL       |       0 | 213 | 76d24d96f319472ab56a76ab70a4f090 | volumes_rbd_volumes   |      0 |        0 |          NULL |              1 |
  | 2025-03-26 08:15:39 | 2025-03-26 09:58:45 | NULL       |       0 | 215 | 76d24d96f319472ab56a76ab70a4f090 | gigabytes_rbd_volumes |      0 |        0 |          NULL |              1 |
  +---------------------+---------------------+------------+---------+-----+----------------------------------+-----------------------+--------+----------+---------------+----------------+
  6 rows in set (0.001 sec)

  ```

To manage notifications about this bug go to:
https://bugs.launchpad.net/cinder/+bug/2104322/+subscriptions




More information about the Ubuntu-openstack-bugs mailing list