cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Kudryavtsev <kudryavtsev...@bw-sw.com>
Subject Tag removal problem found. Need assistance how to fix
Date Wed, 22 Nov 2017 09:58:54 GMT
Hi, I found interesting behaviour with tags:

mysql> SELECT resource_tags.id, resource_tags.uuid, resource_tags.key,
resource_tags.value, resource_tags.domain_id, resource_tags.account_id,
resource_tags.resource_id, resource_tags.resource_uuid,
resource_tags.resource_type, resource_tags.customer FROM resource_tags
WHERE  ( resource_tags.resource_id='2a4264fb-9f63-4d4f-9465-c1bc5440ea60'
OR
resource_tags.resource_uuid=_binary'2a4264fb-9f63-4d4f-9465-c1bc5440ea60' )
 AND resource_tags.resource_type = 'Account';

+----+--------------------------------------+-------+-------+-----------+------------+-------------+--------------------------------------+---------------+----------+
| id | uuid                                 | key   | value | domain_id |
account_id | resource_id | resource_uuid                        |
resource_type | customer |
+----+--------------------------------------+-------+-------+-----------+------------+-------------+--------------------------------------+---------------+----------+
|  7 | 95a1a314-2247-4622-a33f-b9b2680bc2e1 | test  | me    |         1 |
       2 |           2 | 3199fc71-cf39-11e7-af5d-dc0ea16ecd7f | Account
  | NULL     |
| 10 | 6c247aa1-5524-4910-9b5f-c6cfd9b3bdd9 | test3 | me    |         1 |
       4 |           4 | 2a4264fb-9f63-4d4f-9465-c1bc5440ea60 | Account
  | NULL     |
| 12 | 25fb7848-af34-42f7-855e-0f5909a4e979 | test5 | me2   |         1 |
       4 |           4 | 2a4264fb-9f63-4d4f-9465-c1bc5440ea60 | Account
  | NULL     |
+----+--------------------------------------+-------+-------+-----------+------------+-------------+--------------------------------------+---------------+----------+
3 rows in set, 1 warning (0.01 sec)

Don't see that "resource_type" is "account". I just play with it.

Take a look at ID=7. This row is found because:

resource_tags.resource_id='2a4264fb-9f63-4d4f-9465-c1bc5440ea60' when right
part is converted to int. Corresponding code is here:

https://github.com/apache/cloudstack/blob/87ef8137534fa798101f65c6691fcf71513ac978/server/src/com/cloud/tags/TaggedResourceManagerImpl.java#L301

sb.and().op("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.IN);
sb.or("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.IN);
sb.cp();
sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ);

I don't know why the writer uses "resourceId" or "resourceUuid". I suppose
it's a bug and code should be transformed to:

sb.and("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.IN);
sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ);

Or MySQL query should be transformed to:

mysql> SELECT resource_tags.id, resource_tags.uuid, resource_tags.key,
resource_tags.value, resource_tags.domain_id, resource_tags.account_id,
resource_tags.resource_id, resource_tags.resource_uuid,
resource_tags.resource_type, resource_tags.customer FROM resource_tags
WHERE  ( concat("%", resource_tags.resource_id) =
'2a4264fb-9f63-4d4f-9465-c1bc5440ea60' OR
resource_tags.resource_uuid=_binary'2a4264fb-9f63-4d4f-9465-c1bc5440ea60' )
 AND resource_tags.resource_type = 'Account';
+----+--------------------------------------+-------+-------+-----------+------------+-------------+--------------------------------------+---------------+----------+
| id | uuid                                 | key   | value | domain_id |
account_id | resource_id | resource_uuid                        |
resource_type | customer |
+----+--------------------------------------+-------+-------+-----------+------------+-------------+--------------------------------------+---------------+----------+
| 10 | 6c247aa1-5524-4910-9b5f-c6cfd9b3bdd9 | test3 | me    |         1 |
       4 |           4 | 2a4264fb-9f63-4d4f-9465-c1bc5440ea60 | Account
  | NULL     |
| 12 | 25fb7848-af34-42f7-855e-0f5909a4e979 | test5 | me2   |         1 |
       4 |           4 | 2a4264fb-9f63-4d4f-9465-c1bc5440ea60 | Account
  | NULL     |
+----+--------------------------------------+-------+-------+-----------+------------+-------------+--------------------------------------+---------------+----------+
2 rows in set (0.00 sec)

Let me your thoughts and I'll fix it. Right now, obviously it's a bug.



-- 
With best regards, Ivan Kudryavtsev
Bitworks Software, Ltd.
Cell: +7-923-414-1515
WWW: http://bitworks.software/ <http://bw-sw.com/>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message