Activity log for bug #1909630

Date Who What changed Old value New value Message
2020-12-30 06:58:47 haixin bug added bug
2020-12-30 06:58:55 haixin cinder: assignee haixin (haixin77)
2020-12-30 07:11:53 haixin summary invalid quota resource when update volume type invalid quota resource when update volume type name
2020-12-31 02:25:19 haixin description When we need to update volume type name, will call: QUOTAS.update_quota_resource(elevated, old_type_name,name) in this function the code below: def update_quota_resource(self, context, old_type_name, new_type_name): for quota in ('volumes', 'gigabytes', 'snapshots'): old_res = "%s_%s" % (quota, old_type_name) new_res = "%s_%s" % (quota, new_type_name) db.quota_usage_update_resource(context, old_res, new_res) db.quota_class_update_resource(context, # it is not necessary old_res, new_res) db.quota_update_resource(context, # it is not necessary old_res, new_res) As everyone knows, there is no such resource named as "%s_%s" % (quota_type, volulme_type_name) in database table of quota_classes or quotas. in table quota_classes, there are only quota default value. in table quotas, there are only five resources for each project, there are gigabytes, volumes, backups,backup_gigabytes, snapshots. they are value of project quota. on the other hand, in fuction : def reservation_commit(context, reservations, project_id=None): this is the only way to update quota usage, usages will get from table quota_usages. So resource named as "%s_%s" % (quota_type, volulme_type_name) only exist in table quota_usages, and we not need to call quota_class_update_resource and quota_update_resource when update volume type name. When we need to update volume type name, will call: QUOTAS.update_quota_resource(elevated, old_type_name,name) in this function the code below: def update_quota_resource(self, context, old_type_name, new_type_name): for quota in ('volumes', 'gigabytes', 'snapshots'):     old_res = "%s_%s" % (quota, old_type_name)     new_res = "%s_%s" % (quota, new_type_name)     db.quota_usage_update_resource(context,                                    old_res,                                    new_res)     db.quota_class_update_resource(context, # it is not necessary                                    old_res,                                    new_res)     db.quota_update_resource(context,                              old_res,                              new_res) As everyone knows, there is no such resource named as "%s_%s" % (quota_type, volulme_type_name) in database table of quota_classes. in table quota_classes, there are only quota default value for new project. Unless we manually set the default quota for volume type. These values are default values, and we don't know how the user will name the volume type before we create it,So it doesn't make sense to preset a default value for a volume type in advance. so resource named as "%s_%s" % (quota_type, volulme_type_name) only exist in table quota_usages or quotas if we set quota for specified volume type. will not appear in table of quota_classes. so we not need to call quota_class_update_resource when update volume type name.
2021-01-05 15:53:52 michael-mcaleer tags quota volume-type
2021-01-05 15:54:00 michael-mcaleer cinder: status New Triaged
2021-01-05 15:54:08 michael-mcaleer cinder: importance Undecided Medium