Periodic task to clean expired reservation
Now there is no way to clean the expired reservation. This patch added a periodic task in cinder-scheduler to do the cleanup like Nova does. Change-Id: Id792db968ed2fe8e01c64e24d99c9ebadc3232b7 Closes-bug: #1693401
This commit is contained in:
parent
07a90676f7
commit
07f242d68c
@ -62,6 +62,10 @@ quota_opts = [
|
||||
cfg.IntOpt('reservation_expire',
|
||||
default=86400,
|
||||
help='Number of seconds until a reservation expires'),
|
||||
cfg.IntOpt('reservation_clean_interval',
|
||||
default='$reservation_expire',
|
||||
help='Interval between periodic task runs to clean expired '
|
||||
'reservations in seconds.'),
|
||||
cfg.IntOpt('until_refresh',
|
||||
default=0,
|
||||
help='Count of reservations until usage is refreshed'),
|
||||
|
@ -99,6 +99,11 @@ class SchedulerManager(manager.CleanableManager, manager.Manager):
|
||||
def _clean_expired_messages(self, context):
|
||||
self.message_api.cleanup_expired_messages(context)
|
||||
|
||||
@periodic_task.periodic_task(spacing=CONF.reservation_clean_interval,
|
||||
run_immediately=True)
|
||||
def _clean_expired_reservation(self, context):
|
||||
QUOTAS.expire(context)
|
||||
|
||||
def update_service_capabilities(self, context, service_name=None,
|
||||
host=None, capabilities=None,
|
||||
cluster_name=None, timestamp=None,
|
||||
|
@ -94,12 +94,19 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
self.assertIsNone(volume_rpcapi.client.serializer._base.manifest)
|
||||
|
||||
@mock.patch('cinder.message.api.API.cleanup_expired_messages')
|
||||
def test__clean_expired_messages(self, mock_clean):
|
||||
def test_clean_expired_messages(self, mock_clean):
|
||||
|
||||
self.manager._clean_expired_messages(self.context)
|
||||
|
||||
mock_clean.assert_called_once_with(self.context)
|
||||
|
||||
@mock.patch('cinder.quota.QuotaEngine.expire')
|
||||
def test_clean_expired_reservation(self, mock_clean):
|
||||
|
||||
self.manager._clean_expired_reservation(self.context)
|
||||
|
||||
mock_clean.assert_called_once_with(self.context)
|
||||
|
||||
@mock.patch('cinder.scheduler.driver.Scheduler.'
|
||||
'update_service_capabilities')
|
||||
def test_update_service_capabilities_empty_dict(self, _mock_update_cap):
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Added periodic task to clean expired reservation in cinder scheduler.
|
||||
Added a configuration option ``reservation_clean_interval`` to handle
|
||||
the interval.
|
Loading…
Reference in New Issue
Block a user