Revision 6a1434d7 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
7025 | 7025 |
@ivar shutdown_timeout: In case of failover timeout of the shutdown |
7026 | 7026 |
|
7027 | 7027 |
""" |
7028 |
|
|
7029 |
# Constants |
|
7030 |
_MIGRATION_POLL_INTERVAL = 0.5 |
|
7031 |
|
|
7028 | 7032 |
def __init__(self, lu, instance_name, cleanup=False, |
7029 | 7033 |
failover=False, fallback=False, |
7030 | 7034 |
ignore_consistency=False, |
... | ... | |
7348 | 7352 |
""" |
7349 | 7353 |
instance = self.instance |
7350 | 7354 |
target_node = self.target_node |
7355 |
source_node = self.source_node |
|
7351 | 7356 |
migration_info = self.migration_info |
7352 | 7357 |
|
7353 |
abort_result = self.rpc.call_finalize_migration(target_node,
|
|
7354 |
instance, |
|
7355 |
migration_info, |
|
7356 |
False) |
|
7358 |
abort_result = self.rpc.call_instance_finalize_migration_dst(target_node,
|
|
7359 |
instance,
|
|
7360 |
migration_info,
|
|
7361 |
False)
|
|
7357 | 7362 |
abort_msg = abort_result.fail_msg |
7358 | 7363 |
if abort_msg: |
7359 | 7364 |
logging.error("Aborting migration failed on target node %s: %s", |
... | ... | |
7361 | 7366 |
# Don't raise an exception here, as we stil have to try to revert the |
7362 | 7367 |
# disk status, even if this step failed. |
7363 | 7368 |
|
7369 |
abort_result = self.rpc.call_instance_finalize_migration_src(source_node, |
|
7370 |
instance, False, self.live) |
|
7371 |
abort_msg = abort_result.fail_msg |
|
7372 |
if abort_msg: |
|
7373 |
logging.error("Aborting migration failed on source node %s: %s", |
|
7374 |
source_node, abort_msg) |
|
7375 |
|
|
7364 | 7376 |
def _ExecMigration(self): |
7365 | 7377 |
"""Migrate an instance. |
7366 | 7378 |
|
... | ... | |
7432 | 7444 |
raise errors.OpExecError("Could not migrate instance %s: %s" % |
7433 | 7445 |
(instance.name, msg)) |
7434 | 7446 |
|
7447 |
self.feedback_fn("* starting memory transfer") |
|
7448 |
while True: |
|
7449 |
result = self.rpc.call_instance_get_migration_status(source_node, |
|
7450 |
instance) |
|
7451 |
msg = result.fail_msg |
|
7452 |
ms = result.payload # MigrationStatus instance |
|
7453 |
if msg or (ms.status in constants.HV_MIGRATION_FAILED_STATUSES): |
|
7454 |
logging.error("Instance migration failed, trying to revert" |
|
7455 |
" disk status: %s", msg) |
|
7456 |
self.feedback_fn("Migration failed, aborting") |
|
7457 |
self._AbortMigration() |
|
7458 |
self._RevertDiskStatus() |
|
7459 |
raise errors.OpExecError("Could not migrate instance %s: %s" % |
|
7460 |
(instance.name, msg)) |
|
7461 |
|
|
7462 |
if result.payload.status != constants.HV_MIGRATION_ACTIVE: |
|
7463 |
self.feedback_fn("* memory transfer complete") |
|
7464 |
break |
|
7465 |
|
|
7466 |
time.sleep(self._MIGRATION_POLL_INTERVAL) |
|
7467 |
|
|
7468 |
result = self.rpc.call_instance_finalize_migration_src(source_node, |
|
7469 |
instance, |
|
7470 |
True, |
|
7471 |
self.live) |
|
7472 |
msg = result.fail_msg |
|
7473 |
if msg: |
|
7474 |
logging.error("Instance migration succeeded, but finalization failed" |
|
7475 |
" on the source node: %s", msg) |
|
7476 |
raise errors.OpExecError("Could not finalize instance migration: %s" % |
|
7477 |
msg) |
|
7478 |
|
|
7435 | 7479 |
instance.primary_node = target_node |
7480 |
|
|
7436 | 7481 |
# distribute new instance config to the other nodes |
7437 | 7482 |
self.cfg.Update(instance, self.feedback_fn) |
7438 | 7483 |
|
7439 |
result = self.rpc.call_finalize_migration(target_node,
|
|
7440 |
instance, |
|
7441 |
migration_info, |
|
7442 |
True) |
|
7484 |
result = self.rpc.call_instance_finalize_migration_dst(target_node,
|
|
7485 |
instance,
|
|
7486 |
migration_info,
|
|
7487 |
True)
|
|
7443 | 7488 |
msg = result.fail_msg |
7444 | 7489 |
if msg: |
7445 |
logging.error("Instance migration succeeded, but finalization failed:"
|
|
7446 |
" %s", msg) |
|
7490 |
logging.error("Instance migration succeeded, but finalization failed" |
|
7491 |
" on the target node: %s", msg)
|
|
7447 | 7492 |
raise errors.OpExecError("Could not finalize instance migration: %s" % |
7448 | 7493 |
msg) |
7449 | 7494 |
|
Also available in: Unified diff