mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Improve VMWare logs (#5353)
* Improve VMWare logs * Address reviews * Address reviews and add more logs * Improve VMWare logs * Address reviews * Address reviews and add more logs * Address reviews * Address reviews * Try fix tests * Refactor some logs to try fix tests * Verifying if GSON is the cause of test exceptions * Fix checkstyle Co-authored-by: SadiJr <17a0db2854@firemailbox.club> Co-authored-by: SadiJr <sadi@scclouds.com.br>
This commit is contained in:
parent
99313f8eae
commit
01f1aaee60
@ -44,6 +44,7 @@ import com.cloud.agent.api.to.DataTO;
|
||||
import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class StorageSubsystemCommandHandlerBase implements StorageSubsystemCommandHandler {
|
||||
private static final Logger s_logger = Logger.getLogger(StorageSubsystemCommandHandlerBase.class);
|
||||
@ -55,6 +56,7 @@ public class StorageSubsystemCommandHandlerBase implements StorageSubsystemComma
|
||||
|
||||
@Override
|
||||
public Answer handleStorageCommands(StorageSubSystemCommand command) {
|
||||
logCommand(command);
|
||||
if (command instanceof CopyCommand) {
|
||||
return this.execute((CopyCommand)command);
|
||||
} else if (command instanceof CreateObjectCommand) {
|
||||
@ -170,4 +172,12 @@ public class StorageSubsystemCommandHandlerBase implements StorageSubsystemComma
|
||||
return processor.dettachVolume(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
private void logCommand(Command cmd) {
|
||||
try {
|
||||
s_logger.debug(String.format("Executing command %s: [%s].", cmd.getClass().getSimpleName(), new Gson().toJson(cmd)));
|
||||
} catch (Exception e) {
|
||||
s_logger.debug(String.format("Executing command %s.", cmd.getClass().getSimpleName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,4 +29,6 @@ public interface VmwareHostService {
|
||||
VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd);
|
||||
|
||||
String getWorkerName(VmwareContext context, Command cmd, int workerSequence, DatastoreMO dsMo) throws Exception;
|
||||
|
||||
String createLogMessageException(Throwable e, Command command);
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -85,7 +84,6 @@ import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.template.OVAProcessor;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
@ -96,6 +94,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
private String _nfsVersion;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(VmwareHostService hostService, CreateEntityDownloadURLCommand cmd) {
|
||||
DataTO data = cmd.getData();
|
||||
@ -296,13 +295,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
return new PrimaryStorageDownloadAnswer(templateUuidName, 0);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
String msg = "Unable to execute PrimaryStorageDownloadCommand due to exception";
|
||||
s_logger.error(msg, e);
|
||||
return new PrimaryStorageDownloadAnswer(msg);
|
||||
return new PrimaryStorageDownloadAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,22 +373,14 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
try {
|
||||
if (workerVm != null) {
|
||||
// detach volume and destroy worker vm
|
||||
workerVm.detachAllDisksAndDestroy();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Failed to destroy worker VM: " + workerVMName);
|
||||
s_logger.warn(String.format("Failed to destroy worker VM [%s] due to: [%s].", workerVMName, e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
|
||||
details = "BackupSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
||||
return new BackupSnapshotAnswer(cmd, false, details, snapshotBackupUuid, true);
|
||||
return new BackupSnapshotAnswer(cmd, false, hostService.createLogMessageException(e, cmd), snapshotBackupUuid, true);
|
||||
}
|
||||
|
||||
return new BackupSnapshotAnswer(cmd, success, details, snapshotBackupUuid, true);
|
||||
@ -433,14 +418,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, null, result.first(), result.third(), result.second(), cmd.getUniqueName(), ImageFormat.OVA);
|
||||
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
|
||||
details = "CreatePrivateTemplateFromVolumeCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, details);
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,14 +439,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
return new CreatePrivateTemplateAnswer(cmd, true, null, result.first(), result.third(), result.second(), uniqeName, ImageFormat.OVA);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
|
||||
details = "CreatePrivateTemplateFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, details);
|
||||
return new CreatePrivateTemplateAnswer(cmd, false, hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,13 +475,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
}
|
||||
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
||||
s_logger.error(msg, e);
|
||||
return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
|
||||
return new CopyVolumeAnswer(cmd, false, hostService.createLogMessageException(e, cmd), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -543,12 +508,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
success = true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
||||
details = hostService.createLogMessageException(e, cmd);
|
||||
}
|
||||
|
||||
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
|
||||
@ -946,8 +906,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
Script command = new Script(false, "mkdir", _timeout, s_logger);
|
||||
command.add("-p");
|
||||
command.add(exportPath);
|
||||
if (command.execute() != null) {
|
||||
throw new Exception("unable to prepare snapshot backup directory");
|
||||
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
String errorMessage = String.format("Unable to prepare snapshot backup directory: [%s] due to [%s].", exportPath, result);
|
||||
s_logger.error(errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -968,7 +932,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
vmMo.cloneFromCurrentSnapshot(workerVmName, 0, 4, volumeDeviceInfo.second(), VmwareHelper.getDiskDeviceDatastore(volumeDeviceInfo.first()), vmxFormattedVirtualHardwareVersion);
|
||||
clonedVm = vmMo.getRunningHost().findVmOnHyperHost(workerVmName);
|
||||
if (clonedVm == null) {
|
||||
String msg = "Unable to create dummy VM to export volume. volume path: " + volumePath;
|
||||
String msg = String.format("Unable to create dummy VM to export volume. volume path: [%s].", volumePath);
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
@ -1033,7 +997,6 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
vmMo.removeSnapshot(exportName, false);
|
||||
}
|
||||
if (workerVm != null) {
|
||||
//detach volume and destroy worker vm
|
||||
workerVm.detachAllDisksAndDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -47,6 +47,7 @@ import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -96,9 +97,7 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
||||
try {
|
||||
Answer answer;
|
||||
NDC.push(getCommandLogTitle(cmd));
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Executing " + _gson.toJson(cmd));
|
||||
logCommand(cmd);
|
||||
|
||||
if (cmd instanceof PrimaryStorageDownloadCommand) {
|
||||
answer = execute((PrimaryStorageDownloadCommand)cmd);
|
||||
@ -145,6 +144,14 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
||||
}
|
||||
}
|
||||
|
||||
private void logCommand(Command cmd) {
|
||||
try {
|
||||
s_logger.debug(String.format("Executing command: [%s].", _gson.toJson(cmd)));
|
||||
} catch (Exception e) {
|
||||
s_logger.debug(String.format("Executing command: [%s].", cmd.getClass().getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
||||
protected Answer execute(CreateEntityDownloadURLCommand cmd) {
|
||||
boolean success = _storageMgr.execute(this, cmd);
|
||||
if (success) {
|
||||
@ -311,4 +318,12 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
||||
public String getMountPoint(String storageUrl, String nfsVersion) {
|
||||
return _resource.getRootDir(storageUrl, nfsVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createLogMessageException(Throwable e, Command command) {
|
||||
String message = String.format("%s failed due to [%s].", command.getClass().getSimpleName(), VmwareHelper.getExceptionMessage(e));
|
||||
s_logger.error(message, e);
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
return answer;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
s_logger.debug(ex.getMessage());
|
||||
s_logger.error(String.format("Command %s failed due to: [%s].", cmd.getClass().getSimpleName(), ex.getMessage()), ex);
|
||||
|
||||
throw new CloudRuntimeException(ex.getMessage());
|
||||
}
|
||||
@ -313,8 +313,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
if (extents != null) {
|
||||
for (HostUnresolvedVmfsExtent extent : extents) {
|
||||
s_logger.debug("extent devicePath=" + extent.getDevicePath() + ", ordinal=" + extent.getOrdinal()
|
||||
+ ", reason=" + extent.getReason() + ", isHeadExtent=" + extent.isIsHeadExtent());
|
||||
s_logger.debug(String.format("HostUnresolvedVmfsExtent details: [devicePath: %s, ordinal: %s, reason: %s, isHeadExtent: %s].", extent.getDevicePath(),
|
||||
extent.getOrdinal(), extent.getReason(), extent.isIsHeadExtent()));
|
||||
|
||||
String extentDevicePath = extent.getDevicePath();
|
||||
|
||||
@ -380,6 +380,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
* Returns the (potentially new) name of the VMDK file.
|
||||
*/
|
||||
private String cleanUpDatastore(Command cmd, HostDatastoreSystemMO hostDatastoreSystem, DatastoreMO dsMo, Map<String, String> details) throws Exception {
|
||||
s_logger.debug(String.format("Executing clean up in DataStore: [%s].", dsMo.getName()));
|
||||
boolean expandDatastore = Boolean.parseBoolean(details.get(DiskTO.EXPAND_DATASTORE));
|
||||
|
||||
// A volume on the storage system holding a template uses a minimum hypervisor snapshot reserve value.
|
||||
@ -488,11 +489,10 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
private Pair<VirtualMachineMO, Long> copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
|
||||
String templatePathAtSecondaryStorage, String templateName, String templateUuid,
|
||||
boolean createSnapshot, String nfsVersion, String configuration) throws Exception {
|
||||
s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " +
|
||||
templatePathAtSecondaryStorage + ", templateName: " + templateName + ", configuration: " + configuration);
|
||||
|
||||
String secondaryMountPoint = mountService.getMountPoint(secondaryStorageUrl, nfsVersion);
|
||||
s_logger.info("Secondary storage mount point: " + secondaryMountPoint);
|
||||
|
||||
s_logger.info(String.format("Init copy of template [name: %s, path in secondary storage: %s, configuration: %s] in secondary storage [url: %s, mount point: %s] to primary storage.",
|
||||
templateName, templatePathAtSecondaryStorage, configuration, secondaryStorageUrl, secondaryMountPoint));
|
||||
|
||||
String srcOVAFileName =
|
||||
VmwareStorageLayoutHelper.getTemplateOnSecStorageFilePath(secondaryMountPoint, templatePathAtSecondaryStorage, templateName,
|
||||
@ -525,9 +525,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
|
||||
VmConfigInfo vAppConfig;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug(String.format("Deploying OVF template %s with configuration %s", templateName, configuration));
|
||||
}
|
||||
s_logger.debug(String.format("Deploying OVF template %s with configuration %s.", templateName, configuration));
|
||||
hyperHost.importVmFromOVF(srcFileName, templateUuid, datastoreMo, "thin", configuration);
|
||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(templateUuid);
|
||||
if (vmMo == null) {
|
||||
@ -720,15 +718,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
return new CopyCmdAnswer(newTemplate);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
String msg = "Unable to copy template to primary storage due to exception:" + VmwareHelper.getExceptionMessage(e);
|
||||
|
||||
s_logger.error(msg, e);
|
||||
|
||||
return new CopyCmdAnswer(msg);
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
finally {
|
||||
if (dsMo != null && managedStoragePoolName != null) {
|
||||
@ -818,7 +808,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
VirtualMachineMO existingVm = dcMo.findVm(vmName);
|
||||
if (volume.getDeviceId().equals(0L)) {
|
||||
if (existingVm != null) {
|
||||
s_logger.info("Found existing VM " + vmName + " before cloning from template, destroying it");
|
||||
s_logger.info(String.format("Found existing VM wth name [%s] before cloning from template, destroying it", vmName));
|
||||
existingVm.detachAllDisksAndDestroy();
|
||||
}
|
||||
s_logger.info("ROOT Volume from deploy-as-is template, cloning template");
|
||||
@ -890,14 +880,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
return new CopyCmdAnswer(newVol);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
String msg = "clone volume from base image failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||
s_logger.error(msg, e);
|
||||
return new CopyCmdAnswer(e.toString());
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1074,13 +1057,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
newVolume.setPath(result.second());
|
||||
return new CopyCmdAnswer(newVolume);
|
||||
} catch (Throwable t) {
|
||||
if (t instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
||||
s_logger.error(msg, t);
|
||||
return new CopyCmdAnswer("copy volume secondary to primary failed due to exception: " + VmwareHelper.getExceptionMessage(t));
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(t, cmd));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1135,7 +1112,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
vmMo.removeSnapshot(exportName, false);
|
||||
}
|
||||
if (workerVm != null) {
|
||||
//detach volume and destroy worker vm
|
||||
workerVm.detachAllDisksAndDestroy();
|
||||
}
|
||||
}
|
||||
@ -1162,13 +1138,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
newVolume.setPath(result.first() + File.separator + result.second());
|
||||
return new CopyCmdAnswer(newVolume);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
||||
s_logger.error(msg, e);
|
||||
return new CopyCmdAnswer("copy volume from primary to secondary failed due to exception: " + VmwareHelper.getExceptionMessage(e));
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1345,14 +1315,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
return new CopyCmdAnswer(newTemplate);
|
||||
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
|
||||
details = "create template from volume exception: " + VmwareHelper.getExceptionMessage(e);
|
||||
return new CopyCmdAnswer(details);
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(e, cmd));
|
||||
} finally {
|
||||
try {
|
||||
if (volume.getVmName() == null && workerVmMo != null) {
|
||||
@ -1780,15 +1743,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
return new CopyCmdAnswer(newTemplate);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpected exception ", e);
|
||||
|
||||
details = "create template from snapshot exception: " + VmwareHelper.getExceptionMessage(e);
|
||||
|
||||
return new CopyCmdAnswer(details);
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1804,8 +1759,11 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
Script command = new Script(false, "mkdir", _timeout, s_logger);
|
||||
command.add("-p");
|
||||
command.add(exportPath);
|
||||
if (command.execute() != null) {
|
||||
throw new Exception("unable to prepare snapshot backup directory");
|
||||
String result = command.execute();
|
||||
if (result != null) {
|
||||
String errorMessage = String.format("Unable to prepare snapshot backup directory: [%s] due to [%s].", exportPath, result);
|
||||
s_logger.error(errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1835,8 +1793,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
vmMo = clonedVm;
|
||||
}
|
||||
vmMo.exportVm(exportPath, exportName, false, false);
|
||||
|
||||
vmMo.exportVm(exportPath, exportName, false, false);
|
||||
return new Pair<>(diskDevice, disks);
|
||||
} finally {
|
||||
if (clonedVm != null) {
|
||||
@ -1921,6 +1879,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
hasOwnerVm = true;
|
||||
}
|
||||
|
||||
s_logger.debug(String.format("Executing backup snapshot with UUID [%s] to secondary storage.", snapshotUuid));
|
||||
backupResult =
|
||||
backupSnapshotToSecondaryStorage(context, vmMo, hyperHost, destSnapshot.getPath(), srcSnapshot.getVolume().getPath(), snapshotUuid, secondaryStorageUrl,
|
||||
prevSnapshotUuid, prevBackupUuid, hostService.getWorkerName(context, cmd, 1, null), _nfsVersion);
|
||||
@ -2009,24 +1968,16 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
try {
|
||||
if (workerVm != null) {
|
||||
// detach volume and destroy worker vm
|
||||
workerVm.detachAllDisksAndDestroy();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Failed to destroy worker VM: " + workerVMName);
|
||||
s_logger.warn(String.format("Failed to destroy worker VM [%s] due to: [%s]", workerVMName, e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
|
||||
return answer;
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
|
||||
details = "backup snapshot exception: " + VmwareHelper.getExceptionMessage(e);
|
||||
return new CopyCmdAnswer(details);
|
||||
return new CopyCmdAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2226,23 +2177,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
return answer;
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
|
||||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
String msg = "";
|
||||
|
||||
if (isAttach) {
|
||||
msg += "Failed to attach volume: ";
|
||||
}
|
||||
else {
|
||||
msg += "Failed to detach volume: ";
|
||||
}
|
||||
|
||||
s_logger.error(msg + e.getMessage(), e);
|
||||
|
||||
String msg = String.format("Failed to %s volume!", isAttach? "attach" : "detach");
|
||||
s_logger.error(msg, e);
|
||||
hostService.createLogMessageException(e, cmd);
|
||||
// Sending empty error message - too many duplicate errors in UI
|
||||
return new AttachAnswer("");
|
||||
}
|
||||
@ -2468,17 +2405,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
if (isAttach) {
|
||||
String msg = "AttachIsoCommand(attach) failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||
msg = msg + " Also check if your guest os is a supported version";
|
||||
s_logger.error(msg, e);
|
||||
return new AttachAnswer(msg);
|
||||
} else {
|
||||
String msg = "AttachIsoCommand(detach) failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||
msg = msg + " Also check if your guest os is a supported version";
|
||||
s_logger.warn(msg, e);
|
||||
return new AttachAnswer(msg);
|
||||
}
|
||||
String message = String.format("AttachIsoCommand(%s) failed due to: [%s]. Also check if your guest os is a supported version", isAttach? "attach" : "detach", VmwareHelper.getExceptionMessage(e));
|
||||
s_logger.error(message, e);
|
||||
return new AttachAnswer(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2558,14 +2487,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
}
|
||||
return new CreateObjectAnswer(newVol);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
String msg = "create volume failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||
s_logger.error(msg, e);
|
||||
return new CreateObjectAnswer(e.toString());
|
||||
return new CreateObjectAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2588,10 +2510,6 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
@Override
|
||||
public Answer deleteVolume(DeleteCommand cmd) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Executing resource DeleteCommand: " + _gson.toJson(cmd));
|
||||
}
|
||||
|
||||
try {
|
||||
VmwareContext context = hostService.getServiceContext(null);
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
|
||||
@ -2735,14 +2653,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
return new Answer(cmd, true, "Success");
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
String msg = "delete volume failed due to " + VmwareHelper.getExceptionMessage(e);
|
||||
s_logger.error(msg, e);
|
||||
return new Answer(cmd, false, msg);
|
||||
return new Answer(cmd, false, hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3816,12 +3727,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
newVol.setPath(newVolumeName);
|
||||
return new CopyCmdAnswer(newVol);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
details = "create volume from snapshot exception: " + VmwareHelper.getExceptionMessage(e);
|
||||
hostService.createLogMessageException(e, cmd);
|
||||
details = String.format("Failed to create volume from snapshot due to exception: [%s]", VmwareHelper.getExceptionMessage(e));
|
||||
}
|
||||
return new CopyCmdAnswer(details);
|
||||
}
|
||||
@ -3907,11 +3814,8 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
else
|
||||
return new Answer(cmd, isDatastoreStoragePolicyComplaint, null);
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
String details = String.format("Exception while checking if datastore %s is storage policy %s complaince : %s", primaryStorageNameLabel, storagePolicyId, VmwareHelper.getExceptionMessage(e));
|
||||
s_logger.error(details, e);
|
||||
hostService.createLogMessageException(e, cmd);
|
||||
String details = String.format("Exception while checking if datastore [%s] is storage policy [%s] complaince due to: [%s]", primaryStorageNameLabel, storagePolicyId, VmwareHelper.getExceptionMessage(e));
|
||||
return new Answer(cmd, false, details);
|
||||
}
|
||||
}
|
||||
@ -4023,13 +3927,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
|
||||
|
||||
return answer;
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
|
||||
|
||||
hostService.invalidateServiceContext(null);
|
||||
}
|
||||
|
||||
return new SyncVolumePathAnswer("Failed to process SyncVolumePathCommand due to " + e.getMessage());
|
||||
return new SyncVolumePathAnswer(hostService.createLogMessageException(e, cmd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,6 +127,7 @@ import com.vmware.vim25.VirtualSCSISharing;
|
||||
public class VirtualMachineMO extends BaseMO {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualMachineMO.class);
|
||||
private static final ExecutorService MonitorServiceExecutor = Executors.newCachedThreadPool(new NamedThreadFactory("VM-Question-Monitor"));
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
public static final String ANSWER_YES = "0";
|
||||
public static final String ANSWER_NO = "1";
|
||||
@ -1402,7 +1403,7 @@ public class VirtualMachineMO extends BaseMO {
|
||||
|
||||
if(s_logger.isTraceEnabled())
|
||||
s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: "
|
||||
+ new Gson().toJson(vmdkDatastorePathChain) + ", datastore: " + morDs.getValue());
|
||||
+ GSON.toJson(vmdkDatastorePathChain) + ", datastore: " + morDs.getValue());
|
||||
int controllerKey = 0;
|
||||
int unitNumber = 0;
|
||||
|
||||
@ -1800,7 +1801,7 @@ public class VirtualMachineMO extends BaseMO {
|
||||
Pair<VmdkFileDescriptor, byte[]> result = new Pair<VmdkFileDescriptor, byte[]>(descriptor, content);
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("vCenter API trace - getVmdkFileInfo() done");
|
||||
s_logger.trace("VMDK file descriptor: " + new Gson().toJson(result.first()));
|
||||
s_logger.trace("VMDK file descriptor: " + GSON.toJson(result.first()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user