Liron Ar has posted comments on this change.

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


Patch Set 8:

(9 comments)

partially reviewed

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
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 status 
(for example - remain locked in case of failure/crash)

you can use 
ImagesHandler.updateAllDiskImagesSnapshotsStatusInTransactionWithCompensation 
that'll handle it and would reduce the number of update calls to the db.
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 imo 
it's preferred.
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() 
we already know that they exist.
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" about 
that.
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 be 
performed.
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 a 
disk snapshot to other vm.
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 template?
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 active.
Line 265:                 return false;
Line 266:             }
Line 267:         }
Line 268:         return true;


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