Skip to content

Flexible tags for hosts and storage pools - #7489

Merged
DaanHoogland merged 19 commits into
apache:mainfrom
scclouds:flexible-tags
Nov 30, 2023
Merged

Flexible tags for hosts and storage pools#7489
DaanHoogland merged 19 commits into
apache:mainfrom
scclouds:flexible-tags

Conversation

@JoaoJandre

Copy link
Copy Markdown
Contributor

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)
  • 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

  • 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 storagepools (SP)

No.TestResultExpected behavior? (Y/N)
1Create zoneWide SP with flexible tagSP successfully createdY
2Create clusterWide SP with flexible tagSP successfully createdY
3Create SP datastore Cluster (vmware) with flexible tagSP successfully createdY
4Update SP (all three types) with flexible tagSuccessY

With the following situation in the environment:
Storage 1 with rule tags[0] == 'milk' and Storage 2 with rule tags[0] == 'cereal'

No.TestResultExpected behavior? (Y/N)
1Create volume using offering tagged milkVolume allocated to storage 1Y
2Create volume using offering tagged cerealVolume allocated to storage 2Y
3Create volume using untagged offeringError trying to allocate volumeY
3Create volume using offering tagged bananaError trying to allocate volumeY

With the following situation in the environment:
Storage 1 with rule tags[0] == 'milk' and Storage 2 with tag cereal

No.TestResultExpected behavior? (Y/N)
1Create volume using offering tagged milkVolume allocated to storage 1Y
2Create volume using offering tagged cerealVolume allocated to storage 2Y
3Create volume using untagged offeringVolume allocated to storage 2Y
4With the volume of test 1, resize the volume, without changing the offeringSuccessY
5With the volume of test 1, resize the volume, changing the offering to another with the same tagSuccessY
6With the volume of test 1, resize the volume, changing the offering to another one with a different tagExceptionY
7With the volume of test 2, tests 4, 5 and 6 were redoneSame resultsY

Regarding Hosts:

No.TestResultExpected behavior? (Y/N)
1Removing a host and making that host rediscover mgmtSuccessY
2Call the updateHost API to update a host tag to a flexible tagChanged tagY

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.TestResultExpected behavior? (Y/N)
1VM Deploy with offering tagged milkVM allocated to host 1Y
2VM Deploy with offering tagged cerealVM allocated to host 2/3Y
3VM Deploy with untagged offeringExceptionY
4Vm Deploy with offering tagged bananaExceptionY

With the following situation in the environment:
Host 1 with rule tags[0] == 'milk', Host 2 and Host 3 with tag cereal

No.TestResultExpected behavior? (Y/N)
1VM Deploy with offering tagged milkVM allocated to host 1Y
2VM Deploy with offering tagged cerealVM allocated to host 2/3Y
3VM Deploy with untagged offeringVM allocated to host 2/3Y
4VM Deploy with offering tagged bananaExceptionY

Regarding quota activation rules:

No.TestResultExpected behavior? (Y/N)
1Create tariff using activation rule value.host.isTagARulerule activated correctlyY

@DaanHoogland

Copy link
Copy Markdown
Contributor

@JoaoJandre , I haven´t got my head around how exactly this would work yet but it seems promising.
@andrijapanicsb Can you have a look?

@yadvr

yadvr commented May 8, 2023

Copy link
Copy Markdown
Member

@JoaoJandre could a global setting and its use in the deployment planner be enough to make the deployment and related lifecycles are strictly or non-strictly allowed the by deployment planner?

@codecov

codecovBot commented May 8, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 135 lines in your changes are missing coverage. Please review.

Comparison is base (c7ed4ca) 18.33% compared to head (76e4aae) 29.17%.
Report is 5 commits behind head on main.

