You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/04/30 11:01:37 UTC

git commit: updated refs/heads/master to 2133c30

Repository: cloudstack
Updated Branches:
  refs/heads/master 4b2ce34bc -> 2133c302f


CLOUDSTACK-8413: Fixed resource tags on disk are lost when migrate to another storage

During cold volume migration we are duplicating volume entry in volumes table.
When migration is complete, we update the uuid of new entry and expunge the older entry.
This results in removal of resource tags on volume as its resource id still pointing to older volume.
As part of fix while updating uuid for volume, we are updating resource_id for tags also.

This closes #194


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2133c302
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2133c302
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2133c302

Branch: refs/heads/master
Commit: 2133c302f4bf1f4224648bef4689a8a9f725ccd6
Parents: 4b2ce34
Author: Anshul Gangwar <an...@citrix.com>
Authored: Thu Feb 19 16:22:20 2015 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Thu Apr 30 14:34:20 2015 +0530

----------------------------------------------------------------------
 api/src/com/cloud/server/ResourceTag.java                 |  2 ++
 .../schema/src/com/cloud/storage/dao/VolumeDaoImpl.java   |  1 +
 engine/schema/src/com/cloud/tags/ResourceTagVO.java       |  4 ++++
 engine/schema/src/com/cloud/tags/dao/ResourceTagDao.java  |  1 +
 .../src/com/cloud/tags/dao/ResourceTagsDaoImpl.java       | 10 ++++++++++
 5 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2133c302/api/src/com/cloud/server/ResourceTag.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java
index 16d6dc2..ce09fdf 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -92,6 +92,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
      */
     long getResourceId();
 
+    void setResourceId(long resourceId);
+
     /**
      * @return
      */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2133c302/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index 66e8979..85d08b8 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -626,6 +626,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
             destVol.setInstanceId(instanceId);
             update(srcVolId, srcVol);
             update(destVolId, destVol);
+            _tagsDao.updateResourceId(srcVolId, destVolId, ResourceObjectType.Volume);
         } catch (Exception e) {
             throw new CloudRuntimeException("Unable to persist the sequence number for this host");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2133c302/engine/schema/src/com/cloud/tags/ResourceTagVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/tags/ResourceTagVO.java b/engine/schema/src/com/cloud/tags/ResourceTagVO.java
index eadddd1..cc29d8e 100644
--- a/engine/schema/src/com/cloud/tags/ResourceTagVO.java
+++ b/engine/schema/src/com/cloud/tags/ResourceTagVO.java
@@ -143,6 +143,10 @@ public class ResourceTagVO implements ResourceTag {
         return resourceId;
     }
 
+    @Override public void setResourceId(long resourceId) {
+        this.resourceId = resourceId;
+    }
+
     @Override
     public ResourceObjectType getResourceType() {
         return resourceType;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2133c302/engine/schema/src/com/cloud/tags/dao/ResourceTagDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/tags/dao/ResourceTagDao.java b/engine/schema/src/com/cloud/tags/dao/ResourceTagDao.java
index fffe2a47..87662ef 100644
--- a/engine/schema/src/com/cloud/tags/dao/ResourceTagDao.java
+++ b/engine/schema/src/com/cloud/tags/dao/ResourceTagDao.java
@@ -34,4 +34,5 @@ public interface ResourceTagDao extends GenericDao<ResourceTagVO, Long> {
 
     List<? extends ResourceTag> listBy(long resourceId, ResourceObjectType resourceType);
 
+    void updateResourceId(long srcId, long destId, ResourceObjectType resourceType);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2133c302/engine/schema/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java b/engine/schema/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
index 3611999..a6c2624 100644
--- a/engine/schema/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
+++ b/engine/schema/src/com/cloud/tags/dao/ResourceTagsDaoImpl.java
@@ -59,4 +59,14 @@ public class ResourceTagsDaoImpl extends GenericDaoBase<ResourceTagVO, Long> imp
         sc.setParameters("resourceType", resourceType);
         return listBy(sc);
     }
+
+    @Override public void updateResourceId(long srcId, long destId, ResourceObjectType resourceType) {
+        SearchCriteria<ResourceTagVO> sc = AllFieldsSearch.create();
+        sc.setParameters("resourceId", srcId);
+        sc.setParameters("resourceType", resourceType);
+        for( ResourceTagVO tag : listBy(sc)) {
+            tag.setResourceId(destId);
+            update(tag.getId(), tag);
+        }
+    }
 }