From 6057d50d52e0473b7c319d8143bf64633b412eab Mon Sep 17 00:00:00 2001 From: anthony Date: Tue, 31 Aug 2010 17:00:25 -0700 Subject: [PATCH] bug 6057: it happens because management server command timeout before xenapi timeout, when CheckHealthcommand returns, there is no listener since it's a sync command status 6057: resolved fixed --- .../xen/resource/CitrixResourceBase.java | 85 +++---------------- 1 file changed, 11 insertions(+), 74 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 022ba79a5ea..1d0425875ee 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3101,7 +3101,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR return true; } - protected String callHostPluginBase(String plugin, String cmd, String... params) { + protected String callHostPluginBase(String plugin, String cmd, int timeout, String... params) { Map args = new HashMap(); Session slaveSession = null; Connection slaveConn = null; @@ -3113,7 +3113,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR // TODO Auto-generated catch block e.printStackTrace(); } - slaveConn = new Connection(slaveUrl, 1800); + slaveConn = new Connection(slaveUrl, timeout); slaveSession = Session.slaveLocalLoginWithPassword(slaveConn, _username, _password); if (s_logger.isDebugEnabled()) { @@ -3149,53 +3149,13 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } protected String callHostPlugin(String cmd, String... params) { - Map args = new HashMap(); - Session slaveSession = null; - Connection slaveConn = null; - try { - URL slaveUrl = null; - try { - slaveUrl = new URL("http://" + _host.ip); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - slaveConn = new Connection(slaveUrl, 1800); - slaveSession = Session.slaveLocalLoginWithPassword(slaveConn, _username, _password); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Slave logon successful. session= " + slaveSession); - } - Host host = Host.getByUuid(slaveConn, _host.uuid); - - - for (int i = 0; i < params.length; i += 2) { - args.put(params[i], params[i + 1]); - } - - if (s_logger.isTraceEnabled()) { - s_logger.trace("callHostPlugin executing for command " + cmd + " with " + getArgsString(args)); - } - - String result = host.callPlugin(slaveConn, "vmops", cmd, args); - if (s_logger.isTraceEnabled()) { - s_logger.trace("callHostPlugin Result: " + result); - } - return result.replace("\n", ""); - } catch (XenAPIException e) { - s_logger.warn("callHostPlugin failed for cmd: " + cmd + " with args " + getArgsString(args) + " due to " + e.toString()); - } catch (XmlRpcException e) { - s_logger.debug("callHostPlugin failed for cmd: " + cmd + " with args " + getArgsString(args) + " due to " + e.getMessage()); - } finally { - if( slaveSession != null) { - try { - Session.localLogout(slaveConn); - } catch (Exception e) { - } - } - } - return null; + return callHostPluginBase("vmops", cmd, 300, params); } + + protected String callHostPluginWithTimeOut(String cmd, int timeout, String... params) { + return callHostPluginBase("vmops", cmd, timeout, params); + } + protected String getArgsString(Map args) { StringBuilder argString = new StringBuilder(); @@ -5982,7 +5942,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR checksum = ""; } - String result = callHostPlugin("post_create_private_template", "remoteTemplateMountPath", remoteTemplateMountPath, "templateDownloadFolder", templateDownloadFolder, + String result = callHostPluginWithTimeOut("post_create_private_template", 1800, "remoteTemplateMountPath", remoteTemplateMountPath, "templateDownloadFolder", templateDownloadFolder, "templateInstallFolder", templateInstallFolder, "templateFilename", templateFilename, "templateName", templateName, "templateDescription", templateDescription, "checksum", checksum, "virtualSize", String.valueOf(virtualSize), "templateId", String.valueOf(templateId)); @@ -6005,29 +5965,6 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR return success; } - protected boolean waitForGC(String primaryStorageSRUuid, String previousSnapshotUuid, String firstBackupUuid, Boolean isISCSI) { - boolean success = false; - String result = callHostPlugin("validatePreviousSnapshotBackup", "primaryStorageSRUuid", primaryStorageSRUuid, "previousSnapshotUuid", previousSnapshotUuid, - "firstBackupUuid", firstBackupUuid, "isISCSI", isISCSI.toString()); - - if (result != null && !result.isEmpty()) { - String[] expectedActual = result.split("#"); - String status = expectedActual[0]; - - if (expectedActual.length == 3) { - String expectedParentOfPreviousSnapshot = expectedActual[1]; - String actualParentOfPreviousSnapshot = expectedActual[2]; - if (status.equals("1") && expectedParentOfPreviousSnapshot.equals(actualParentOfPreviousSnapshot)) { - success = true; - } else { - s_logger.error("Could not backup snapshot because the previous snapshot hasn't been coalesced by XenServer GC." + "Expected parent of previous snapshot: " - + expectedParentOfPreviousSnapshot + " Actual parent of previous snapshot: " + actualParentOfPreviousSnapshot); - } - } - } - return success; - } - // Each argument is put in a separate line for readability. // Using more lines does not harm the environment. protected String backupSnapshot(String primaryStorageSRUuid, Long dcId, Long accountId, Long volumeId, String secondaryStorageMountPath, String snapshotUuid, @@ -6043,7 +5980,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR // Each argument is put in a separate line for readability. // Using more lines does not harm the environment. - String results = callHostPlugin("backupSnapshot", "primaryStorageSRUuid", primaryStorageSRUuid, "dcId", dcId.toString(), "accountId", accountId.toString(), "volumeId", + String results = callHostPluginWithTimeOut("backupSnapshot", 1800, "primaryStorageSRUuid", primaryStorageSRUuid, "dcId", dcId.toString(), "accountId", accountId.toString(), "volumeId", volumeId.toString(), "secondaryStorageMountPath", secondaryStorageMountPath, "snapshotUuid", snapshotUuid, "prevSnapshotUuid", prevSnapshotUuid, "prevBackupUuid", prevBackupUuid, "isFirstSnapshotOfRootVolume", isFirstSnapshotOfRootVolume.toString(), "isISCSI", isISCSI.toString()); @@ -6146,7 +6083,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR String failureString = "Could not create volume from " + backedUpSnapshotUuid; templatePath = (templatePath == null) ? "" : templatePath; - String results = callHostPlugin("createVolumeFromSnapshot", "dcId", dcId.toString(), "accountId", accountId.toString(), "volumeId", volumeId.toString(), + String results = callHostPluginWithTimeOut("createVolumeFromSnapshot", 1800, "dcId", dcId.toString(), "accountId", accountId.toString(), "volumeId", volumeId.toString(), "secondaryStorageMountPath", secondaryStorageMountPath, "backedUpSnapshotUuid", backedUpSnapshotUuid, "templatePath", templatePath, "templateDownloadFolder", templateDownloadFolder, "isISCSI", isISCSI.toString());