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 66.66667% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.22%. Comparing base (8db065a) to head (6c819d0).

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 75.00% 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.22%   -0.02%     
+ Complexity    13396    13381      -15     
============================================
  Files          5658     5658              
  Lines        499169   499117      -52     
  Branches      60579    60578       -1     
============================================
- Hits          81087    80999      -88     
- Misses       409041   409074      +33     
- Partials       9041     9044       +3     
Flag Coverage Δ
uitests 4.03% <ø> (ø)
unittests 17.08% <66.66%> (-0.02%) ⬇️

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

@sonarqubecloud
Copy link

@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

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.

2 participants