Skip to content

Unhide setting js.interpretation.enabled#12605

Open
winterhazel wants to merge 2 commits intoapache:4.20from
winterhazel:unhide-js-interpretation-enabled
Open

Unhide setting js.interpretation.enabled#12605
winterhazel wants to merge 2 commits intoapache:4.20from
winterhazel:unhide-js-interpretation-enabled

Conversation

@winterhazel
Copy link
Member

@winterhazel winterhazel commented Feb 6, 2026

Description

This PR proposes unhiding js.interpretation.enabled. For reference regarding why, see the discussion in #12523.

Also, the configuration was made dynamic, and some extra refactoring was performed to organize the code (JsInterpreterHelper already exists in main).

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

How Has This Been Tested?

  1. I upgraded my environment to the new version, with the changes included, and checked the database entry for js.interpretation.enabled.
  • Before the changes:

    MariaDB [cloud]> select * from configuration where name = "js.interpretation.enabled";
      +----------+----------+------------------+---------------------------+----------------------------------------------+------------------------------------------------------------------------------------------------------------+---------------+---------------------+------------+----------+-------------+--------+---------------------------+------+---------+-------+
      | category | instance | component        | name                      | value                                        | description                                                                                                | default_value | updated             | is_dynamic | group_id | subgroup_id | parent | display_text              | kind | options | scope |
      +----------+----------+------------------+---------------------------+----------------------------------------------+------------------------------------------------------------------------------------------------------------+---------------+---------------------+------------+----------+-------------+--------+---------------------------+------+---------+-------+
      | Hidden   | DEFAULT  | ManagementServer | js.interpretation.enabled | MQmVLZoL1kmmDHZR1YsoIgw0OuvMDdyTnU9y3FEUNDA= | Enable/Disable all JavaScript interpretation related functionalities to create or update Javascript rules. | false         | 2026-01-23 11:09:12 |          0 |        1 |           1 | NULL   | Js interpretation enabled | NULL | NULL    |     1 |
      +----------+----------+------------------+---------------------------+----------------------------------------------+------------------------------------------------------------------------------------------------------------+---------------+---------------------+------------+----------+-------------+--------+---------------------------+------+---------+-------+
  • In the logs:

    2026-02-06 11:46:01,436 INFO  [c.c.u.d.Upgrade42210to42300] (main:[]) (logid:) Updating setting 'js.interpretation.enabled' to decrypted value [true].
    
  • After the changes:

    MariaDB [cloud]> select * from configuration where name = "js.interpretation.enabled";
     +----------+----------+---------------+---------------------------+-------+-----------------------------------------------------------------------+---------------+---------------------+------------+----------+-------------+--------+---------------------------+------+---------+-------+
     | category | instance | component     | name                      | value | description                                                           | default_value | updated             | is_dynamic | group_id | subgroup_id | parent | display_text              | kind | options | scope |
     +----------+----------+---------------+---------------------------+-------+-----------------------------------------------------------------------+---------------+---------------------+------------+----------+-------------+--------+---------------------------+------+---------+-------+
     | System   | DEFAULT  | JsInterpreter | js.interpretation.enabled | true  | Enable/disable all JavaScript interpretation related functionalities. | false         | 2026-02-06 11:45:28 |          1 |        1 |           1 | NULL   | Js interpretation enabled | NULL | NULL    |     1 |
     +----------+----------+---------------+---------------------------+-------+-----------------------------------------------------------------------+---------------+---------------------+------------+----------+-------------+--------+---------------------------+------+---------+-------+
  1. I attempted to create heuristic rules, flexible tags, and Quota activation rules. When the setting was disabled, I received an error informing me that js.interpretation.enabled was disabled. When the setting was enabled, I was able to create them successfully.

@winterhazel
Copy link
Member Author

@blueorangutan package

@winterhazel winterhazel changed the title Unhide setting 'js.interpretation.enabled' Unhide setting js.interpretation.enabled Feb 6, 2026
@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.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (3d7d412) to head (2c89c1c).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
...ava/com/cloud/upgrade/dao/Upgrade42020to42030.java 0.00% 30 Missing ⚠️
.../cloudstack/jsinterpreter/JsInterpreterHelper.java 0.00% 13 Missing ⚠️
...ain/java/com/cloud/storage/StorageManagerImpl.java 0.00% 4 Missing ⚠️
...in/java/com/cloud/server/ManagementServerImpl.java 0.00% 3 Missing ⚠️
...udstack/api/response/QuotaResponseBuilderImpl.java 0.00% 2 Missing ⚠️
...n/java/com/cloud/resource/ResourceManagerImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12605   +/-   ##
=========================================
  Coverage     16.26%   16.26%           
  Complexity    13429    13429           
=========================================
  Files          5661     5662    +1     
  Lines        500010   500056   +46     
  Branches      60715    60719    +4     
=========================================
+ Hits          81331    81352   +21     
- Misses       409606   409631   +25     
  Partials       9073     9073           
Flag Coverage Δ
uitests 4.15% <ø> (ø)
unittests 17.12% <0.00%> (+<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

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

@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

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15416)

…to42030.java

Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
@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 16762

@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

