Skip to content

Conversation

@winterhazel
Copy link
Member

Description

The configuration update process mixes type validation with range validation in com.cloud.configuration.ConfigurationManagerImpl#validateConfigurationValue. To improve this process, this PR splits these validations into two methods (validateValueType and validateValueRange) and cleans up the code.

Furthermore, this PR also fixes an issue that allows non-numeric values to be inserted into Double configurations, such as zone.virtualnetwork.ipv6subnet.capacity.notificationthreshold.

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)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

I manually verified the behavior of trying to update configurations of the following types, and compared them with the previous version to ensure the result was expected:

  • String - quota.currency.symbol and alert.email.addresses (that is, one that does not have null as a valid value and another that does);
  • Boolean - admin.is.allowed.to.deploy.anywhere;
  • Integer - storage.cleanup.interval. (the validations for this type also apply to Short and Long);
  • Float - cpu.overprovisioning.factor (also applies to Double).
Number Test Result Expected result (Y/N)?
1 Value "null" in a String that does not have null as a valid value The value is updated in the database, but the default value is used Y
2 Value "1" in a String that does not have null as a valid value Success Y
3 Value "1.1" in a String that does not have null as a valid value Success Y
4 Value "test" in a String that does not have null as a valid value Success Y
5 Value "null" in a String that has null as a valid value Success Y
6 Value "1" in a String that has null as a valid value Success Y
7 Value "1.1" in a String that has null as a valid value Success Y
8 Value "test" in a String that has null as a valid value Success Y
9 Value "null" in a Boolean Exception Y
10 Value "1" in a Boolean Exception Y
11 Value "1.1" in a Boolean Exception Y
12 Value "test" in a Boolean Exception Y
13 Value "true" in a Boolean Success Y
14 Value "false" in a Boolean Success Y
15 Value "fALse" in a Boolean Exception Y
16 Value "null" in an Integer Exception Y
17 Value "1" in an Integer Success Y
18 Value "1.1" in an Integer Exception Y
19 Value "test" in an Integer Exception Y
20 Value "null" in a Float Exception Y
21 Value "1" in a Float Success Y
22 Value "1.1" in a Float Success Y
23 Value "test" in a Float Exception Y

@winterhazel winterhazel force-pushed the updateconfig-refactor branch from f2e3757 to 91ca46c Compare May 22, 2024 12:03
@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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9670

…gerImpl.java

Co-authored-by: Henrique Sato <henriquesato2003@gmail.com>
@codecov
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 72.28916% with 23 lines in your changes missing coverage. Please review.

Project coverage is 15.58%. Comparing base (b155e3d) to head (ef851d8).
Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
.../cloud/configuration/ConfigurationManagerImpl.java 72.28% 13 Missing and 10 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9107      +/-   ##
============================================
+ Coverage     15.57%   15.58%   +0.01%     
- Complexity    12051    12075      +24     
============================================
  Files          5505     5505              
  Lines        482738   482725      -13     
  Branches      61341    62781    +1440     
============================================
+ Hits          75202    75251      +49     
+ Misses       399227   399166      -61     
+ Partials       8309     8308       -1     
Flag Coverage Δ
uitests 4.17% <ø> (ø)
unittests 16.37% <72.28%> (+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.

@github-actions
Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

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

@github-actions
Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@sureshanaparti sureshanaparti added this to the 4.20.0.0 milestone Jun 29, 2024
@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]: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 10226

@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]: ✔️ el7 ✔️ el8 ✔️ el9 ✖️ debian ✔️ suse15. SL-JID 10228

@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

[SF] Trillian Build Failed (tid-11061)

@winterhazel winterhazel requested a review from hsato03 August 22, 2024 13:00
Copy link
Collaborator

@hsato03 hsato03 left a comment

Choose a reason for hiding this comment

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

LGTM. didn't test

@JoaoJandre
Copy link
Contributor

Hey @winterhazel

I did some testing, overall it looks good, but I've found one case that I think we should address in this PR.

Number Config Value Result
1 storage.cleanup.interval oasij Error
2 storage.cleanup.interval . Error
3 storage.cleanup.interval ( Error
4 storage.cleanup.interval 102938120381209381203981239128 Error
5 storage.cleanup.interval Error
6 storage.cleanup.interval "" Error
7 storage.cleanup.interval 86400 Ok
8 cpu.overprovisioning.factor a Error
9 cpu.overprovisioning.factor ^ Error
10 cpu.overprovisioning.factor 1.1.1 Error
11 cpu.overprovisioning.factor 10928091283012830123810293 OK
12 cpu.overprovisioning.factor 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 OK, but this should not be
13 admin.is.allowed.to.deploy.anywhere 1 Error
14 admin.is.allowed.to.deploy.anywhere 0 Error
15 admin.is.allowed.to.deploy.anywhere a Error
16 admin.is.allowed.to.deploy.anywhere FALSE Error
17 admin.is.allowed.to.deploy.anywhere TRUE Error
18 admin.is.allowed.to.deploy.anywhere true OK
19 admin.is.allowed.to.deploy.anywhere false OK

Test 12 was sucessful, but the number informed is bigger than the maximum value of Floats and Doubles. Double.parseDouble() returns Infinity if the number being parsed would overflow. We should not allow this config value, we should return an error, like what is done in test 4.

@winterhazel
Copy link
Member Author

Thanks for testing @JoaoJandre. I addressed the issue you pointed out.

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

@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 test result (tid-11158)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 53213 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9107-t11158-kvm-ol8.zip
Smoke tests completed. 137 look OK, 2 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_secure_vm_migration Error 135.45 test_vm_life_cycle.py
test_01_secure_vm_migration Error 135.45 test_vm_life_cycle.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL Failure 391.95 test_vpc_redundant.py
test_05_rvpc_multi_tiers Failure 487.68 test_vpc_redundant.py
test_05_rvpc_multi_tiers Error 487.70 test_vpc_redundant.py

@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-11181)

Copy link
Contributor

@JoaoJandre JoaoJandre left a comment

Choose a reason for hiding this comment

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

LGTM

@DaanHoogland
Copy link
Contributor

@blueorangutan LLtest

@blueorangutan
Copy link

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

@github-actions
Copy link

github-actions bot commented Sep 4, 2024

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

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

@JoaoJandre
Copy link
Contributor

Merging based on approvals and manual testing #9107 (comment)

@JoaoJandre JoaoJandre merged commit f156c4e into apache:main Sep 6, 2024
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 10, 2024
…pache#9107)

* Refactor type and range validation in configuration update process

* Update server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Co-authored-by: Henrique Sato <henriquesato2003@gmail.com>

* Remove duplicate imports

* Fix tests

* Address Joao's reviews

---------

Co-authored-by: Henrique Sato <henriquesato2003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants