JoaoJandre opened a new pull request, #7489:
URL: https://github.com/apache/cloudstack/pull/7489

   ### Description
   
   Currently when setting tags for a resource, a host for example, offerings 
with those tags will be directed towards that resource. However, offerings 
without any tags may also be directed towards it. Making it so even after 
tagging a resource, with the intention of making it exclusive to certain types 
of offerings, this exclusiveness might be ignored.
   
   Furthermore, the current tag system only allows the user to inform a simple 
list of tags, without the possibility to create more complex rules, like 
checking if the offering has certain pairs of tags.
   
   To address the described problems, we propose to create a new feature to 
allow users to use JS to create more complex tagging rules in the following 
APIs:
   - updateHost
   - createStoragePool
   - updateStoragePool
   
   For this, we will use the JS interpreter introduced in #5909. We will 
introduce a new preset variable, called "tags", which can be used to refer to 
the offering's tags list that will be paired with the resource. A simple 
example of a rule using this preset variable is:
   `tags[0] == cereal && tags[1] == milk`
   
   When setting a resource with this tag rule, only offerings whose first tag 
is cereal and second tag is milk will be accepted, offerings without tags will 
not be accepted. Although, this simple rule does not care for the rest of the 
offering's tags, so an offering with a third tag will also be accepted, no 
matter what the tag is.
   
   To allow users to keep using the current tagging system without any hassle, 
we propose to introduce a new parameter to the affected APIs to inform if ACS 
should treat them the classic way, or to try to interpret it a rule in JS.
   
   In order to support this behavior, we need to store which way the tags 
should be interpreted by ACS. We propose to add a new column called 
`is_tag_a_rule` in the following tables:
   - host_tags
   - storage_pool_tags
   
   Furthermore, those same tables will have their tag column type changed from 
`varchar(255)` to `text`, to allow rules that have more than 255 characters.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [X] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [X] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   Unit tests were created, and some were updated. Moreover, manual tests were 
performed:
   Regarding creating and updating _storage_ _pools_ (SP)
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| Create zoneWide SP with flexible tag | SP successfully created | Y |
   |2| Create clusterWide SP with flexible tag | SP successfully created | Y |
   |3| Create SP datastore Cluster (vmware) with flexible tag | SP successfully 
created | Y |
   |4| Update SP (all three types) with flexible tag | Success | Y |
   
   With the following situation in the environment:
   `Storage 1` with rule `tags[0] == 'milk'` and `Storage 2` with rule `tags[0] 
== 'cereal'`
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| Create volume using offering tagged `milk`| Volume allocated to storage 
1 | Y |
   |2| Create volume using offering tagged `cereal` | Volume allocated to 
storage 2 | Y |
   |3| Create volume using untagged offering | Error trying to allocate volume 
| Y |
   |3| Create volume using offering tagged `banana` | Error trying to allocate 
volume | Y |
   
   With the following situation in the environment:
   `Storage 1` with rule `tags[0] == 'milk'` and `Storage 2` with tag `cereal`
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| Create volume using offering tagged `milk`| Volume allocated to storage 
1 | Y |
   |2| Create volume using offering tagged `cereal` | Volume allocated to 
storage 2 | Y |
   |3| Create volume using untagged offering | Volume allocated to storage 2 | 
Y |
   |4| With the volume of test 1, resize the volume, without changing the 
offering | Success | Y |
   |5| With the volume of test 1, resize the volume, changing the offering to 
another with the same tag | Success | Y |
   |6| With the volume of test 1, resize the volume, changing the offering to 
another one with a different tag | Exception | Y |
   |7| With the volume of test 2, tests 4, 5 and 6 were redone | Same results | 
Y |
   
   Regarding Hosts:
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| Removing a host and making that host rediscover mgmt | Success | Y |
   |2| Call the `updateHost` API to update a host tag to a flexible tag | 
Changed tag | Y |
   
   Regarding deploying VMs:
   With the following situation in the environment:
   `Host 1` with rule `tags[0] == 'milk'`, `Host 2` and `Host 3` with rule 
`tags[0] == cereal`
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| VM Deploy with offering tagged `milk` | VM allocated to host 1 | Y |
   |2| VM Deploy with offering tagged `cereal` | VM allocated to host 2/3 | Y |
   |3| VM Deploy with untagged offering | Exception | Y |
   |4| Vm Deploy with offering tagged `banana` | Exception | Y |
    
   With the following situation in the environment:
   `Host 1` with rule `tags[0] == 'milk'`, `Host 2` and `Host 3` with tag 
`cereal`
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| VM Deploy with offering tagged `milk` | VM allocated to host 1 | Y |
   |2| VM Deploy with offering tagged `cereal` | VM allocated to host 2/3 | Y |
   |3| VM Deploy with untagged offering | VM allocated to host 2/3 | Y |
   |4| VM Deploy with offering tagged `banana` | Exception | Y |
   
   Regarding quota activation rules:
   | No. | Test | Result | Expected behavior? (Y/N) |
   | ------ | ------ | ------ | ------ |
   |1| Create tariff using activation rule `value.host.isTagARule` | rule 
activated correctly | Y |
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to