mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10305: Rare race condition in KVM migration (#2466)
There is a race condition in the monitoring of the migration process on KVM. If the monitor wakes up in the tight window after the migration succeeds, but before the migration thread terminates, the monitor will get a LibvirtException “Domain not found: no domain with matching uuid” when checking on the migration status. This in turn causes CloudStack to sync the VM state to stop, in which it issues a defensive StopCommand to ensure it is correctly synced. Fix: Prevent LibvirtException: "Domain not found" caused by the call to dm.getInfo()
This commit is contained in:
parent
cae3292560
commit
703054964a
@ -172,9 +172,16 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
|
||||
|
||||
// pause vm if we meet the vm.migrate.pauseafter threshold and not already paused
|
||||
final int migratePauseAfter = libvirtComputingResource.getMigratePauseAfter();
|
||||
if (migratePauseAfter > 0 && sleeptime > migratePauseAfter && dm.getInfo().state == DomainState.VIR_DOMAIN_RUNNING ) {
|
||||
s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + migratePauseAfter+ "ms to complete migration");
|
||||
if (migratePauseAfter > 0 && sleeptime > migratePauseAfter) {
|
||||
DomainState state = null;
|
||||
try {
|
||||
state = dm.getInfo().state;
|
||||
} catch (final LibvirtException e) {
|
||||
s_logger.info("Couldn't get VM domain state after " + sleeptime + "ms: " + e.getMessage());
|
||||
}
|
||||
if (state != null && state == DomainState.VIR_DOMAIN_RUNNING) {
|
||||
try {
|
||||
s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + migratePauseAfter + "ms to complete migration");
|
||||
dm.suspend();
|
||||
} catch (final LibvirtException e) {
|
||||
// pause could be racy if it attempts to pause right when vm is finished, simply warn
|
||||
@ -182,6 +189,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
s_logger.info("Migration thread for " + vmName + " is done");
|
||||
|
||||
destDomain = migrateThread.get(10, TimeUnit.SECONDS);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user