Skip to content

CLOUDSTACK-9570: Bug in listSnapshots for snapshots with deleted data stores - #1735

Closed
nvazquez wants to merge 1 commit into
apache:4.9from
nvazquez:list-snapshots-issue
Closed

CLOUDSTACK-9570: Bug in listSnapshots for snapshots with deleted data stores#1735
nvazquez wants to merge 1 commit into
apache:4.9from
nvazquez:list-snapshots-issue

Conversation

@nvazquez

Copy link
Copy Markdown
Contributor

Actual behaviour

If there is snapshot on a data store that is removed, listSnapshots still tries to enumerate it and gives error (in this example data store 2 has been removed):
client/api?command=listSnapshots&isrecursive=true&listall=true

<listsnapshotsresponsecloud-stack-version="4.9.1.0-SNAPSHOT">
<errorcode>530</errorcode>
<cserrorcode>4250</cserrorcode>
<errortext>Unable to locate datastore with id 2</errortext>
</listsnapshotsresponse>

Reproduce error

This steps can be followed to reproduce issue:

  • Take a snapshot of a volume (this creates a references for primary storage and secondary storage in snapshot_store_ref table
  • Simulate retiring primary data storage where snapshot is cached (in this example X is a fake data store and Y is snapshot id):
UPDATE `cloud`.`snapshot_store_ref` SET `store_id`='X', `state`="Destroyed" WHERE `id`='Y';
  • List snapshots: client/api?command=listSnapshots&isrecursive=true&listall=true

@yadvr

yadvr commented Nov 1, 2016

Copy link
Copy Markdown
Member

LGTM. I'll fire some regression tests.
@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-131

@yadvr

yadvr commented Nov 1, 2016

Copy link
Copy Markdown
Member

@blueorangutan test

@abhinandanprateek

Copy link
Copy Markdown
Contributor

LGTM on code review.

@nvazquez
nvazquezforce-pushed the list-snapshots-issue branch from dd7d85a to b63805cCompareNovember 4, 2016 13:12
@serg38

Copy link
Copy Markdown

@rhtyd @jburwell The tests didn't kick in last time. Can we fire matrix again?

@ustcweizhou

Copy link
Copy Markdown
Contributor

if the data store is deleted, the snapshot should be removed as well, right?

@yadvr

yadvr commented Nov 8, 2016

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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)){

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvazquez this can cause NPE, instead use ObjectInDataStoreStateMachine.State.Destroyed.equals(...) or an explicit != null.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks @rhtyd

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-149

@serg38

Copy link
Copy Markdown

@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.

@nvazquez
nvazquezforce-pushed the list-snapshots-issue branch from b63805c to 18d2a05CompareNovember 8, 2016 14:42
@jburwell

Copy link
Copy Markdown
Contributor

@nvazquez could you please add a Marvin test to verify this fix?

@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-184

@nvazquez
nvazquezforce-pushed the list-snapshots-issue branch 2 times, most recently from 42be7f6 to 32c3e89CompareNovember 21, 2016 20:40
@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@jburwell I added new Marvin test in test_snapshots.py

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan package

@yadvr

Copy link
Copy Markdown
Member

LGTM.

@jburwell

Copy link
Copy Markdown
Contributor

@nvazquez could you please check into the Travis failures?

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-245

@yadvr

Copy link
Copy Markdown
Member

@jburwell the Travis failure is ignorable caused by a oobm corner case (exception is ignorable). I'll work on a fix soon.
@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@jburwell @rhtyd sorry I've been off yesterday, do I push force to kick tests again?

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-426)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36018 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr1735-t426-kvm-centos7.zip
Test completed. 34 look ok, 14 have error(s)

