-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Cleanup snapshot files in datastores for Error-ed snapshots, and some code improvements #12347
New issue
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
base: 4.20
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1867,41 +1867,7 @@ public void cleanupStorage(boolean recurring) { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| //destroy snapshots in destroying state in snapshot_store_ref | ||||||||||||||
| List<SnapshotDataStoreVO> ssSnapshots = _snapshotStoreDao.listByState(ObjectInDataStoreStateMachine.State.Destroying); | ||||||||||||||
| for (SnapshotDataStoreVO snapshotDataStoreVO : ssSnapshots) { | ||||||||||||||
| String snapshotUuid = null; | ||||||||||||||
| SnapshotVO snapshot = null; | ||||||||||||||
| final String storeRole = snapshotDataStoreVO.getRole().toString().toLowerCase(); | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| snapshot = _snapshotDao.findById(snapshotDataStoreVO.getSnapshotId()); | ||||||||||||||
| if (snapshot == null) { | ||||||||||||||
| logger.warn(String.format("Did not find snapshot [ID: %d] for which store reference is in destroying state; therefore, it cannot be destroyed.", snapshotDataStoreVO.getSnapshotId())); | ||||||||||||||
| continue; | ||||||||||||||
| } | ||||||||||||||
| snapshotUuid = snapshot.getUuid(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug(String.format("Verifying if snapshot [%s] is in destroying state in %s data store ID: %d.", snapshotUuid, storeRole, snapshotDataStoreVO.getDataStoreId())); | ||||||||||||||
| } | ||||||||||||||
| SnapshotInfo snapshotInfo = snapshotFactory.getSnapshot(snapshotDataStoreVO.getSnapshotId(), snapshotDataStoreVO.getDataStoreId(), snapshotDataStoreVO.getRole()); | ||||||||||||||
| if (snapshotInfo != null) { | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug(String.format("Snapshot [%s] in destroying state found in %s data store [%s]; therefore, it will be destroyed.", snapshotUuid, storeRole, snapshotInfo.getDataStore().getUuid())); | ||||||||||||||
| } | ||||||||||||||
| _snapshotService.deleteSnapshot(snapshotInfo); | ||||||||||||||
| } else if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug(String.format("Did not find snapshot [%s] in destroying state in %s data store ID: %d.", snapshotUuid, storeRole, snapshotDataStoreVO.getDataStoreId())); | ||||||||||||||
| } | ||||||||||||||
| } catch (Exception e) { | ||||||||||||||
| logger.error("Failed to delete snapshot [{}] from storage due to: [{}].", snapshot, e.getMessage()); | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug("Failed to delete snapshot [{}] from storage.", snapshot, e); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| cleanupSnapshotsFromStoreRefInDestroyingState(); | ||||||||||||||
| cleanupSecondaryStorage(recurring); | ||||||||||||||
|
|
||||||||||||||
| List<VolumeVO> vols = volumeDao.listVolumesToBeDestroyed(new Date(System.currentTimeMillis() - ((long)StorageCleanupDelay.value() << 10))); | ||||||||||||||
|
|
@@ -1941,20 +1907,7 @@ public void cleanupStorage(boolean recurring) { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // remove snapshots in Error state | ||||||||||||||
| List<SnapshotVO> snapshots = _snapshotDao.listAllByStatus(Snapshot.State.Error); | ||||||||||||||
| for (SnapshotVO snapshotVO : snapshots) { | ||||||||||||||
| try { | ||||||||||||||
| List<SnapshotDataStoreVO> storeRefs = _snapshotStoreDao.findBySnapshotId(snapshotVO.getId()); | ||||||||||||||
| for (SnapshotDataStoreVO ref : storeRefs) { | ||||||||||||||
| _snapshotStoreDao.expunge(ref.getId()); | ||||||||||||||
| } | ||||||||||||||
| _snapshotDao.expunge(snapshotVO.getId()); | ||||||||||||||
| } catch (Exception e) { | ||||||||||||||
| logger.error("Unable to destroy snapshot [{}] due to: [{}].", snapshotVO, e.getMessage()); | ||||||||||||||
| logger.debug("Unable to destroy snapshot [{}].", snapshotVO, e); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| removeSnapshotsInErrorStatus(); | ||||||||||||||
|
|
||||||||||||||
| // destroy uploaded volumes in abandoned/error state | ||||||||||||||
| List<VolumeDataStoreVO> volumeDataStores = _volumeDataStoreDao.listByVolumeState(Volume.State.UploadError, Volume.State.UploadAbandoned); | ||||||||||||||
|
|
@@ -2055,6 +2008,63 @@ public void cleanupStorage(boolean recurring) { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private void cleanupSnapshotsFromStoreRefInDestroyingState() { | ||||||||||||||
| List<SnapshotDataStoreVO> storeRefSnapshotsInDestroyingState = _snapshotStoreDao.listByState(ObjectInDataStoreStateMachine.State.Destroying); | ||||||||||||||
| for (SnapshotDataStoreVO snapshotDataStoreVO : storeRefSnapshotsInDestroyingState) { | ||||||||||||||
| SnapshotVO snapshot = _snapshotDao.findById(snapshotDataStoreVO.getSnapshotId()); | ||||||||||||||
| if (snapshot == null) { | ||||||||||||||
| logger.warn("Did not find snapshot [ID: {}] for which store reference is in destroying state; therefore, it cannot be destroyed.", snapshotDataStoreVO.getSnapshotId()); | ||||||||||||||
| continue; | ||||||||||||||
| } | ||||||||||||||
| deleteSnapshot(snapshot, snapshotDataStoreVO); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
sureshanaparti marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| private void deleteSnapshot(SnapshotVO snapshot, SnapshotDataStoreVO snapshotDataStoreVO) { | ||||||||||||||
| if (snapshot == null || snapshotDataStoreVO == null) { | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| final String snapshotUuid = snapshot.getUuid(); | ||||||||||||||
| final String storeRole = snapshotDataStoreVO.getRole().toString().toLowerCase(); | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug("Snapshot [{}] is in {} state on {} data store ID: {}.", snapshotUuid, snapshotDataStoreVO.getState(), storeRole, snapshotDataStoreVO.getDataStoreId()); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+2031
to
+2033
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.
Suggested change
|
||||||||||||||
| SnapshotInfo snapshotInfo = snapshotFactory.getSnapshotIncludingRemoved(snapshotDataStoreVO.getSnapshotId(), snapshotDataStoreVO.getDataStoreId(), snapshotDataStoreVO.getRole()); | ||||||||||||||
| if (snapshotInfo != null) { | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug("Snapshot [{}] in {} state found on {} data store [{}], it will be deleted.", snapshotUuid, snapshotDataStoreVO.getState(), storeRole, snapshotInfo.getDataStore().getUuid()); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+2036
to
+2038
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. I think the condition is not needed for the simple getters. Else lambdas can work as well.
Suggested change
|
||||||||||||||
| _snapshotService.deleteSnapshot(snapshotInfo); | ||||||||||||||
| } else if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug("Did not find snapshot [{}] in {} state on {} data store ID: {}.", snapshotUuid, snapshotDataStoreVO.getState(), storeRole, snapshotDataStoreVO.getDataStoreId()); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+2040
to
+2042
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.
Suggested change
|
||||||||||||||
| } catch (Exception e) { | ||||||||||||||
| logger.error("Failed to delete snapshot [{}] from storage due to: [{}].", snapshot, e.getMessage()); | ||||||||||||||
| if (logger.isDebugEnabled()) { | ||||||||||||||
| logger.debug("Failed to delete snapshot [{}] from storage.", snapshot, e); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+2045
to
+2047
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.
Suggested change
|
||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private void removeSnapshotsInErrorStatus() { | ||||||||||||||
| List<SnapshotVO> snapshotsInErrorStatus = _snapshotDao.listAllByStatusIncludingRemoved(Snapshot.State.Error); | ||||||||||||||
| for (SnapshotVO snapshotVO : snapshotsInErrorStatus) { | ||||||||||||||
| try { | ||||||||||||||
| List<SnapshotDataStoreVO> storeRefSnapshotsInErrorStatus = _snapshotStoreDao.findBySnapshotId(snapshotVO.getId()); | ||||||||||||||
| for (SnapshotDataStoreVO snapshotDataStoreVO : storeRefSnapshotsInErrorStatus) { | ||||||||||||||
| deleteSnapshot(snapshotVO, snapshotDataStoreVO); | ||||||||||||||
| _snapshotStoreDao.expunge(snapshotDataStoreVO.getId()); | ||||||||||||||
| } | ||||||||||||||
| _snapshotDao.expunge(snapshotVO.getId()); | ||||||||||||||
| } catch (Exception e) { | ||||||||||||||
| logger.error("Unable to destroy snapshot [{}] due to: [{}].", snapshotVO, e.getMessage()); | ||||||||||||||
| logger.debug("Unable to destroy snapshot [{}].", snapshotVO, e); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
sureshanaparti marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| protected boolean isVolumeSuspectedDestroyDuplicateOfVmVolume(VolumeVO gcVolume) { | ||||||||||||||
| if (gcVolume.getPath() == null) { | ||||||||||||||
| return false; | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.