Unhide setting js.interpretation.enabled#12605
Unhide setting js.interpretation.enabled#12605winterhazel wants to merge 2 commits intoapache:4.20from
js.interpretation.enabled#12605Conversation
|
@blueorangutan package |
js.interpretation.enabled
|
@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 Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16729 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-15416) |
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42020to42030.java
Outdated
Show resolved
Hide resolved
…to42030.java Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
|
@blueorangutan package |
|
@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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16762 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-15426) |
There was a problem hiding this comment.
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
JsInterpreterHelperclass to centralize JS interpretation configuration and validation - Moves
js.interpretation.enabledfrom 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()toJsInterpreterHelper.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.
| 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); |
There was a problem hiding this comment.
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';"
| 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); |
| } catch (CloudRuntimeException e) { | ||
| logger.warn("Error while decrypting configuration 'js.interpretation.enabled'. The configuration may already be decrypted."); | ||
| } |
There was a problem hiding this comment.
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.
|
[SF] Trillian Build Failed (tid-15484) |
|
@winterhazel |
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 (
JsInterpreterHelperalready exists inmain).Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
js.interpretation.enabled.Before the changes:
In the logs:
After the changes:
js.interpretation.enabledwas disabled. When the setting was enabled, I was able to create them successfully.