From ca249b248b0a3096cc59b98922d08f28f31ba31b Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Tue, 13 Aug 2013 21:54:44 +0800 Subject: [PATCH] Fix resize volume stuck in "RESIZE" status While resizing a improper volume, it may stuck in "RESIZE" status and Trove can't deal with this status with other actions. We need to catch the exception. Now, resize volume method exists some problems to achieve the goal. This patch will solve the critical problem firstly. fix bug 1212767 Change-Id: I868694fc01217ef0e6e8450ce981c4cab544b612 --- trove/taskmanager/models.py | 11 ++++++++++- trove/tests/fakes/nova.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index 47edd58b01..6fd45602ac 100644 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -14,6 +14,7 @@ import traceback +from cinderclient import exceptions as cinder_exceptions from eventlet import greenthread from novaclient import exceptions as nova_exceptions from trove.common import cfg @@ -456,7 +457,15 @@ class BuiltInstanceTasks(BuiltInstance, NotifyMixin, ConfigurationMixin): LOG.debug("%s: Resizing volume for instance: %s from %s to %r GB" % (greenthread.getcurrent(), self.server.id, old_volume_size, new_size)) - self.volume_client.volumes.resize(self.volume_id, new_size) + try: + self.volume_client.volumes.extend(self.volume_id, new_size) + except cinder_exceptions.ClientException: + self.update_db(task_status=inst_models.InstanceTasks.NONE) + LOG.exception("Error encountered trying to rescan or resize the " + "attached volume filesystem for volume: " + "%s" % self.volume_id) + raise + try: utils.poll_until( lambda: self.volume_client.volumes.get(self.volume_id), diff --git a/trove/tests/fakes/nova.py b/trove/tests/fakes/nova.py index 8e4c5325cb..b86a4d44b9 100644 --- a/trove/tests/fakes/nova.py +++ b/trove/tests/fakes/nova.py @@ -497,7 +497,7 @@ class FakeVolumes(object): def list(self, detailed=True): return [self.db[key] for key in self.db] - def resize(self, volume_id, new_size): + def extend(self, volume_id, new_size): LOG.debug("Resize volume id (%s) to size (%s)" % (volume_id, new_size)) volume = self.get(volume_id)