Skip to content

Commit 9d31e59

Browse files
hiroki-aistkaruturi
authored andcommitted
CLOUDSTACK-7412: Can't create proper template from VM on S3 secondary storage environment
Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>
1 parent 488c178 commit 9d31e59

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,29 @@ protected Answer copyObject(DataObject srcData, DataObject destData, Host destHo
174174
}
175175

176176
if (cacheData != null) {
177-
if (srcData.getType() == DataObjectType.VOLUME && destData.getType() == DataObjectType.VOLUME) {
178-
// volume transfer from primary to secondary or vice versa. Volume transfer between primary pools are already handled by copyVolumeBetweenPools
177+
final Long cacheId = cacheData.getId();
178+
final String cacheType = cacheData.getType().toString();
179+
final String cacheUuid = cacheData.getUuid().toString();
180+
181+
if (srcData.getType() == DataObjectType.VOLUME &&
182+
(destData.getType() == DataObjectType.VOLUME ||
183+
destData.getType() == DataObjectType.TEMPLATE)) {
184+
// volume transfer from primary to secondary. Volume transfer between primary pools are already handled by copyVolumeBetweenPools
185+
// Delete cache in order to certainly transfer a latest image.
186+
s_logger.debug("Delete " + cacheType + " cache(id: " + cacheId +
187+
", uuid: " + cacheUuid + ")");
179188
cacheMgr.deleteCacheObject(srcForCopy);
180189
} else {
181190
// for template, we want to leave it on cache for performance reason
182191
if ((answer == null || !answer.getResult()) && srcForCopy.getRefCount() < 2) {
183192
// cache object created by this copy, not already there
193+
s_logger.warn("Copy may not be handled correctly by agent(id: " + ep.getId() + ")." +
194+
" Delete " + cacheType + " cache(id: " + cacheId +
195+
", uuid: " + cacheUuid + ")");
184196
cacheMgr.deleteCacheObject(srcForCopy);
185197
} else {
198+
s_logger.debug("Decrease reference count of " + cacheType +
199+
" cache(id: " + cacheId + ", uuid: " + cacheUuid + ")");
186200
cacheMgr.releaseCacheObject(srcForCopy);
187201
}
188202
}

0 commit comments

Comments
 (0)