Daniel Erez has posted comments on this change.

Change subject: core: introduce RemoveDiskSnapshotsCommand
......................................................................


Patch Set 8:

(10 comments)

http://gerrit.ovirt.org/#/c/26327/8/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskSnapshotTaskHandler.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskSnapshotTaskHandler.java:

Line 43:                 VdcActionType.RemoveSnapshotSingleDisk,
Line 44:                 buildRemoveSnapshotSingleDiskParameters(),
Line 45:                 getCommandContext());
Line 46: 
Line 47:         if (vdcReturnValue != null && 
vdcReturnValue.getInternalVdsmTaskIdList() != null) {
> iirc those can't be null
used the same pattern as RemoveDiskSnapshot, but right, seems redundant
Line 48:             enclosingCommand.getReturnValue()
Line 49:                     .getVdsmTaskIdList()
Line 50:                     
.addAll(vdcReturnValue.getInternalVdsmTaskIdList());
Line 51:         }


Line 115:     private void updateImagesStatus(ImageStatus imageStatus) {
Line 116:         Guid imageGroupId = 
DbFacade.getInstance().getDiskImageDao().getSnapshotById(imageId).getId();
Line 117:         List<DiskImage> images = 
DbFacade.getInstance().getDiskImageDao().getAllSnapshotsForImageGroup(imageGroupId);
Line 118:         for (DiskImage image : images) {
Line 119:             ImagesHandler.updateImageStatus(image.getImageId(), 
imageStatus);
> what about compensation here? images might remain/changed to unneeded statu
Done
Line 120:         }
Line 121:     }
Line 122: 
Line 123:     @Override


http://gerrit.ovirt.org/#/c/26327/8/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskSnapshotsCommand.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveDiskSnapshotsCommand.java:

Line 53: 
Line 54:         setImage(representativeImage);
Line 55:         setStorageDomainId(representativeImage.getStorageIds().get(0));
Line 56: 
Line 57:         if (!Guid.isNullOrEmpty(getParameters().getContainerId())) {
> one of checks should be sufficent if we know what's the defined value, so i
isEmpty is probably enough but Guid already has isNullOrEmpty...
Line 58:             setVmId(getParameters().getContainerId());
Line 59:         }
Line 60:         else {
Line 61:             List<VM> listVms = 
getVmDAO().getVmsListForDisk(representativeImage.getId(), false);


Line 92: 
Line 93:     @Override
Line 94:     protected boolean canDoAction() {
Line 95:         DiskImagesValidator diskImagesValidator = 
createDiskImageValidator(getImages());
Line 96:         if (!validate(diskImagesValidator.diskImagesNotExist())) {
> this check can be removed in that case, as you load the images in getImages
Done
Line 97:             return false;
Line 98:         }
Line 99: 
Line 100:         if 
(!validate(diskImagesValidator.diskImagesBelongToSameImageGroup())) {


Line 101:             return false;
Line 102:         }
Line 103: 
Line 104:         if (getVm() == null) {
Line 105:             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_NOT_FOUND);
> this check could be first, to avoid further db loads if we already "know" a
Done
Line 106:         }
Line 107: 
Line 108:         if (!canRunActionOnNonManagedVm()) {
Line 109:             return false;


Line 113:         if (!validate(new 
StoragePoolValidator(getStoragePool()).isUp()) ||
Line 114:                 !validateVmNotDuringSnapshot() ||
Line 115:                 !validateVmNotInPreview() ||
Line 116:                 !validateSnapshotExists() ||
Line 117:                 !validate(vmValidator.vmDown()) ||
> the vm might be running when the disk is unplugged, so the operation could 
Done
Line 118:                 
!validate(vmValidator.vmNotHavingDeviceSnapshotsAttachedToOtherVms(false)) ||
Line 119:                 !validateStorageDomainActive()) {
Line 120:             return false;
Line 121:         }


Line 114:                 !validateVmNotDuringSnapshot() ||
Line 115:                 !validateVmNotInPreview() ||
Line 116:                 !validateSnapshotExists() ||
Line 117:                 !validate(vmValidator.vmDown()) ||
Line 118:                 
!validate(vmValidator.vmNotHavingDeviceSnapshotsAttachedToOtherVms(false)) ||
> you should add a check that any of the removed snapshots isn't attached as 
used diskImagesSnapshotsNotAttachedToOtherVms instead
Line 119:                 !validateStorageDomainActive()) {
Line 120:             return false;
Line 121:         }
Line 122: 


Line 251:     }
Line 252: 
Line 253:     protected boolean validateImagesNotInTemplate() {
Line 254:         for (Guid imageId : getParameters().getImageIds()) {
Line 255:             if (getVmTemplateDAO().get(imageId) != null) {
> can you elaborate on that check? how could the image id's be id's of a temp
similar check in RemoveSnapshotCommand.. but probably redundant there as well 
so I'll remove it.
Line 256:                 return false;
Line 257:             }
Line 258:         }
Line 259:         return true;


Line 260:     }
Line 261: 
Line 262:     protected boolean validateImagesNotActive() {
Line 263:         for (Guid imageId : getParameters().getImageIds()) {
Line 264:             if (getDiskImageDao().get(imageId) != null) {
> diskImageDao get() would always return the diskimage even if it's not activ
the getter should return null for non active images - see similar check in 
RemoveSnapshotCommand
Line 265:                 return false;
Line 266:             }
Line 267:         }
Line 268:         return true;


http://gerrit.ovirt.org/#/c/26327/8/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/StorageDomainValidatorTest.java
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/StorageDomainValidatorTest.java:

Line 116:     @Test
Line 117:     public void 
testDomainWithEnoughSizeToRemoveDiskSnapshotsMaxVirtualSize() {
Line 118:         validator = new 
StorageDomainValidator(mockStorageDomain(1024, 0, StorageType.NFS));
Line 119:         DiskImage image1 = mockDiskImage(1024, 1024);
Line 120:         DiskImage image2 = mockDiskImage(256, 1024);
> I would also add a negetive test here when the domain has virtual size of l
Done
Line 121: 
Line 122:         assertTrue("Domain should have enough space for merging the 
snapshots",
Line 123:             
validator.hasSpaceForRemovingDiskSnapshots(Arrays.asList(image1, 
image2)).isValid());
Line 124:     }


-- 
To view, visit http://gerrit.ovirt.org/26327
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia714a4390d1d9b672005be30f58b7fa98b9a31cd
Gerrit-PatchSet: 8
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Liron Ar <lara...@redhat.com>
Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Tal Nisan <tni...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to