Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ protected Void createVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, C
} else {
vo.processEvent(Event.OperationFailed);
errMsg = result.getResult();
VolumeVO volume = volDao.findById(vo.getId());
if (volume != null && volume.getState() == State.Allocated && volume.getPodId() != null) {
volume.setPoolId(null);
volDao.update(volume.getId(), volume);
}
}
VolumeApiResult volResult = new VolumeApiResult((VolumeObject)vo);
if (errMsg != null) {
Expand Down Expand Up @@ -1238,6 +1243,10 @@ private void destroyAndReallocateManagedVolume(VolumeInfo volumeInfo) {
}

if (volume.getState() == State.Allocated) { // Possible states here: Allocated, Ready & Creating
if (volume.getPodId() != null) {
volume.setPoolId(null);
volDao.update(volume.getId(), volume);
}
return;
}

Expand Down Expand Up @@ -2482,7 +2491,7 @@ public AsyncCallFuture<VolumeApiResult> resize(VolumeInfo volume) {
try {
volume.processEvent(Event.ResizeRequested);
} catch (Exception e) {
s_logger.debug("Failed to change state to resize", e);
s_logger.debug("Failed to change volume state to resize", e);
result.setResult(e.toString());
future.complete(result);
return future;
Expand All @@ -2494,10 +2503,8 @@ public AsyncCallFuture<VolumeApiResult> resize(VolumeInfo volume) {
try {
volume.getDataStore().getDriver().resize(volume, caller);
} catch (Exception e) {
s_logger.debug("Failed to change state to resize", e);

s_logger.debug("Failed to resize volume", e);
result.setResult(e.toString());

future.complete(result);
}

Expand Down Expand Up @@ -2541,7 +2548,7 @@ protected Void resizeVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, C
try {
volume.processEvent(Event.OperationFailed);
} catch (Exception e) {
s_logger.debug("Failed to change state", e);
s_logger.debug("Failed to change volume state (after resize failure)", e);
}
VolumeApiResult res = new VolumeApiResult(volume);
res.setResult(result.getResult());
Expand All @@ -2552,13 +2559,8 @@ protected Void resizeVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, C
try {
volume.processEvent(Event.OperationSuccessed);
} catch (Exception e) {
s_logger.debug("Failed to change state", e);
VolumeApiResult res = new VolumeApiResult(volume);
res.setResult(result.getResult());
future.complete(res);
return null;
s_logger.debug("Failed to change volume state (after resize success)", e);
}

VolumeApiResult res = new VolumeApiResult(volume);
future.complete(res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,25 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
boolean encryptionRequired = anyVolumeRequiresEncryption(vol);
long [] endpointsToRunResize = resizeParameter.hosts;

CreateCmdResult result = new CreateCmdResult(null, null);

// if hosts are provided, they are where the VM last ran. We can use that.
if (endpointsToRunResize == null || endpointsToRunResize.length == 0) {
EndPoint ep = epSelector.select(data, encryptionRequired);
if (ep == null) {
String errMsg = String.format(NO_REMOTE_ENDPOINT_WITH_ENCRYPTION, encryptionRequired);
s_logger.error(errMsg);
result.setResult(errMsg);
callback.complete(result);
return;
}
endpointsToRunResize = new long[] {ep.getId()};
}
ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(),
resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName, vol.getChainInfo(), vol.getPassphrase(), vol.getEncryptFormat());
if (pool.getParent() != 0) {
resizeCmd.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
}
CreateCmdResult result = new CreateCmdResult(null, null);
try {
ResizeVolumeAnswer answer = (ResizeVolumeAnswer) storageMgr.sendToPool(pool, endpointsToRunResize, resizeCmd);
if (answer != null && answer.getResult()) {
Expand All @@ -456,7 +464,6 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
s_logger.debug("return a null answer, mark it as failed for unknown reason");
result.setResult("return a null answer, mark it as failed for unknown reason");
}

} catch (Exception e) {
s_logger.debug("sending resize command failed", e);
result.setResult(e.toString());
Expand Down