| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -16,6 +16,8 @@ | |
| // under the License. | ||
| package org.apache.cloudstack.storage.datastore; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| import org.apache.log4j.Logger; | ||
| Expand Down Expand Up | @@ -44,6 +46,7 @@ | |
| import com.cloud.agent.api.to.DataObjectType; | ||
| import com.cloud.agent.api.to.S3TO; | ||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||
| import com.cloud.storage.DataStoreRole; | ||
| import com.cloud.storage.SnapshotVO; | ||
| import com.cloud.storage.VMTemplateStoragePoolVO; | ||
| Expand Down Expand Up | @@ -172,7 +175,11 @@ public DataObject create(DataObject obj, DataStore dataStore) { | |
| if (snapshotDataStoreVO != null) { | ||
| ss.setParentSnapshotId(snapshotDataStoreVO.getSnapshotId()); | ||
| } | ||
| ss.setInstallPath(TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + snapshotDao.findById(obj.getId()).getAccountId() + "/" + snapshot.getVolumeId()); | ||
| String snapshotInstallPath = TemplateConstants.DEFAULT_SNAPSHOT_ROOT_DIR + "/" + snapshotDao.findById(obj.getId()).getAccountId() + "/" + snapshot.getVolumeId(); | ||
| if (snapshot.getHypervisorType().equals(HypervisorType.VMware)) { | ||
| snapshotInstallPath = snapshotInstallPath.concat("/" + UUID.randomUUID().toString()); | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI would also call concat twice: 1 for the "/"; and the 2nd time for the UUID.randomUUID().toString().
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityauto spell typo? contact == concat
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYep... I edited. :)
Sorry, something went wrong.
All reactions
|
||
| } | ||
| ss.setInstallPath(snapshotInstallPath); | ||
| ss.setState(ObjectInDataStoreStateMachine.State.Allocated); | ||
| ss = snapshotDataStoreDao.persist(ss); | ||
| break; | ||
| Expand Down Expand Up | @@ -265,7 +272,8 @@ public boolean deleteIfNotReady(DataObject dataObj) { | |
| return true; | ||
| case SNAPSHOT: | ||
| SnapshotDataStoreVO destSnapshotStore = snapshotDataStoreDao.findByStoreSnapshot(dataStore.getRole(), dataStore.getId(), objId); | ||
| if (destSnapshotStore != null && destSnapshotStore.getState() != ObjectInDataStoreStateMachine.State.Ready) { | ||
| if (destSnapshotStore != null && destSnapshotStore.getState() != ObjectInDataStoreStateMachine.State.Ready && | ||
| destSnapshotStore.getState() != ObjectInDataStoreStateMachine.State.Allocated) { | ||
| return snapshotDataStoreDao.remove(destSnapshotStore.getId()); | ||
| } else { | ||
| s_logger.warn("Snapshot " + objId + " is not found on image store " + dataStore.getId() + ", so no need to delete"); | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -98,7 +98,10 @@ | |
| import com.cloud.agent.AgentManager; | ||
| import com.cloud.agent.api.Answer; | ||
| import com.cloud.agent.api.Command; | ||
| import com.cloud.agent.api.DeleteSnapshotsDirCommand; | ||
| import com.cloud.agent.api.DeleteVMSnapshotCommand; | ||
| import com.cloud.agent.api.StoragePoolInfo; | ||
| import com.cloud.agent.api.VMSnapshotTO; | ||
| import com.cloud.agent.manager.Commands; | ||
| import com.cloud.api.ApiDBUtils; | ||
| import com.cloud.api.query.dao.TemplateJoinDao; | ||
| Expand Down Expand Up | @@ -1120,14 +1123,60 @@ public void cleanupStorage(boolean recurring) { | |
| } | ||
|
|
||
| // remove snapshots in Error state | ||
| List<SnapshotVO> snapshots = _snapshotDao.listAllByStatus(Snapshot.State.Error); | ||
| List<SnapshotVO> snapshots = _snapshotDao.listAllByStatusIncludingRemoved(Snapshot.State.Error); | ||
| for (SnapshotVO snapshotVO : snapshots) { | ||
| try { | ||
| List<SnapshotDataStoreVO> storeRefs = _snapshotStoreDao.findBySnapshotId(snapshotVO.getId()); | ||
| boolean isVMware = snapshotVO.getHypervisorType().equals(HypervisorType.VMware); | ||
| boolean removeSnapshot = true; | ||
| for (SnapshotDataStoreVO ref : storeRefs) { | ||
| _snapshotStoreDao.expunge(ref.getId()); | ||
| // Cleanup corresponding items (if any) from secondary storage. | ||
| if (isVMware) { | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityonly for vmware???
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGood catch! We would have to get the PR in and test it, without the IF, against Xen and KVM, at least. What do you think?
Sorry, something went wrong.
All reactions
|
||
| if(ref.getRole().isImageStore()) { // Delete items from secondary storage | ||
| DataStore snapshotDataStore = _dataStoreMgr.getDataStore(ref.getDataStoreId(), DataStoreRole.Image); | ||
| DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(snapshotDataStore.getTO(), ref.getInstallPath()); | ||
| EndPoint ep = _epSelector.select(snapshotDataStore); | ||
| if (ep == null) { | ||
| s_logger.warn("There is no secondary storage VM for image store: " + snapshotDataStore.getName() + ", cannot cleanup snapshot: " + snapshotVO.getUuid()); | ||
| removeSnapshot = false; | ||
| continue; | ||
| } | ||
| Answer deleteSnapshotsDirAnswer = ep.sendMessage(cmd); | ||
| if ((deleteSnapshotsDirAnswer != null) && deleteSnapshotsDirAnswer.getResult()) { | ||
| s_logger.debug("Deleted snapshot: " + snapshotVO.getUuid() + " from secondary storage: " + snapshotDataStore.getName()); | ||
| _snapshotStoreDao.expunge(ref.getId()); | ||
| } else { | ||
| s_logger.warn("Failed to delete snapshot: " + snapshotVO.getUuid() + " from secondary storage: " + snapshotDataStore.getName()); | ||
| removeSnapshot = false; | ||
| } | ||
| } else if (ref.getRole() == DataStoreRole.Primary) { // Delete worker VM snapshot | ||
| VolumeVO volume = _volumeDao.findByIdIncludingRemoved(snapshotVO.getVolumeId()); | ||
| if (volume.getInstanceId() == null) | ||
| continue; | ||
| VMInstanceVO vm = _vmInstanceDao.findById(volume.getInstanceId()); | ||
| Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId(); | ||
| if (hostId != null) { | ||
| VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(); | ||
| vmSnapshotTO.setSnapshotName(ref.getInstallPath()); | ||
| vmSnapshotTO.setDescription(snapshotVO.getName()); | ||
| DeleteVMSnapshotCommand deleteSnapshotCommand = new DeleteVMSnapshotCommand(vm.getInstanceName(), vmSnapshotTO, null, null); | ||
| Answer deleteSnapshotAnswer = _agentMgr.send(hostId, deleteSnapshotCommand); | ||
| if ((deleteSnapshotAnswer != null) && deleteSnapshotAnswer.getResult()) { | ||
| s_logger.debug("Deleted worker VM snapshot: " + snapshotVO.getName()); | ||
| _snapshotStoreDao.expunge(ref.getId()); | ||
| } else { | ||
| s_logger.warn("Failed to delete worker VM snapshot: " + snapshotVO.getName()); | ||
| removeSnapshot = false; | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| _snapshotStoreDao.expunge(ref.getId()); | ||
| } | ||
| } | ||
| if (removeSnapshot) { | ||
| _snapshotDao.expunge(snapshotVO.getId()); | ||
| } | ||
| _snapshotDao.expunge(snapshotVO.getId()); | ||
| } catch (Exception e) { | ||
| s_logger.warn("Unable to destroy snapshot " + snapshotVO.getUuid(), e); | ||
| } | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs this really only true for vmware? It seems that adding a uuid to the path is a rather universal action in the ssvm, no?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt seems like it should be applied to any hypervisor.
Is that another one we can take in and fix?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.