Copy link
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

[SF] Trillian Build Failed (tid-15426)

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

This PR unhides the js.interpretation.enabled configuration setting, moving it from the "Hidden" category to the "System" category, and makes it dynamic so it can be changed without restarting the management server. This addresses issue #12523 where the management server would hang during startup when this setting was enabled. The PR refactors the JavaScript interpretation validation logic by introducing a new JsInterpreterHelper class that centralizes the configuration and validation logic.

Changes:

  • Introduces JsInterpreterHelper class to centralize JS interpretation configuration and validation
  • Moves js.interpretation.enabled from ManagementService to JsInterpreterHelper and changes it from "Hidden" to "System" category
  • Makes the configuration dynamic to allow runtime changes
  • Migrates all validation calls from ManagementService.checkJsInterpretationAllowedIfNeededForParameterValue() to JsInterpreterHelper.ensureInterpreterEnabledIfParameterProvided()
  • Adds database upgrade script to unhide and decrypt the existing configuration value

Reviewed changes

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

Show a summary per file
File Description
server/src/main/java/org/apache/cloudstack/jsinterpreter/JsInterpreterHelper.java New helper class that implements Configurable interface and provides the JS_INTERPRETATION_ENABLED ConfigKey and validation method
server/src/main/java/com/cloud/storage/StorageManagerImpl.java Updated to inject and use JsInterpreterHelper for validating storage pool and secondary storage selector operations
server/src/main/java/com/cloud/server/ManagementServerImpl.java Removed old ConfigKey definition, jsInterpretationEnabled field, and validation method; unconditionally registers CreateSecondaryStorageSelectorCmd and UpdateSecondaryStorageSelectorCmd
server/src/main/java/com/cloud/resource/ResourceManagerImpl.java Updated to inject and use JsInterpreterHelper for validating host update operations
plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java Removed jsInterpretationEnabled field and isJsInterpretationEnabled() method
plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaService.java Removed isJsInterpretationEnabled() method from interface
plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java Updated to inject and use JsInterpreterHelper for validating quota tariff operations
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42020to42030.java Adds database migration to unhide and decrypt the js.interpretation.enabled configuration setting
api/src/main/java/com/cloud/server/ManagementService.java Removed JsInterpretationEnabled ConfigKey and checkJsInterpretationAllowedIfNeededForParameterValue() method

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

Comment on lines +84 to +88
String query = "UPDATE cloud.configuration SET value = ?, category = 'System' WHERE name = 'js.interpretation.enabled' AND category = 'Hidden';";

try (PreparedStatement pstmt = conn.prepareStatement(query)) {
String decryptedValue = DBEncryptionUtil.decrypt(encryptedValue);
logger.info("Updating setting 'js.interpretation.enabled' to decrypted value [{}], and category 'System'.", decryptedValue);
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The SQL UPDATE statement only updates the 'value' and 'category' fields, but according to the PR description and the new ConfigKey definition in JsInterpreterHelper, the 'component' field should also be updated from 'ManagementServer' to 'JsInterpreter', and the 'is_dynamic' field should be updated to 1 (true). The SQL query should be: "UPDATE cloud.configuration SET value = ?, category = 'System', component = 'JsInterpreter', is_dynamic = 1 WHERE name = 'js.interpretation.enabled' AND category = 'Hidden';"

Suggested change
String query = "UPDATE cloud.configuration SET value = ?, category = 'System' WHERE name = 'js.interpretation.enabled' AND category = 'Hidden';";
try (PreparedStatement pstmt = conn.prepareStatement(query)) {
String decryptedValue = DBEncryptionUtil.decrypt(encryptedValue);
logger.info("Updating setting 'js.interpretation.enabled' to decrypted value [{}], and category 'System'.", decryptedValue);
String query = "UPDATE cloud.configuration SET value = ?, category = 'System', component = 'JsInterpreter', is_dynamic = 1 WHERE name = 'js.interpretation.enabled' AND category = 'Hidden';";
try (PreparedStatement pstmt = conn.prepareStatement(query)) {
String decryptedValue = DBEncryptionUtil.decrypt(encryptedValue);
logger.info("Updating setting 'js.interpretation.enabled' to decrypted value [{}], category 'System', component 'JsInterpreter', and is_dynamic = 1.", decryptedValue);

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +95
} catch (CloudRuntimeException e) {
logger.warn("Error while decrypting configuration 'js.interpretation.enabled'. The configuration may already be decrypted.");
}
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The error handling here catches a generic CloudRuntimeException, but DBEncryptionUtil.decrypt() throws EncryptionOperationNotPossibleException when the value is already decrypted. The catch block should specifically catch EncryptionOperationNotPossibleException to distinguish between an already-decrypted value and an actual error. Additionally, when catching this exception, the code should proceed with using the encrypted value (since it's already decrypted) instead of just logging a warning and not updating the database.

Copilot uses AI. Check for mistakes.
@DaanHoogland DaanHoogland added this to the 4.20.3 milestone Feb 16, 2026
@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15484)

@weizhouapache
Copy link
Member

@winterhazel
the mgmt service failed to start , can you check ?
the simulator CI tests failed too

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