TestResultTime (s)Test File
test_02_VPC_default_routesFailure797.53test_vpc_router_nics.py
test_01_VPC_nics_after_destroyFailure837.70test_vpc_router_nics.py
test_05_rvpc_multi_tiersFailure364.54test_vpc_redundant.py
test_04_rvpc_network_garbage_collector_nicsFailure302.68test_vpc_redundant.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routersFailure308.34test_vpc_redundant.py
test_02_redundant_VPC_default_routesFailure860.08test_vpc_redundant.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACLFailure364.81test_vpc_redundant.py
test_02_attach_volumeFailure668.53test_volumes.py
test_01_create_volumeFailure684.11test_volumes.py
test_10_attachAndDetach_isoFailure683.95test_vm_life_cycle.py
test_04_change_offering_smallFailure794.82test_service_offerings.py
test_router_dns_guestipqueryFailure277.49test_router_dns.py
test_router_dhcphostsFailure188.63test_router_dhcphosts.py
test_router_dhcp_optsFailure21.43test_router_dhcphosts.py
test_04_rvpc_privategw_static_routesFailure1026.10test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanupFailure879.57test_privategw_acl.py
test_02_vpc_privategw_static_routesFailure975.48test_privategw_acl.py
test_isolate_network_password_serverFailure188.89test_password_server.py
test_reboot_routerFailure439.34test_network.py
test_network_rules_acquired_public_ip_3_Load_Balancer_RuleFailure831.86test_network.py
test_network_rules_acquired_public_ip_2_nat_ruleFailure679.68test_network.py
test_network_rules_acquired_public_ip_1_static_nat_ruleFailure675.78test_network.py
test_02_port_fwd_on_non_src_natFailure678.99test_network.py
test_01_port_fwd_on_src_natFailure673.86test_network.py
test_assign_and_removal_lbFailure110.42test_loadbalance.py
test_02_create_lb_rule_non_natFailure110.46test_loadbalance.py
test_01_create_lb_rule_src_natFailure110.59test_loadbalance.py
test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80Failure301.21test_internal_lb.py
test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80Failure230.32test_internal_lb.py
test_01_vpc_site2site_vpnError300.79test_vpc_vpn.py
test_01_redundant_vpc_site2site_vpnError386.60test_vpc_vpn.py
test_05_rvpc_multi_tiersError425.47test_vpc_redundant.py
test_02_list_snapshots_with_removed_data_storeError6.27test_snapshots.py
ContextSuite context=TestRouterDHCPHosts>:teardownError239.35test_router_dhcphosts.py
test_04_rvpc_internallb_haproxy_stats_on_all_interfacesError316.07test_internal_lb.py
test_03_vpc_internallb_haproxy_stats_on_all_interfacesError230.54test_internal_lb.py
test_01_vpc_remote_access_vpnSuccess76.23test_vpc_vpn.py
test_09_delete_detached_volumeSuccess15.48test_volumes.py
test_08_resize_volumeSuccess15.39test_volumes.py
test_07_resize_failSuccess20.49test_volumes.py
test_06_download_detached_volumeSuccess15.29test_volumes.py
test_05_detach_volumeSuccess100.26test_volumes.py
test_04_delete_attached_volumeSuccess10.21test_volumes.py
test_03_download_attached_volumeSuccess15.29test_volumes.py
test_deploy_vm_multipleSuccess324.11test_vm_life_cycle.py
test_deploy_vmSuccess0.03test_vm_life_cycle.py
test_advZoneVirtualRouterSuccess0.02test_vm_life_cycle.py
test_09_expunge_vmSuccess185.30test_vm_life_cycle.py
test_08_migrate_vmSuccess41.06test_vm_life_cycle.py
test_07_restore_vmSuccess0.15test_vm_life_cycle.py
test_06_destroy_vmSuccess125.85test_vm_life_cycle.py
test_03_reboot_vmSuccess125.90test_vm_life_cycle.py
test_02_start_vmSuccess5.15test_vm_life_cycle.py
test_01_stop_vmSuccess125.89test_vm_life_cycle.py
test_CreateTemplateWithDuplicateNameSuccess65.66test_templates.py
test_08_list_system_templatesSuccess0.03test_templates.py
test_07_list_public_templatesSuccess0.05test_templates.py
test_05_template_permissionsSuccess0.06test_templates.py
test_04_extract_templateSuccess5.16test_templates.py
test_03_delete_templateSuccess5.12test_templates.py
test_02_edit_templateSuccess90.12test_templates.py
test_01_create_templateSuccess80.70test_templates.py
test_10_destroy_cpvmSuccess161.62test_ssvm.py
test_09_destroy_ssvmSuccess163.71test_ssvm.py
test_08_reboot_cpvmSuccess161.68test_ssvm.py
test_07_reboot_ssvmSuccess133.68test_ssvm.py
test_06_stop_cpvmSuccess221.90test_ssvm.py
test_05_stop_ssvmSuccess133.82test_ssvm.py
test_04_cpvm_internalsSuccess1.24test_ssvm.py
test_03_ssvm_internalsSuccess3.27test_ssvm.py
test_02_list_cpvm_vmSuccess0.14test_ssvm.py
test_01_list_sec_storage_vmSuccess0.16test_ssvm.py
test_01_snapshot_root_diskSuccess11.55test_snapshots.py
test_03_delete_service_offeringSuccess0.05test_service_offerings.py
test_02_edit_service_offeringSuccess0.07test_service_offerings.py
test_01_create_service_offeringSuccess0.11test_service_offerings.py
test_02_sys_template_readySuccess0.17test_secondary_storage.py
test_01_sys_vm_startSuccess0.24test_secondary_storage.py
test_09_reboot_routerSuccess35.34test_routers.py
test_08_start_routerSuccess25.29test_routers.py
test_07_stop_routerSuccess10.18test_routers.py
test_06_router_advancedSuccess0.07test_routers.py
test_05_router_basicSuccess0.05test_routers.py
test_04_restart_network_wo_cleanupSuccess5.70test_routers.py
test_03_restart_network_cleanupSuccess80.99test_routers.py
test_02_router_internal_advSuccess1.13test_routers.py
test_01_router_internal_basicSuccess0.67test_routers.py
test_router_dns_externalipquerySuccess0.09test_router_dns.py
test_01_updatevolumedetailSuccess5.12test_resource_detail.py
test_01_reset_vm_on_rebootSuccess131.06test_reset_vm_on_reboot.py
test_createRegionSuccess0.04test_regions.py
test_create_pvlan_networkSuccess5.26test_pvlan.py
test_dedicatePublicIpRangeSuccess0.47test_public_ip_range.py
test_01_vpc_privategw_aclSuccess108.90test_privategw_acl.py
test_01_primary_storage_nfsSuccess35.85test_primary_storage.py
test_createPortablePublicIPRangeSuccess15.23test_portable_publicip.py
test_createPortablePublicIPAcquireSuccess15.58test_portable_publicip.py
test_UpdateStorageOverProvisioningFactorSuccess0.22test_over_provisioning.py
test_oobm_zchange_passwordSuccess20.52test_outofbandmanagement.py
test_oobm_multiple_mgmt_server_ownershipSuccess16.52test_outofbandmanagement.py
test_oobm_issue_power_statusSuccess10.51test_outofbandmanagement.py
test_oobm_issue_power_softSuccess15.52test_outofbandmanagement.py
test_oobm_issue_power_resetSuccess15.52test_outofbandmanagement.py
test_oobm_issue_power_onSuccess15.52test_outofbandmanagement.py
test_oobm_issue_power_offSuccess16.02test_outofbandmanagement.py
test_oobm_issue_power_cycleSuccess15.52test_outofbandmanagement.py
test_oobm_enabledisable_across_clusterzonesSuccess62.56test_outofbandmanagement.py
test_oobm_enable_feature_validSuccess5.22test_outofbandmanagement.py
test_oobm_enable_feature_invalidSuccess0.15test_outofbandmanagement.py
test_oobm_disable_feature_validSuccess5.24test_outofbandmanagement.py
test_oobm_disable_feature_invalidSuccess0.14test_outofbandmanagement.py
test_oobm_configure_invalid_driverSuccess0.11test_outofbandmanagement.py
test_oobm_configure_default_driverSuccess0.10test_outofbandmanagement.py
test_oobm_background_powerstate_syncSuccess29.85test_outofbandmanagement.py
test_extendPhysicalNetworkVlanSuccess15.37test_non_contigiousvlan.py
test_01_nicSuccess592.15test_nic.py
test_releaseIPSuccess264.47test_network.py
test_public_ip_user_accountSuccess10.27test_network.py
test_public_ip_admin_accountSuccess40.34test_network.py
test_delete_accountSuccess274.01test_network.py
test_nic_secondaryip_add_removeSuccess330.07test_multipleips_per_nic.py
login_test_saml_userSuccess25.58test_login.py
test_03_list_snapshotsSuccess0.09test_list_ids_parameter.py
test_02_list_templatesSuccess0.04test_list_ids_parameter.py
test_01_list_volumesSuccess0.04test_list_ids_parameter.py
test_07_list_default_isoSuccess0.08test_iso.py
test_05_iso_permissionsSuccess0.08test_iso.py
test_04_extract_IsoSuccess5.40test_iso.py
test_03_delete_isoSuccess95.23test_iso.py
test_02_edit_isoSuccess0.08test_iso.py
test_01_create_isoSuccess22.08test_iso.py
test_dedicateGuestVlanRangeSuccess10.45test_guest_vlan_range.py
test_UpdateConfigParamWithScopeSuccess0.19test_global_settings.py
test_rolepermission_lifecycle_updateSuccess7.11test_dynamicroles.py
test_rolepermission_lifecycle_listSuccess6.90test_dynamicroles.py
test_rolepermission_lifecycle_deleteSuccess6.81test_dynamicroles.py
test_rolepermission_lifecycle_createSuccess7.16test_dynamicroles.py
test_rolepermission_lifecycle_concurrent_updatesSuccess7.08test_dynamicroles.py
test_role_lifecycle_update_role_inuseSuccess6.95test_dynamicroles.py
test_role_lifecycle_updateSuccess11.93test_dynamicroles.py
test_role_lifecycle_listSuccess6.93test_dynamicroles.py
test_role_lifecycle_deleteSuccess11.82test_dynamicroles.py
test_role_lifecycle_createSuccess6.96test_dynamicroles.py
test_role_inuse_deletionSuccess7.00test_dynamicroles.py
test_role_account_acls_multiple_mgmt_serversSuccess9.19test_dynamicroles.py
test_role_account_aclsSuccess9.85test_dynamicroles.py
test_default_role_deletionSuccess6.99test_dynamicroles.py
test_04_create_fat_type_disk_offeringSuccess0.09test_disk_offerings.py
test_03_delete_disk_offeringSuccess0.04test_disk_offerings.py
test_02_edit_disk_offeringSuccess0.06test_disk_offerings.py
test_02_create_sparse_type_disk_offeringSuccess0.09test_disk_offerings.py
test_01_create_disk_offeringSuccess0.12test_disk_offerings.py
test_deployvm_userdispersingSuccess15.76test_deploy_vms_with_varied_deploymentplanners.py
test_deployvm_userconcentratedSuccess51.09test_deploy_vms_with_varied_deploymentplanners.py
test_deployvm_firstfitSuccess60.79test_deploy_vms_with_varied_deploymentplanners.py
test_deployvm_userdata_postSuccess5.38test_deploy_vm_with_userdata.py
test_deployvm_userdataSuccess121.62test_deploy_vm_with_userdata.py
test_02_deploy_vm_root_resizeSuccess7.02test_deploy_vm_root_resize.py
test_01_deploy_vm_root_resizeSuccess7.09test_deploy_vm_root_resize.py
test_00_deploy_vm_root_resizeSuccess243.91test_deploy_vm_root_resize.py
test_deploy_vm_from_isoSuccess224.12test_deploy_vm_iso.py
test_DeployVmAntiAffinityGroupSuccess237.38test_affinity_groups.py
test_03_delete_vm_snapshotsSkipped0.00test_vm_snapshots.py
test_02_revert_vm_snapshotsSkipped0.00test_vm_snapshots.py
test_01_test_vm_volume_snapshotSkipped0.00test_vm_snapshots.py
test_01_create_vm_snapshotsSkipped0.00test_vm_snapshots.py
test_06_copy_templateSkipped0.00test_templates.py
test_static_role_account_aclsSkipped0.03test_staticroles.py
test_01_scale_vmSkipped0.00test_scale_vm.py
test_01_primary_storage_iscsiSkipped0.04test_primary_storage.py
test_06_copy_isoSkipped0.00test_iso.py
test_deploy_vgpu_enabled_vmSkipped0.01test_deploy_vgpu_enabled_vm.py

