Commit 843baa34 by Őry Máté

common: use humanize_exception for aborted activities

parent bb695789
......@@ -33,7 +33,9 @@ from sizefield.models import FileSizeField
from .tasks import local_tasks, storage_tasks
from celery.exceptions import TimeoutError
from common.models import WorkerNotFound, HumanReadableException
from common.models import (
WorkerNotFound, HumanReadableException, humanize_exception
)
logger = logging.getLogger(__name__)
......@@ -404,10 +406,11 @@ class Disk(TimeStampedModel):
try:
result = remote.get(timeout=5)
break
except TimeoutError:
except TimeoutError as e:
if task is not None and task.is_aborted():
AbortableAsyncResult(remote.id).abort()
raise Exception("Download aborted by user.")
raise humanize_exception(ugettext_noop(
"Operation aborted by user."), e)
disk.size = result['size']
disk.type = result['type']
disk.is_ready = True
......@@ -477,11 +480,12 @@ class Disk(TimeStampedModel):
try:
remote.get(timeout=5)
break
except TimeoutError:
except TimeoutError as e:
if task is not None and task.is_aborted():
AbortableAsyncResult(remote.id).abort()
disk.destroy()
raise Exception("Save as aborted by use.")
raise humanize_exception(ugettext_noop(
"Operation aborted by user."), e)
disk.is_ready = True
disk.save()
return disk
......@@ -41,7 +41,9 @@ from model_utils.models import TimeStampedModel, StatusModel
from taggit.managers import TaggableManager
from acl.models import AclBase
from common.models import create_readable, HumanReadableException
from common.models import (
create_readable, HumanReadableException, humanize_exception
)
from common.operations import OperatedMixin
from ..tasks import vm_tasks, agent_tasks
from .activity import (ActivityInProgressError, instance_activity,
......@@ -877,10 +879,11 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
while True:
try:
return remote.get(timeout=step)
except TimeoutError:
except TimeoutError as e:
if task is not None and task.is_aborted():
AbortableAsyncResult(remote.id).abort()
raise Exception("Shutdown aborted by user.")
raise humanize_exception(ugettext_noop(
"Operation aborted by user."), e)
def suspend_vm(self, timeout=230):
queue_name = self.get_remote_queue_name('vm', 'slow')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment