Skip to content

Commit 17f4a63

Browse files
committed
CLOUDSTACK-4204:[Object_store_refactor] Snapshot created from volume in
zone2 is copying to secondary staging storages in zone1
1 parent 17715d7 commit 17f4a63

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ private Scope getZoneScope(Scope destScope) {
176176
return zoneScope;
177177
}
178178

179+
private Scope pickCacheScopeForCopy(DataObject srcData, DataObject destData) {
180+
Scope srcScope = srcData.getDataStore().getScope();
181+
Scope destScope = destData.getDataStore().getScope();
182+
183+
Scope selectedScope = null;
184+
if (srcScope.getScopeId() != null) {
185+
selectedScope = srcScope;
186+
} else if (destScope.getScopeId() != null) {
187+
selectedScope = destScope;
188+
} else {
189+
s_logger.warn("Cannot find a zone-wide scope for move between cache store and image store");
190+
}
191+
return selectedScope;
192+
}
193+
179194
protected Answer copyObject(DataObject srcData, DataObject destData) {
180195
String value = configDao.getValue(Config.PrimaryStorageDownloadWait.toString());
181196
int _primaryStorageDownloadWait = NumbersUtil.parseInt(value,
@@ -185,7 +200,7 @@ protected Answer copyObject(DataObject srcData, DataObject destData) {
185200
DataObject srcForCopy = srcData;
186201
try {
187202
if (needCacheStorage(srcData, destData)) {
188-
Scope destScope = getZoneScope(destData.getDataStore().getScope());
203+
Scope destScope = pickCacheScopeForCopy(srcData, destData);
189204
srcForCopy = cacheData = cacheMgr.createCacheObject(srcData, destScope);
190205
}
191206

@@ -435,7 +450,8 @@ protected Answer copySnapshot(DataObject srcData, DataObject destData) {
435450
Answer answer = null;
436451
try {
437452
if (needCacheStorage(srcData, destData)) {
438-
cacheData = cacheMgr.getCacheObject(srcData, destData.getDataStore().getScope());
453+
Scope selectedScope = pickCacheScopeForCopy(srcData, destData);
454+
cacheData = cacheMgr.getCacheObject(srcData, selectedScope);
439455

440456
CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, _mgmtServer.getExecuteInSequence());
441457
cmd.setCacheTO(cacheData.getTO());

0 commit comments

Comments
 (0)