From bac419e256b34c1f4399aae397671760b62b79ff Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Mon, 7 Mar 2011 14:32:43 +0100 Subject: [PATCH] Fixed error handling on election. --- ccserver/election.py | 9 ++++----- ccserver/exceptions.py | 4 ++++ ccserver/handlers.py | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ccserver/election.py b/ccserver/election.py index c41dd31..a04470d 100644 --- a/ccserver/election.py +++ b/ccserver/election.py @@ -9,7 +9,8 @@ from __future__ import absolute_import from copy import copy -from ccserver.exceptions import UnknownElectionAlgo, UnknownElectionType +from ccserver.exceptions import (UnknownElectionAlgo, UnknownElectionType, + ElectionError) def tags(*args): ''' @@ -126,10 +127,8 @@ class Elector(object): hv_alloc = {} for vm, hvs in candidates: if not hvs: - migration_plan.append({'sid': vm['id'], - 'did': '', - 'error': 'no destination hv found', - 'type': 'error'}) + raise ElectionError('No destination found for %r vm' % vm['id']) + else: # Try to take an hypervisor that is not already in the plan: for hv in hvs: diff --git a/ccserver/exceptions.py b/ccserver/exceptions.py index 3836ef8..55827f8 100644 --- a/ccserver/exceptions.py +++ b/ccserver/exceptions.py @@ -56,3 +56,7 @@ class UnknownMigrationType(Exception): class UnknownObjectError(Exception): pass + + +class ElectionError(Exception): + pass diff --git a/ccserver/handlers.py b/ccserver/handlers.py index 8e98229..f2911be 100644 --- a/ccserver/handlers.py +++ b/ccserver/handlers.py @@ -709,6 +709,7 @@ class CliHandler(OnlineCCHandler): else: errmsg = '%r unknown migration type' % migration['type'] errs.error(migration['sid'], errmsg) + continue # Construct the migration properties: migration_properties = { -- GitLab