@nvazquez
nvazquezforce-pushed the list-snapshots-issue branch from 32c3e89 to 8369007CompareDecember 6, 2016 19:58
_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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvazquez What is changed here?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anshul1886, at the beggining of each line there's one space added, to be consistent with indentation

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is any issue observed here for which null check is added?

@nvazqueznvazquezJan 3, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case for null case when that can happen?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

@mike-tutkowski@anshul1886 @rhtyd We had enough LGTM and successful test results for this PR. Are there any concern before merging it?

@yadvr

Copy link
Copy Markdown
Member

@serg38 sure
@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-453

@mike-tutkowski

Copy link
Copy Markdown
Member

@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

Copy link
Copy Markdown
Member

@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

Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@serg38

Copy link
Copy Markdown

@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.
Did you have other suggestions for this PR?

@anshul1886

anshul1886 commented Jan 11, 2017

Copy link
Copy Markdown

@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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Trillian test result (tid-774)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42807 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr1735-t774-kvm-centos7.zip
Intermitten failure detected: /marvin/tests/smoke/test_privategw_acl.py
Intermitten failure detected: /marvin/tests/smoke/test_routers_network_ops.py
Intermitten failure detected: /marvin/tests/smoke/test_snapshots.py
Intermitten failure detected: /marvin/tests/smoke/test_volumes.py
Intermitten failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Test completed. 45 look ok, 3 have error(s)