FilesPatch %Lines
.../src/main/java/com/cloud/host/dao/HostDaoImpl.java53.84%20 Missing and 4 partials ⚠️
...loudstack/utils/jsinterpreter/TagAsRuleHelper.java0.00%16 Missing ⚠️
...ain/java/com/cloud/storage/StorageManagerImpl.java13.33%13 Missing ⚠️
.../cloud/configuration/ConfigurationManagerImpl.java40.00%10 Missing and 2 partials ⚠️
...om/cloud/api/query/dao/StoragePoolJoinDaoImpl.java78.37%6 Missing and 2 partials ⚠️
.../agent/manager/allocator/impl/RandomAllocator.java0.00%7 Missing ⚠️
.../main/java/com/cloud/storage/StoragePoolTagVO.java45.45%6 Missing ⚠️
.../com/cloud/storage/dao/StoragePoolTagsDaoImpl.java40.00%6 Missing ⚠️
...che/cloudstack/metrics/PrometheusExporterImpl.java0.00%6 Missing ⚠️
...gent/manager/allocator/impl/FirstFitAllocator.java20.00%3 Missing and 1 partial ⚠️
... and 16 more
Additional details and impacted files
@@ Coverage Diff @@## main #7489 +/- ##
=============================================
+ Coverage 18.33% 29.17% +10.84% - Complexity 17808 31127 +13319 
=============================================
Files 5059 5195 +136 Lines 344296 366930 +22634 Branches 49577 53735 +4158 =============================================
+ Hits 63132 107065 +43933 + Misses 272093 245223 -26870 - Partials 9071 14642 +5571 
FlagCoverage Δ
simulator-marvin-tests25.16% <41.56%> (+5.60%)⬆️
uitests4.45% <ø> (-0.04%)⬇️
unit-tests14.82% <28.32%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoaoJandre

JoaoJandre commented May 8, 2023

Copy link
Copy Markdown
ContributorAuthor

@JoaoJandre could a global setting and its use in the deployment planner be enough to make the deployment and related lifecycles are strictly or non-strictly allowed the by deployment planner?

This would be the simplest solution; however, it would be limited as well. A setting like that would either make all hosts accept or not accept offerings without tags (the same with storage pools). The solution proposed in this PR makes the hosts and storage tags much more flexible; for instance, you could have hosts that accept untagged offerings, while others do not. Furthermore, being able to write a rule in JS opens space for operator creativity, and they would have a much finer control/understanding over their cloud environment.

Also, the current behavior is kept; therefore, the use of tag as rules is optional.

@andrijapanicsb

Copy link
Copy Markdown
Contributor

Sounds interesting - as long as we keep the original behaviour a default (backward compatibility), I think this would be an interesting feature. It does add complexity (as with anything else), so proper documentation should be in place.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@DaanHoogland

Copy link
Copy Markdown
Contributor

Sounds interesting - as long as we keep the original behaviour a default (backward compatibility), I think this would be an interesting feature. It does add complexity (as with anything else), so proper documentation should be in place.

@JoaoJandre , can you reply this comment, please? As I read this the old behaviour is intact without change. But is there any risk that a user may think they use an old fashion tag but end up creating a dynamic one?

@JoaoJandre

Copy link
Copy Markdown
ContributorAuthor

Sounds interesting - as long as we keep the original behaviour a default (backward compatibility), I think this would be an interesting feature. It does add complexity (as with anything else), so proper documentation should be in place.

@JoaoJandre , can you reply this comment, please? As I read this the old behaviour is intact without change. But is there any risk that a user may think they use an old fashion tag but end up creating a dynamic one?

