cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-7362) Resource tagging sometimes tags the wrong resource
Date Mon, 18 Aug 2014 14:18:20 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-7362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14100670#comment-14100670
] 

ASF subversion and git services commented on CLOUDSTACK-7362:
-------------------------------------------------------------

Commit 880bff28e0521aa6696dac491556cd56fbd01eaa in cloudstack's branch refs/heads/master from
[~weizhou]
[ https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;h=880bff2 ]

CLOUDSTACK-7362: fix wrong uuid issue for resource tags
(cherry picked from commit 838a1a8476cfb4308103b3797a281f843e208d38)


> Resource tagging sometimes tags the wrong resource
> --------------------------------------------------
>
>                 Key: CLOUDSTACK-7362
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-7362
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>          Components: API
>    Affects Versions: 4.4.1
>            Reporter: Stephen Hoogendijk
>
> This problem occurs when the uuid of the resource you are about to tag begins with a
number that actually corresponds to the id field of an entry in the same resource type table.
> Example:
> We want to tag security group with UUID 6cb95038-6b76-4905-bdf5-85bf0e0eda51 which has
ID #5. But we also have a security group with ID #6 and UUID d582e52c-f3c1-4e12-8e86-9dad0a5bd725.
What happens is the following:
> First it runs this method:
> {code:java}
> long id = getResourceId(resourceId, resourceType);
> {code}
> which actually tries to find the entity by its UUID and returns the resource id (numeric).
This process goes off without a hitch.
> Next, it actually tries to find the UUID of the resource (because you can also send in
the internal (numeric) identifier):
> {code:java}
> String resourceUuid = getUuid(resourceId, resourceType)
> {code}
> Now this is when the magic starts happening, this is what's happening inside the method:
> {code:java}
> entity = _entityMgr.findById(clazz, resourceId);
>         if (entity != null && entity instanceof Identity) {
>             return ((Identity)entity).getUuid();
>        }
> {code}
> Because our resourceId starts with a numeric 6 the findById method somehow returns the
object that actually has the internal numeric identifier 6. Thus it ends up tagging the wrong
object.
> This issue can be resolved by changing the getUUID() method to:
> {code:java}
>     @Override
>     public String getUuid(String resourceId, ResourceObjectType resourceType) {
>         Class<?> clazz = s_typeMap.get(resourceType);
>         Object entity = _entityMgr.findByUuid(clazz, resourceId);
>         if (entity != null) {
>             return ((Identity)entity).getUuid();
>         }
>         entity = _entityMgr.findById(clazz, resourceId);
>         if (entity != null && entity instanceof Identity) {
>             return ((Identity)entity).getUuid();
>         }
>         return resourceId;
>     }
> {code}
> What i would like to know is if this is a known issue or not? I couldn't find a bug report
here in Jira. If this is an unknown bug then i will go ahead and submit the patch.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message