Skip to content

Conversation

@winterhazel
Copy link
Member

Description

Before commit 03a4b9f, preset variables were injected into the JS interpreter by directly prepending them as a string to the script. 03a4b9f changed the interpreter so that preset variables are injected via bindings instead. However, all preset variables are still injected as a string. Due to this, variables that were previously interpreted as objects are now interpreted as strings. This broke the Quota activation rules and secondary storage selectors features.

This PR changes the code to inject the preset variables using their expected types. Also, the test files of most preset variables have been removed because the tests do not make sense anymore with the new injection mechanism.

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  • I created a Quota tariff with an activation rule, ran the Usage job, and debugged org.apache.cloudstack.utils.jsinterpreter.JsInterpreter#executeScriptInThread to validate that the preset variables had their expected type in the JS interpreter.
  • I created a secondary storage selector for templates, registered a template, and debugged org.apache.cloudstack.utils.jsinterpreter.JsInterpreter#executeScriptInThread to validate that the preset variables had their expected type in the JS interpreter.
  • I added a flexible host tag to one of my hosts, deployed a VM using an offering that matched the tag, and debugged org.apache.cloudstack.utils.jsinterpreter.JsInterpreter#executeScriptInThread to validate that the offering's host tags were correctly injected into the JS interpreter as a list.

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 67.21311% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.27%. Comparing base (8db065a) to head (d2ca3ef).
⚠️ Report is 21 commits behind head on 4.20.

Files with missing lines Patch % Lines
...dstack/storage/heuristics/HeuristicRuleHelper.java 40.00% 6 Missing ⚠️
...k/storage/heuristics/presetvariables/Template.java 33.33% 4 Missing ⚠️
...ionrule/presetvariables/GenericPresetVariable.java 0.00% 2 Missing ⚠️
...resetvariables/GenericHeuristicPresetVariable.java 0.00% 2 Missing ⚠️
.../cloudstack/utils/jsinterpreter/JsInterpreter.java 77.77% 1 Missing and 1 partial ⚠️
...loudstack/utils/jsinterpreter/TagAsRuleHelper.java 71.42% 2 Missing ⚠️
...k/storage/heuristics/presetvariables/Snapshot.java 50.00% 1 Missing ⚠️
...ack/storage/heuristics/presetvariables/Volume.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #12515      +/-   ##
============================================
+ Coverage     16.24%   16.27%   +0.02%     
- Complexity    13396    13487      +91     
============================================
  Files          5658     5658              
  Lines        499169   503837    +4668     
  Branches      60579    62882    +2303     
============================================
+ Hits          81087    81990     +903     
- Misses       409041   412715    +3674     
- Partials       9041     9132      +91     
Flag Coverage Δ
uitests 3.98% <ø> (-0.05%) ⬇️
unittests 17.13% <67.21%> (+0.03%) ⬆️

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.

@winterhazel
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@winterhazel 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

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16519

@winterhazel
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@winterhazel 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

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

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@DaanHoogland DaanHoogland requested a review from shwstppr January 26, 2026 11:35
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@RosiKyu
Copy link
Collaborator

RosiKyu commented Jan 26, 2026

@blueorangutan test

@RosiKyu RosiKyu self-assigned this Jan 26, 2026
@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian test result (tid-15273)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52572 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12515-t15273-kvm-ol8.zip
Smoke tests completed. 141 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
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

Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.


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

Copy link
Contributor

@shwstppr shwstppr 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. Copilot highlighted a logging issue

@blueorangutan
Copy link

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

Test Result Time (s) Test File

@winterhazel
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

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

@sonarqubecloud
Copy link

@blueorangutan
Copy link

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

Sign up for free to 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.

5 participants