Uh oh!
There was an error while loading. Please reload this page.
CLOUDSTACK-9570: Bug in listSnapshots for snapshots with deleted data stores - #1735
CLOUDSTACK-9570: Bug in listSnapshots for snapshots with deleted data stores#1735nvazquez wants to merge 1 commit into
Conversation
yadvr
commented
Nov 1, 2016
LGTM. I'll fire some regression tests. |
blueorangutan
commented
Nov 1, 2016
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Nov 1, 2016
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-131 |
yadvr
commented
Nov 1, 2016
@blueorangutan test |
abhinandanprateek
commented
Nov 4, 2016
LGTM on code review. |
dd7d85a to
b63805cCompareserg38
commented
Nov 8, 2016
@rhtyd @jburwell The tests didn't kick in last time. Can we fire matrix again? |
ustcweizhou
commented
Nov 8, 2016
if the data store is deleted, the snapshot should be removed as well, right? |
yadvr
commented
Nov 8, 2016
@blueorangutan package |
blueorangutan
commented
Nov 8, 2016
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
| long storagePoolId = snapshotStore.getDataStoreId(); | ||
| DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); | ||
| if (! snapshotStore.getState().equals(ObjectInDataStoreStateMachine.State.Destroyed)){ |
There was a problem hiding this comment.
@nvazquez this can cause NPE, instead use ObjectInDataStoreStateMachine.State.Destroyed.equals(...) or an explicit != null.
blueorangutan
commented
Nov 8, 2016
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-149 |
serg38
commented
Nov 8, 2016
@ustcweizhou Not necessary. The issue affects removal of primary storage DS where there are snapshot copies. After that the snapshot could remain on secondary storage. |
b63805c to
18d2a05Comparejburwell
commented
Nov 8, 2016
@nvazquez could you please add a Marvin test to verify this fix? |
nvazquez
commented
Nov 8, 2016
@jburwell sure, will work on it |
| Boolean supportsStorageSystemSnapshots = new Boolean(value); | ||
| if (mapCapabilities != null) { | ||
| String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); | ||
| Boolean supportsStorageSystemSnapshots = new Boolean(value); |
There was a problem hiding this comment.
new Boolean skips the constant pool -- putting unnecessary pressure on the heap and creating a potential memory leak. Please use Boolean.valueOf to part the value to avoid this issue.
18d2a05 to
0c2ad75Compareyadvr
commented
Nov 20, 2016
@blueorangutan package |
blueorangutan
commented
Nov 20, 2016
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Nov 20, 2016
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-184 |
42be7f6 to
32c3e89Comparenvazquez
commented
Nov 21, 2016
@jburwell I added new Marvin test in |
yadvr
commented
Nov 23, 2016
@blueorangutan package |
yadvr
commented
Nov 23, 2016
LGTM. |
jburwell
commented
Nov 23, 2016
@nvazquez could you please check into the Travis failures? |
yadvr
commented
Nov 24, 2016
@blueorangutan package |
blueorangutan
commented
Nov 24, 2016
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Nov 24, 2016
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-245 |
yadvr
commented
Nov 24, 2016
@jburwell the Travis failure is ignorable caused by a oobm corner case (exception is ignorable). I'll work on a fix soon. |
blueorangutan
commented
Nov 24, 2016
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
nvazquez
commented
Nov 24, 2016
@jburwell @rhtyd sorry I've been off yesterday, do I push force to kick tests again? |
blueorangutan
commented
Nov 24, 2016
Trillian test result (tid-426)
|
32c3e89 to
8369007Compare8369007 to
ed87d66Compare| _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); | ||
| Long domainId = domainIdRecursiveListProject.first(); | ||
| Boolean isRecursive = domainIdRecursiveListProject.second(); | ||
| ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third(); |
There was a problem hiding this comment.
Hi @anshul1886, at the beggining of each line there's one space added, to be consistent with indentation
There was a problem hiding this comment.
These type of changes should not be done on unrelated file as it makes following changes difficult.
| snapshotResponse.setObjectName("snapshot"); | ||
| snapshotResponses.add(snapshotResponse); | ||
| if (snapshotResponse != null) { | ||
| snapshotResponse.setObjectName("snapshot"); |
There was a problem hiding this comment.
Is any issue observed here for which null check is added?
There was a problem hiding this comment.
This check is added as we introduced a case in createSnapshotResponse where null is returned, and in that case we shouldn't add the response to the response list
There was a problem hiding this comment.
What is the use case for null case when that can happen?
There was a problem hiding this comment.
I've added a few comments.
If we implement those comments, then null should not be a problem here (in other words, the code in this class could remain unchanged).
| long storagePoolId = snapshotStore.getDataStoreId(); | ||
| DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); | ||
| if (snapshotStore.getState() != null && ! snapshotStore.getState().equals(ObjectInDataStoreStateMachine.State.Destroyed)) { |
There was a problem hiding this comment.
As pointed out by @mike-tutkowski store cannot be destroyed if there are snapshots. Also that enum is meant for snapshot (and entities like that) and not for snapshot store.
There was a problem hiding this comment.
For managed storage, that is true. For unmanaged storage, one should be able to delete the primary storage from which a snapshot was created and the snapshot should be able to remain (since the snapshot, in this case, is on secondary storage).
serg38
commented
Jan 10, 2017
@mike-tutkowski@anshul1886 @rhtyd We had enough LGTM and successful test results for this PR. Are there any concern before merging it? |
yadvr
commented
Jan 10, 2017
@serg38 sure |
blueorangutan
commented
Jan 10, 2017
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Jan 10, 2017
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-453 |
mike-tutkowski
commented
Jan 10, 2017
@serg38@anshul1886 @rhtyd Maybe someone could take a look at my comments before we check this in and see if they think any of those should be implemented here. Thanks |
yadvr
commented
Jan 10, 2017
@mike-tutkowski sorry I don't have the bandwidth for a review, though I can facilitate with running tests. Maybe @anshul1886 and/or @serg38 can comment. Thanks. @blueorangutan test |
blueorangutan
commented
Jan 10, 2017
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
serg38
commented
Jan 11, 2017
@mike-tutkowski The only comments in this PR are about deletion of PS with a snapshot copy. I am 100% agree with your statement. This PR excludes destroyed snapshot copies including ones on the PS from evaluation during the listSnaphsot call thus avoiding NPE if original PS is already deleted. |
@serg38 I had some open questions on code which are not yet answered specifically related to use case of null case and comparison of non comparable properties. Also, for unmanaged storage there is nothing called snapshot copy on primary yet once the snapshot is created. This PR is meant to fix that case i.e. unmanaged primary storage case only. So I am not understanding what are you referring to here. I had replied to your comment on dev mail but didn't get any response. |
| } | ||
| long storagePoolId = snapshotStore.getDataStoreId(); | ||
| DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); |
There was a problem hiding this comment.
Another possibility here is that we could simply still try to retrieve "dataStore" and then perform this check:
DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
if (dataStore == null) {
return DataStoreRole.Image;
}
If "dataStore" equals null, then it was removed, which should only be something that happened when unmanaged storage is being used (thus when the the snapshot resides on secondary storage).
| snapshotInfo = (SnapshotInfo)snapshot; | ||
| } else { | ||
| DataStoreRole dataStoreRole = getDataStoreRole(snapshot, _snapshotStoreDao, _dataStoreMgr); | ||
There was a problem hiding this comment.
I would say the default should be DataStoreRole.Image for getDataStoreRole and so getDataStoreRole should probably never return null.
| @Override | ||
| public PrimaryDataStore getPrimaryDataStore(long dataStoreId) { | ||
| StoragePoolVO dataStoreVO = dataStoreDao.findById(dataStoreId); | ||
| StoragePoolVO dataStoreVO = dataStoreDao.findByIdIncludingRemoved(dataStoreId); |
There was a problem hiding this comment.
Is getPrimaryDataStore(long) called from many places? If so, it might be a bit risky to change this from findById to findByIdIncludingRemoved unless we are pretty sure all of the calling code is OK with that change.
| snapshotResponse.setObjectName("snapshot"); | ||
| snapshotResponses.add(snapshotResponse); | ||
| if (snapshotResponse != null) { | ||
| snapshotResponse.setObjectName("snapshot"); |
There was a problem hiding this comment.
I've added a few comments.
If we implement those comments, then null should not be a problem here (in other words, the code in this class could remain unchanged).
blueorangutan
commented
Jan 11, 2017
Trillian test result (tid-774)
|
@mike-tutkowski@anshul1886 thanks for your comments! I'll work on them! @rhtyd this PR was targeted for 4.9, should I retarget it to master branch? |
nvazquez
commented
Feb 17, 2017
Closing this PR as #1847 includes this changes in a simpler way |
Actual behaviour
If there is snapshot on a data store that is removed,
listSnapshotsstill tries to enumerate it and gives error (in this example data store 2 has been removed):client/api?command=listSnapshots&isrecursive=true&listall=trueReproduce error
This steps can be followed to reproduce issue:
client/api?command=listSnapshots&isrecursive=true&listall=true