<fix>[local]: skip download image cache from ceph to local
skip download image cache from ceph to local
Resolves/Related:
@@ -186,10 +186,47 @@ public class LocalStorageKvmMigrateVmFlow extends NoRollbackFlow {
@Override
public void setup() {
+ flow(new NoRollbackFlow() {
+ String __name__ = "get-base-image-cache-of-root-volume";
+
+ @Override
+ public void run(final FlowTrigger trigger, Map data) {
+ GetVolumeBaseImagePathCmd cmd = new GetVolumeBaseImagePathCmd();
+ cmd.volumeInstallDir = backend.makeVolumeInstallDir(rootVolume);
+ cmd.imageCacheDir = backend.getCachedImageDir();
+ cmd.volumeUuid = rootVolume.getUuid();
+ callKvmHost(srcHostUuid, ref.getPrimaryStorageUuid(), LocalStorageKvmBackend.GET_BASE_IMAGE_PATH, cmd, GetVolumeBaseImagePathRsp.class, new ReturnValueCompletion<GetVolumeBaseImagePathRsp>(trigger) {
+ @Override
+ public void success(GetVolumeBaseImagePathRsp rsp) {
+ if (rsp.path != null && backend.isCachedImageUrl(rsp.path)) {
+ backingImage.path = rsp.path;
+ backingImage.size = rsp.size;
+ }
+ trigger.next();
+ }
+
+ @Override
+ public void fail(ErrorCode errorCode) {
+ logger.error(String.format("cannot get volume base image %s, skip and continue", errorCode.getDetails()));
+ trigger.next();
+ }
+ });
+ }
+ });
+
if (downloadImage) {
flow(new NoRollbackFlow() {
String __name__ = "download-image-to-cache";
+ @Override
+ public boolean skip(Map data) {
+ if (backingImage.path == null) {
+ logger.debug("no base image cache, skip this flow");
+ return true;
+ }
+ return false;
+ }
+
@Override
public void run(final FlowTrigger trigger, Map data) {
DownloadImageToPrimaryStorageCacheMsg msg = new DownloadImageToPrimaryStorageCacheMsg();
@@ -215,34 +252,6 @@ public class LocalStorageKvmMigrateVmFlow extends NoRollbackFlow {
}
});
} else {
- flow(new NoRollbackFlow() {
- String __name__ = "get-base-image-cache-of-root-volume";
-
- @Override
- public void run(final FlowTrigger trigger, Map data) {
- GetVolumeBaseImagePathCmd cmd = new GetVolumeBaseImagePathCmd();
- cmd.volumeInstallDir = backend.makeVolumeInstallDir(rootVolume);
- cmd.imageCacheDir = backend.getCachedImageDir();
- cmd.volumeUuid = rootVolume.getUuid();
- callKvmHost(srcHostUuid, ref.getPrimaryStorageUuid(), LocalStorageKvmBackend.GET_BASE_IMAGE_PATH, cmd, GetVolumeBaseImagePathRsp.class, new ReturnValueCompletion<GetVolumeBaseImagePathRsp>(trigger) {
- @Override
- public void success(GetVolumeBaseImagePathRsp rsp) {
- if (rsp.path != null && backend.isCachedImageUrl(rsp.path)) {
- backingImage.path = rsp.path;
- backingImage.size = rsp.size;
- }
- trigger.next();
- }
-
- @Override
- public void fail(ErrorCode errorCode) {
- logger.error(String.format("cannot get volume base image %s, skip and continue", errorCode.getDetails()));
- trigger.next();
- }
- });
- }
- });
-
flow(new Flow() {
String __name__ = "reserve-capacity-for-base-image-cache-on-dst-host";