Sure, as I stated on #7489 (comment), the current behavior is kept; therefore, the use of tag as rules is optional. Users have to explicitly inform the isTagARule parameter as true when calling the APIs to make the tags be interpreted as rules.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@DaanHooglandDaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good code , but needs good functional verification

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6180

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test matrix

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SF] Trillian-Jenkins matrix job (centos7 mgmt + xenserver71, rocky8 mgmt + vmware67u3, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-6627)
Environment: xenserver-71 (x2), Advanced Networking with Mgmt server 7
Total time taken: 41078 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7489-t6627-xenserver-71.zip
Smoke tests completed. 110 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-6628)
Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server r8
Total time taken: 41071 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7489-t6628-vmware-67u3.zip
Smoke tests completed. 85 look OK, 1 have errors, 24 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_08_arping_in_ssvmFailure60.66test_diagnostics.py
test_09_arping_in_cpvmFailure60.75test_diagnostics.py
all_test_safe_shutdownSkipped---test_safe_shutdown.py
all_test_metrics_apiSkipped---test_metrics_api.py
all_test_outofbandmanagementSkipped---test_outofbandmanagement.py
all_test_outofbandmanagement_nestedpluginSkipped---test_outofbandmanagement_nestedplugin.py
all_test_routers_iptables_default_policySkipped---test_routers_iptables_default_policy.py
all_test_secondary_storageSkipped---test_secondary_storage.py
all_test_service_offeringsSkipped---test_service_offerings.py
all_test_storage_policySkipped---test_storage_policy.py
all_test_templatesSkipped---test_templates.py
all_test_update_security_groupSkipped---test_update_security_group.py
all_test_usage_eventsSkipped---test_usage_events.py
all_test_vm_autoscalingSkipped---test_vm_autoscaling.py
all_test_vm_deployment_plannerSkipped---test_vm_deployment_planner.py
all_test_vm_life_cycleSkipped---test_vm_life_cycle.py
all_test_vm_lifecycle_unmanage_importSkipped---test_vm_lifecycle_unmanage_import.py
all_test_vm_snapshot_kvmSkipped---test_vm_snapshot_kvm.py
all_test_vm_snapshotsSkipped---test_vm_snapshots.py
all_test_volumesSkipped---test_volumes.py
all_test_vpc_ipv6Skipped---test_vpc_ipv6.py
all_test_vpc_redundantSkipped---test_vpc_redundant.py
all_test_vpc_router_nicsSkipped---test_vpc_router_nics.py
all_test_vpc_vpnSkipped---test_vpc_vpn.py
all_test_host_maintenanceSkipped---test_host_maintenance.py
all_test_hostha_kvmSkipped---test_hostha_kvm.py

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-6629)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 44219 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7489-t6629-kvm-centos7.zip
Smoke tests completed. 110 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@JoaoJandre can you solve the conflicts?

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@JoaoJandre

Copy link
Copy Markdown
ContributorAuthor

@JoaoJandre can you solve the conflicts?

@DaanHoogland I guess the conflicts solved themselves :D

@shwstpprshwstppr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoaoJandre do we need to move storage_pool_view to the view file now as per #7417?

@JoaoJandre

Copy link
Copy Markdown
ContributorAuthor

@shwstppr done

@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@shwstpprshwstppr reopened this Nov 21, 2023
@DaanHoogland

Copy link
Copy Markdown
Contributor

from the backend:

Smoke tests completed. 117 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_08_migrate_vmError42.83test_vm_life_cycle.py

github api rate limit hit, but I think we are ok with this one, @shwstppr.

@GutoVeronezi

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@GutoVeronezi a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7860

@DaanHoogland

Copy link
Copy Markdown
Contributor

@shwstppr@GutoVeronezi are we good with this one?

@GutoVeronezi

Copy link
Copy Markdown
Contributor

@shwstppr@GutoVeronezi are we good with this one?

LGTM, nothing more from my side.

@shwstppr

Copy link
Copy Markdown
Contributor

@DaanHoogland I'm good as it already has the required approvals.

@JoaoJandre should we add some notes in the documentation to highlight the new behaviour?

@DaanHoogland

Copy link
Copy Markdown
Contributor

@DaanHoogland I'm good as it already has the required approvals.

@JoaoJandre should we add some notes in the documentation to highlight the new behaviour?

@JoaoJandre I added an issue for documentation and assigned you (#8283 )

merging

@DaanHoogland
DaanHoogland merged commit 26b01f6 into apache:mainNov 30, 2023
@JoaoJandre

Copy link
Copy Markdown
ContributorAuthor

@DaanHoogland I'm good as it already has the required approvals.
@JoaoJandre should we add some notes in the documentation to highlight the new behaviour?

@JoaoJandre I added an issue for documentation and assigned you (#8283 )

merging

@DaanHoogland Okay, I'll add it to my tasks and do it in the following days.

@Pearl1594Pearl1594 mentioned this pull request Dec 5, 2023
13 tasks
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Dec 6, 2023
Co-authored-by: João Jandre <joao@scclouds.com.br>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@JoaoJandre@DaanHoogland@yadvr@andrijapanicsb@blueorangutan@shwstppr@GutoVeronezi@rajujith