Revision c4e388a5 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
80 | 80 |
|
81 | 81 |
_MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)', |
82 | 82 |
re.M | re.I) |
83 |
_MIGRATION_INFO_MAX_BAD_ANSWERS = 5 |
|
84 |
_MIGRATION_INFO_RETRY_DELAY = 2 |
|
83 | 85 |
|
84 | 86 |
_KVM_NETWORK_SCRIPT = constants.SYSCONFDIR + "/ganeti/kvm-vif-bridge" |
85 | 87 |
|
... | ... | |
675 | 677 |
|
676 | 678 |
info_command = 'info migrate' |
677 | 679 |
done = False |
680 |
broken_answers = 0 |
|
678 | 681 |
while not done: |
679 | 682 |
result = self._CallMonitorCommand(instance_name, info_command) |
680 | 683 |
match = self._MIGRATION_STATUS_RE.search(result.stdout) |
681 | 684 |
if not match: |
682 |
raise errors.HypervisorError("Unknown 'info migrate' result: %s" % |
|
683 |
result.stdout) |
|
685 |
broken_answers += 1 |
|
686 |
if not result.stdout: |
|
687 |
logging.info("KVM: empty 'info migrate' result") |
|
688 |
else: |
|
689 |
logging.warning("KVM: unknown 'info migrate' result: %s" % |
|
690 |
result.stdout) |
|
691 |
time.sleep(self._MIGRATION_INFO_RETRY_DELAY) |
|
684 | 692 |
else: |
685 | 693 |
status = match.group(1) |
686 | 694 |
if status == 'completed': |
687 | 695 |
done = True |
688 | 696 |
elif status == 'active': |
689 |
time.sleep(2) |
|
697 |
# reset the broken answers count |
|
698 |
broken_answers = 0 |
|
699 |
time.sleep(self._MIGRATION_INFO_RETRY_DELAY) |
|
690 | 700 |
elif status == 'failed' or status == 'cancelled': |
691 | 701 |
if not live: |
692 | 702 |
self._CallMonitorCommand(instance_name, 'cont') |
693 | 703 |
raise errors.HypervisorError("Migration %s at the kvm level" % |
694 | 704 |
status) |
695 | 705 |
else: |
696 |
logging.info("KVM: unknown migration status '%s'", status) |
|
697 |
time.sleep(2) |
|
706 |
logging.warning("KVM: unknown migration status '%s'", status) |
|
707 |
broken_answers += 1 |
|
708 |
time.sleep(self._MIGRATION_INFO_RETRY_DELAY) |
|
709 |
if broken_answers >= self._MIGRATION_INFO_MAX_BAD_ANSWERS: |
|
710 |
raise errors.HypervisorError("Too many 'info migrate' broken answers") |
|
698 | 711 |
|
699 | 712 |
utils.KillProcess(pid) |
700 | 713 |
self._RemoveInstanceRuntimeFiles(pidfile, instance_name) |
Also available in: Unified diff