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