TestResultTime (s)Test File
test_04_rvpc_privategw_static_routesFailure345.63test_privategw_acl.py
test_01_create_volumeError249.60test_volumes.py
test_02_list_snapshots_with_removed_data_storeError0.04test_snapshots.py
test_01_vpc_site2site_vpnSuccess165.13test_vpc_vpn.py
test_01_vpc_remote_access_vpnSuccess71.17test_vpc_vpn.py
test_01_redundant_vpc_site2site_vpnSuccess301.46test_vpc_vpn.py
test_02_VPC_default_routesSuccess445.31test_vpc_router_nics.py
test_01_VPC_nics_after_destroySuccess831.58test_vpc_router_nics.py
test_05_rvpc_multi_tiersSuccess516.55test_vpc_redundant.py
test_04_rvpc_network_garbage_collector_nicsSuccess1406.00test_vpc_redundant.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routersSuccess548.52test_vpc_redundant.py
test_02_redundant_VPC_default_routesSuccess769.66test_vpc_redundant.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACLSuccess1284.91test_vpc_redundant.py
test_09_delete_detached_volumeSuccess156.68test_volumes.py
test_08_resize_volumeSuccess156.39test_volumes.py
test_07_resize_failSuccess161.38test_volumes.py
test_06_download_detached_volumeSuccess156.25test_volumes.py
test_05_detach_volumeSuccess236.36test_volumes.py
test_04_delete_attached_volumeSuccess151.22test_volumes.py
test_03_download_attached_volumeSuccess156.32test_volumes.py
test_02_attach_volumeSuccess214.74test_volumes.py
test_deploy_vm_multipleSuccess388.71test_vm_life_cycle.py
test_deploy_vmSuccess0.03test_vm_life_cycle.py
test_advZoneVirtualRouterSuccess0.02test_vm_life_cycle.py
test_10_attachAndDetach_isoSuccess46.70test_vm_life_cycle.py
test_09_expunge_vmSuccess125.23test_vm_life_cycle.py
test_08_migrate_vmSuccess66.21test_vm_life_cycle.py
test_07_restore_vmSuccess0.12test_vm_life_cycle.py
test_06_destroy_vmSuccess130.85test_vm_life_cycle.py
test_03_reboot_vmSuccess125.84test_vm_life_cycle.py
test_02_start_vmSuccess10.17test_vm_life_cycle.py
test_01_stop_vmSuccess125.82test_vm_life_cycle.py
test_CreateTemplateWithDuplicateNameSuccess65.57test_templates.py
test_08_list_system_templatesSuccess0.03test_templates.py
test_07_list_public_templatesSuccess0.04test_templates.py
test_05_template_permissionsSuccess0.06test_templates.py
test_04_extract_templateSuccess5.17test_templates.py
test_03_delete_templateSuccess5.11test_templates.py
test_02_edit_templateSuccess90.18test_templates.py
test_01_create_templateSuccess65.56test_templates.py
test_10_destroy_cpvmSuccess166.69test_ssvm.py
test_09_destroy_ssvmSuccess164.22test_ssvm.py
test_08_reboot_cpvmSuccess101.57test_ssvm.py
test_07_reboot_ssvmSuccess133.39test_ssvm.py
test_06_stop_cpvmSuccess136.78test_ssvm.py
test_05_stop_ssvmSuccess163.33test_ssvm.py
test_04_cpvm_internalsSuccess1.25test_ssvm.py
test_03_ssvm_internalsSuccess2.83test_ssvm.py
test_02_list_cpvm_vmSuccess0.12test_ssvm.py
test_01_list_sec_storage_vmSuccess0.13test_ssvm.py
test_01_snapshot_root_diskSuccess11.08test_snapshots.py
test_04_change_offering_smallSuccess204.53test_service_offerings.py
test_03_delete_service_offeringSuccess0.04test_service_offerings.py
test_02_edit_service_offeringSuccess0.06test_service_offerings.py
test_01_create_service_offeringSuccess0.11test_service_offerings.py
test_02_sys_template_readySuccess0.13test_secondary_storage.py
test_01_sys_vm_startSuccess0.18test_secondary_storage.py
test_09_reboot_routerSuccess40.36test_routers.py
test_08_start_routerSuccess35.31test_routers.py
test_07_stop_routerSuccess10.16test_routers.py
test_06_router_advancedSuccess0.06test_routers.py
test_05_router_basicSuccess0.04test_routers.py
test_04_restart_network_wo_cleanupSuccess5.71test_routers.py
test_03_restart_network_cleanupSuccess70.61test_routers.py
test_02_router_internal_advSuccess0.85test_routers.py
test_01_router_internal_basicSuccess0.46test_routers.py
test_router_dns_guestipquerySuccess76.78test_router_dns.py
test_router_dns_externalipquerySuccess0.08test_router_dns.py
test_router_dhcphostsSuccess362.54test_router_dhcphosts.py
test_router_dhcp_optsSuccess21.58test_router_dhcphosts.py
test_01_updatevolumedetailSuccess0.08test_resource_detail.py
test_01_reset_vm_on_rebootSuccess181.27test_reset_vm_on_reboot.py
test_createRegionSuccess0.07test_regions.py
test_create_pvlan_networkSuccess5.28test_pvlan.py
test_dedicatePublicIpRangeSuccess0.45test_public_ip_range.py
test_03_vpc_privategw_restart_vpc_cleanupSuccess641.01test_privategw_acl.py
test_02_vpc_privategw_static_routesSuccess591.72test_privategw_acl.py
test_01_vpc_privategw_aclSuccess92.18test_privategw_acl.py
test_01_primary_storage_nfsSuccess35.79test_primary_storage.py
test_createPortablePublicIPRangeSuccess15.19test_portable_publicip.py
test_createPortablePublicIPAcquireSuccess15.49test_portable_publicip.py
test_isolate_network_password_serverSuccess57.38test_password_server.py
test_UpdateStorageOverProvisioningFactorSuccess0.14test_over_provisioning.py
test_oobm_zchange_passwordSuccess30.64test_outofbandmanagement.py
test_oobm_multiple_mgmt_server_ownershipSuccess16.37test_outofbandmanagement.py
test_oobm_issue_power_statusSuccess10.25test_outofbandmanagement.py
test_oobm_issue_power_softSuccess15.31test_outofbandmanagement.py
test_oobm_issue_power_resetSuccess15.34test_outofbandmanagement.py
test_oobm_issue_power_onSuccess15.33test_outofbandmanagement.py
test_oobm_issue_power_offSuccess15.32test_outofbandmanagement.py
test_oobm_issue_power_cycleSuccess15.32test_outofbandmanagement.py
test_oobm_enabledisable_across_clusterzonesSuccess87.63test_outofbandmanagement.py
test_oobm_enable_feature_validSuccess5.16test_outofbandmanagement.py
test_oobm_enable_feature_invalidSuccess0.09test_outofbandmanagement.py
test_oobm_disable_feature_validSuccess0.15test_outofbandmanagement.py
test_oobm_disable_feature_invalidSuccess0.10test_outofbandmanagement.py
test_oobm_configure_invalid_driverSuccess0.09test_outofbandmanagement.py
test_oobm_configure_default_driverSuccess0.07test_outofbandmanagement.py
test_oobm_background_powerstate_syncSuccess23.41test_outofbandmanagement.py
test_extendPhysicalNetworkVlanSuccess15.32test_non_contigiousvlan.py
test_01_nicSuccess534.90test_nic.py
test_releaseIPSuccess237.83test_network.py
test_reboot_routerSuccess504.00test_network.py
test_public_ip_user_accountSuccess10.25test_network.py
test_public_ip_admin_accountSuccess40.30test_network.py
test_network_rules_acquired_public_ip_3_Load_Balancer_RuleSuccess66.72test_network.py
test_network_rules_acquired_public_ip_2_nat_ruleSuccess61.49test_network.py
test_network_rules_acquired_public_ip_1_static_nat_ruleSuccess123.59test_network.py
test_delete_accountSuccess293.29test_network.py
test_02_port_fwd_on_non_src_natSuccess55.65test_network.py
test_01_port_fwd_on_src_natSuccess111.72test_network.py
test_nic_secondaryip_add_removeSuccess247.88test_multipleips_per_nic.py
login_test_saml_userSuccess19.25test_login.py
test_assign_and_removal_lbSuccess133.48test_loadbalance.py
test_02_create_lb_rule_non_natSuccess187.30test_loadbalance.py
test_01_create_lb_rule_src_natSuccess208.34test_loadbalance.py
test_03_list_snapshotsSuccess0.08test_list_ids_parameter.py
test_02_list_templatesSuccess0.04test_list_ids_parameter.py
test_01_list_volumesSuccess0.03test_list_ids_parameter.py
test_07_list_default_isoSuccess0.06test_iso.py
test_05_iso_permissionsSuccess0.07test_iso.py
test_04_extract_IsoSuccess5.26test_iso.py
test_03_delete_isoSuccess95.21test_iso.py
test_02_edit_isoSuccess0.06test_iso.py
test_01_create_isoSuccess21.01test_iso.py
test_04_rvpc_internallb_haproxy_stats_on_all_interfacesSuccess177.89test_internal_lb.py
test_03_vpc_internallb_haproxy_stats_on_all_interfacesSuccess127.47test_internal_lb.py
test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80Success576.92test_internal_lb.py
test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80Success446.36test_internal_lb.py
test_dedicateGuestVlanRangeSuccess10.27test_guest_vlan_range.py
test_UpdateConfigParamWithScopeSuccess0.15test_global_settings.py
test_rolepermission_lifecycle_updateSuccess6.15test_dynamicroles.py
test_rolepermission_lifecycle_listSuccess5.99test_dynamicroles.py
test_rolepermission_lifecycle_deleteSuccess5.98test_dynamicroles.py
test_rolepermission_lifecycle_createSuccess5.90test_dynamicroles.py
test_rolepermission_lifecycle_concurrent_updatesSuccess6.00test_dynamicroles.py
test_role_lifecycle_update_role_inuseSuccess5.91test_dynamicroles.py
test_role_lifecycle_updateSuccess10.98test_dynamicroles.py
test_role_lifecycle_listSuccess5.89test_dynamicroles.py
test_role_lifecycle_deleteSuccess10.94test_dynamicroles.py
test_role_lifecycle_createSuccess5.90test_dynamicroles.py
test_role_inuse_deletionSuccess6.01test_dynamicroles.py
test_role_account_acls_multiple_mgmt_serversSuccess8.10test_dynamicroles.py
test_role_account_aclsSuccess8.35test_dynamicroles.py
test_default_role_deletionSuccess6.01test_dynamicroles.py
test_04_create_fat_type_disk_offeringSuccess0.07test_disk_offerings.py
test_03_delete_disk_offeringSuccess0.04test_disk_offerings.py
test_02_edit_disk_offeringSuccess0.05test_disk_offerings.py
test_02_create_sparse_type_disk_offeringSuccess0.07test_disk_offerings.py
test_01_create_disk_offeringSuccess0.11test_disk_offerings.py
test_deployvm_userdispersingSuccess21.06test_deploy_vms_with_varied_deploymentplanners.py
test_deployvm_userconcentratedSuccess50.79test_deploy_vms_with_varied_deploymentplanners.py
test_deployvm_firstfitSuccess45.63test_deploy_vms_with_varied_deploymentplanners.py
test_deployvm_userdata_postSuccess10.44test_deploy_vm_with_userdata.py
test_deployvm_userdataSuccess101.05test_deploy_vm_with_userdata.py
test_02_deploy_vm_root_resizeSuccess6.02test_deploy_vm_root_resize.py
test_01_deploy_vm_root_resizeSuccess6.00test_deploy_vm_root_resize.py
test_00_deploy_vm_root_resizeSuccess257.85test_deploy_vm_root_resize.py
test_deploy_vm_from_isoSuccess197.44test_deploy_vm_iso.py
test_DeployVmAntiAffinityGroupSuccess111.25test_affinity_groups.py
test_03_delete_vm_snapshotsSkipped0.00test_vm_snapshots.py
test_02_revert_vm_snapshotsSkipped0.00test_vm_snapshots.py
test_01_test_vm_volume_snapshotSkipped0.00test_vm_snapshots.py
test_01_create_vm_snapshotsSkipped0.00test_vm_snapshots.py
test_06_copy_templateSkipped0.00test_templates.py
test_static_role_account_aclsSkipped0.02test_staticroles.py
test_01_scale_vmSkipped0.00test_scale_vm.py
test_01_primary_storage_iscsiSkipped0.04test_primary_storage.py
test_06_copy_isoSkipped0.00test_iso.py
test_deploy_vgpu_enabled_vmSkipped0.06test_deploy_vgpu_enabled_vm.py

@nvazquez

nvazquez commented Jan 11, 2017

Copy link
Copy Markdown
ContributorAuthor

@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

Copy link
Copy Markdown
ContributorAuthor

Closing this PR as #1847 includes this changes in a simpler way

@nvazquez
nvazquez deleted the list-snapshots-issue branch April 6, 2020 14:54
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@nvazquez@yadvr@blueorangutan@abhinandanprateek@serg38@ustcweizhou@jburwell@mike-tutkowski@anshul1886