Skip to content

Fix listing service offerings with different host tags#12919

Merged
DaanHoogland merged 5 commits intoapache:4.22from
shapeblue:422-change-offering-hosttags
Apr 9, 2026
Merged

Fix listing service offerings with different host tags#12919
DaanHoogland merged 5 commits intoapache:4.22from
shapeblue:422-change-offering-hosttags

Conversation

@nvazquez
Copy link
Copy Markdown
Contributor

@nvazquez nvazquez commented Mar 30, 2026

Description

This PR introduces the global setting: allow.different.host.tags.offerings.for.vm.scale to fix the listing of service offerings for VMs, including offerings that contain different host tags.

  • Previously only offerings without any host tag or offerings matching exactly the same VM offering host tags were displayed
  • By default the setting is set to false, to preserve the previous behavior.
  • When the setting is enabled, the listing of service offerings for a VM will include offerings containing different host tags than the current offering

Fixes: #11407

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)
  • Build/CI
  • Test (unit or integration test code)

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?

  • Create service offering A with host tag = TAG_A
  • Create service offering B with host tag = TAG_B
  • Edit hosts, some using tag TAG_A and some using TAG_B
  • Deploy VM from service offering A
  • Stop VM
  • Click on Scale VM, observe that offering B is available, select offering B
  • VM is properly scaled to use offering B

How did you try to break this feature and the system with this change?

@nvazquez
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@nvazquez 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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 47.22222% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.60%. Comparing base (59b6c32) to head (d2685ff).
⚠️ Report is 8 commits behind head on 4.22.

Files with missing lines Patch % Lines
...ain/java/com/cloud/api/query/QueryManagerImpl.java 50.00% 7 Missing and 4 partials ⚠️
.../main/java/com/cloud/host/dao/HostTagsDaoImpl.java 33.33% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #12919      +/-   ##
============================================
- Coverage     17.60%   17.60%   -0.01%     
+ Complexity    15676    15675       -1     
============================================
  Files          5918     5918              
  Lines        531667   531721      +54     
  Branches      65001    65013      +12     
============================================
+ Hits          93617    93621       +4     
- Misses       427491   427535      +44     
- Partials      10559    10565       +6     
Flag Coverage Δ
uitests 3.70% <ø> (-0.01%) ⬇️
unittests 18.67% <47.22%> (-0.01%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates service offering listing logic (used for VM scaling) so that offerings with different host tags are also shown, by expanding the tag filter to include tags present on hosts in the VM’s current cluster and by loosening host-tag matching to OR semantics.

Changes:

  • Extend service offering filtering to include host tags from the VM’s current cluster when listing scale-eligible offerings.
  • Change host-tag matching from requiring all tags (AND) to allowing any matching tag (OR), while still including untagged offerings.
  • Add unit tests for collecting cluster host tags into the VM’s host tag filter.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java Expands host-tag filtering for service offering listing and adds helper to include cluster tags.
engine/schema/src/main/java/com/cloud/host/dao/HostTagsDao.java Adds DAO API to list host tags by cluster ID.
engine/schema/src/main/java/com/cloud/host/dao/HostTagsDaoImpl.java Implements listing tags by cluster via host IDs + custom search.
server/src/test/java/com/cloud/api/query/QueryManagerImplTest.java Adds tests for the new helper that augments host tags with current cluster tags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nvazquez
Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@nvazquez nvazquez added this to the 4.22.1 milestone Mar 31, 2026
@nvazquez
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@nvazquez 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]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17308

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@blueorangutan
Copy link
Copy Markdown

@nvazquez 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]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17314

Copy link
Copy Markdown
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

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

code lgtm

Copy link
Copy Markdown
Member

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

@nvazquez the setting is not in effect for custom offerings

Steps to reproduce the issue

  1. Have 2 host tags with hosttags h1 and h2 respectively

  2. Create a custom unconstrained offering c1 with host tag h1

  3. Create another custom unconstrained offering c2 with host tag h2

  4. Make sure dynamic scaling is enabled in the global settings and service offering and the registered template

  5. Deploy a vm with the custom unconstrained offering c1

  6. Make sure the global setting "allow.different.host.tags.offerings.for.vm.scale" is enabled

  7. Scale the running vm

  8. The custom unconstrained offering c2 with host tag h2 is not displayed

Image
  1. If the vm is stopped then all the offerings are displayed
Screenshot 2026-04-06 at 4 19 16 PM

@nvazquez
Copy link
Copy Markdown
Contributor Author

nvazquez commented Apr 6, 2026

Hi @kiranchavala this is similar to issue: #6865 and it seems to be by design from PR: #5923. I do see it is planned to be fixed by: #12908

Copy link
Copy Markdown
Member

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

@nvazquez can you add the host tags and storage tags in the UI

when a user tries to scale the VM, it's handy to see the tags associated with the service offering

https://cloudstack.apache.org/api/apidocs-4.22/apis/listServiceOfferings.html

Image
(local) 🐱 > list serviceofferings id=57d7582f-d854-477c-9690-329eeada8d32  filter=hosttags,storagetags
{
  "count": 1,
  "serviceoffering": [
    {
      "hosttags": "test3",
      "storagetags": "test3"
    }
  ]
}

@nvazquez
Copy link
Copy Markdown
Contributor Author

nvazquez commented Apr 7, 2026

@kiranchavala please find the fix pushed, host tags and/or storage tags will only be displayed when available at least in one offering from the list

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@nvazquez 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]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17388

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

Test Result Time (s) Test File

Copy link
Copy Markdown
Member

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

LGTM

Tested the issue manually

Tested with both admin and with normal user role

Have 2 host tags with hosttags h1 and h2 respectively

Create a compute offering c1,c2,c3 with host tags h1,h2,h3 respectively

Stop the vm

Scale the vm

Only the compute offering c3 is visible, as it has the same host tag

Make sure the global setting "allow.different.host.tags.offerings.for.vm.scale" is enabled

Scale the vm

Compute offering c2 is also visible, though it having a host tag h2

Also the host tags and storage tags are visible in the ui

Image

@DaanHoogland DaanHoogland merged commit b585802 into apache:4.22 Apr 9, 2026
26 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Apache CloudStack 4.22.1 Apr 9, 2026
@DaanHoogland DaanHoogland deleted the 422-change-offering-hosttags branch April 9, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Ability to change compute offering with different host tags

7 participants