You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by syed <gi...@git.apache.org> on 2016/09/01 16:41:21 UTC

[GitHub] cloudstack pull request #1600: Support Backup of Snapshots for Managed Stora...

Github user syed commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1600#discussion_r77209873
  
    --- Diff: engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java ---
    @@ -328,15 +412,64 @@ private void handleCreateTemplateFromSnapshot(SnapshotInfo snapshotInfo, Templat
                     copyCommand.setOptions(srcDetails);
     
                     copyCmdAnswer = (CopyCmdAnswer)_agentMgr.send(hostVO.getId(), copyCommand);
    -            }
    -            catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex) {
    +
    +                if (needCache) {
    +
    +                    // If cached storage was needed (in case of object store as secondary
    +                    // storage), at this point, the data has been copied from the primary
    +                    // to the NFS cache by the hypervisor. We now invoke another copy
    +                    // command to copy this data from cache to secondary storage. We
    +                    // then cleanup the cache
    +
    +                    destOnStore.processEvent(Event.OperationSuccessed, copyCmdAnswer);
    +
    +                    CopyCommand cmd = new CopyCommand(destOnStore.getTO(), destData.getTO(), primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value());
    +                    EndPoint ep = selector.select(destOnStore, destData);
    +
    +                    if (ep == null) {
    +                        errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
    +                        LOGGER.error(errMsg);
    +                        copyCmdAnswer = new CopyCmdAnswer(errMsg);
    +                    } else {
    +                        copyCmdAnswer = (CopyCmdAnswer) ep.sendMessage(cmd);
    +                    }
    +
    +                    // clean up snapshot copied to staging
    +                    performCleanupCacheStorage(destOnStore);
    +                }
    +
    +
    +            } catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex) {
                     String msg = "Failed to create template from snapshot (Snapshot ID = " + snapshotInfo.getId() + ") : ";
     
                     LOGGER.warn(msg, ex);
     
                     throw new CloudRuntimeException(msg + ex.getMessage());
    -            }
    -            finally {
    +
    +            } finally {
    +
    +                // detach and remove access after the volume is created
    +                SnapshotObjectTO snapshotObjectTO = (SnapshotObjectTO) snapshotInfo.getTO();
    +                DiskTO disk = new DiskTO(snapshotObjectTO, null, snapshotInfo.getPath(), Volume.Type.UNKNOWN);
    +                DettachCommand cmd = new DettachCommand(disk, null);
    +                StoragePoolVO storagePool = _storagePoolDao.findById(srcDataStore.getId());
    +
    +                cmd.setManaged(true);
    +                cmd.setStorageHost(storagePool.getHostAddress());
    +                cmd.setStoragePort(storagePool.getPort());
    +                cmd.set_iScsiName(getProperty(snapshotInfo.getId(), DiskTO.IQN));
    +
    +                try {
    +                    DettachAnswer dettachAnswer = (DettachAnswer) _agentMgr.send(hostVO.getId(), cmd);
    +
    +                    if (!dettachAnswer.getResult()) {
    +                        throw new CloudRuntimeException("Error detaching volume:" + dettachAnswer.getDetails());
    --- End diff --
    
    There is a `catch` statement which catches this excepiton. The `revokeAccess()` call will always happen. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---