Skip to content

Add limit configuration for number of projects#9172

Merged
DaanHoogland merged 6 commits intoapache:mainfrom
my-code-AL:add-limit-configuration-for-number-of-projects
Jul 15, 2024
Merged

Add limit configuration for number of projects#9172
DaanHoogland merged 6 commits intoapache:mainfrom
my-code-AL:add-limit-configuration-for-number-of-projects

Conversation

@my-code-AL
Copy link
Contributor

Description

The following PR creates a new feature of adding a limit to the number of projects of accounts within a singular domain. This helps administrators organize resources.

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

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

Screenshot 2024-06-04 at 7 04 04 PM

How Has This Been Tested?

The following issue has been tested with several mocked test cases that specify domain max projects and account max projects with valid and invalid inputs. Finally, the UI has been verified using a local linux environment; see above image in screenshots.

@codecov
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 15.53%. Comparing base (4079906) to head (241520c).
Report is 1 commits behind head on main.

Files Patch % Lines
.../cloud/resourcelimit/ResourceLimitManagerImpl.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##               main    #9172     +/-   ##
===========================================
  Coverage     15.53%   15.53%             
+ Complexity    11968    11967      -1     
===========================================
  Files          5492     5492             
  Lines        480947   480953      +6     
  Branches      62483    59152   -3331     
===========================================
+ Hits          74726    74729      +3     
- Misses       397960   397963      +3     
  Partials       8261     8261             
Flag Coverage Δ
uitests 4.16% <ø> (ø)
unittests 16.30% <66.66%> (+<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.

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 needs testing. is there a issue related to this? I remember such a thing. If we find it let's link it.

Assert.assertEquals(defaultAccountCpuMax, result);
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

this test has several calls into the code and asserts in between. Do you think it can be split in separate test cases?

"200",
"The default maximum primary storage space (in GiB) that can be used for an account",
null),
DefaultMaxAccountProjects(
Copy link
Contributor

Choose a reason for hiding this comment

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

adding the config here is a bit of a deprecated way of doing these. Have a look at ConfigKey<> for the prefered way.
Define a ConfigKey<> in a manager implementation or a service interface and then add the configKey to the return of the getConfirKeys() in the manager. You can then use the value more dynamically and it doesn't have to be preloaded in the config method.

I understand you are just following the convention you see in the files you are changing but still,...

DefaultMaxDomainMemory("Domain Defaults", ManagementServer.class, Long.class, "max.domain.memory", "81920", "The default maximum memory (in MB) that can be used for a domain", null),
DefaultMaxDomainPrimaryStorage("Domain Defaults", ManagementServer.class, Long.class, "max.domain.primary.storage", "400", "The default maximum primary storage space (in GiB) that can be used for a domain", null),
DefaultMaxDomainSecondaryStorage("Domain Defaults", ManagementServer.class, Long.class, "max.domain.secondary.storage", "800", "The default maximum secondary storage space (in GiB) that can be used for a domain", null),
DefaultMaxDomainProjects("Domain Defaults",ManagementServer.class,Long.class,"max.domain.projects","50","The default maximum number of projects that can be created for a domain",null),
Copy link
Contributor

Choose a reason for hiding this comment

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

see above

Assert.assertEquals(defaultDomainCpuMax, result);
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

again, can this test case be split?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alrighty, I was able to do the changes as you described. Please let me know if there is anything else I can do.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, this one looks good, not sure if the build failures are related.

@my-code-AL my-code-AL force-pushed the add-limit-configuration-for-number-of-projects branch from 11aecf4 to 86746b0 Compare June 7, 2024 19:51
@borisstoyanov
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@borisstoyanov 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 9835

Copy link
Contributor

@borisstoyanov borisstoyanov left a comment

Choose a reason for hiding this comment

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

@my-code-AL hi, thanks for this PR, there seems to be a problem with the unit tests


10:19:49 [INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.251 s - in org.apache.cloudstack.affinity.AffinityGroupServiceImplTest
10:19:49 [INFO] 
10:19:50 [INFO] Results:
10:19:50 [INFO] 
10:19:50 [ERROR] Errors: 
10:19:50 [ERROR]   ResourceLimitManagerImplTest.unnecessary Mockito stubbings ? UnnecessaryStubbing
10:19:50 [INFO] 
10:19:50 [ERROR] Tests run: 1885, Failures: 0, Errors: 1, Skipped: 6
10:19:50 [INFO] 
10:19:50 [INFO] ------------------------------------------------------------------------
10:19:50 [INFO] Reactor Summary for Apache CloudStack 4.20.0.0-SNAPSHOT:

Can you please look into this?

@borisstoyanov borisstoyanov self-assigned this Jun 12, 2024
Copy link
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

LGTM - this needs additional review/testing, and check if it needs any Marvin tests?

@DaanHoogland
Copy link
Contributor

@my-code-AL can you look at the unit tests @borisstoyanov pointed at?

@my-code-AL
Copy link
Contributor Author

@DaanHoogland Will do! I've been busy at work but will fix soon!

@my-code-AL
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@my-code-AL 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.

@my-code-AL my-code-AL requested a review from borisstoyanov July 12, 2024 01:20
@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland 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 10337

@DaanHoogland
Copy link
Contributor

@blueorangutan LLtest alma9 kvm-alma9 keepEnv

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[LL]Trillian test result (tid-6953)
Environment: kvm-alma9 (x2), Advanced Networking with Mgmt server a9
Total time taken: 50617 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9172-t6953-kvm-alma9.zip
Smoke tests completed. 134 look OK, 3 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestClusterDRS>:setup Error 0.00 test_cluster_drs.py
test_01_invalid_upgrade_kubernetes_cluster Failure 0.01 test_kubernetes_clusters.py
test_02_upgrade_kubernetes_cluster Failure 0.00 test_kubernetes_clusters.py
test_03_deploy_and_scale_kubernetes_cluster Failure 0.00 test_kubernetes_clusters.py
test_04_autoscale_kubernetes_cluster Failure 0.00 test_kubernetes_clusters.py
test_05_basic_lifecycle_kubernetes_cluster Failure 0.00 test_kubernetes_clusters.py
test_06_delete_kubernetes_cluster Failure 0.00 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 0.00 test_kubernetes_clusters.py
test_10_vpc_tier_kubernetes_cluster Failure 0.00 test_kubernetes_clusters.py
test_11_test_unmanaged_cluster_lifecycle Error 0.00 test_kubernetes_clusters.py
test_06_purge_expunged_vm_background_task Failure 377.98 test_purge_expunged_vms.py

@DaanHoogland
Copy link
Contributor

setting the limit to 1 an error occurs on creating the second:
image

after deleting the first prj the second gets created.

setting for a domain to two
image

a second user can create their own prj:
image

good work @my-code-AL , totally out of scope but I was wondering if there is any reason this setting is not dynamic (i.e. can be changed without restart) work for another day maybe ;)

@DaanHoogland DaanHoogland merged commit afdf4d7 into apache:main Jul 15, 2024
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 15, 2024

Awesome work, congrats on your first merged pull request!

@my-code-AL
Copy link
Contributor Author

my-code-AL commented Jul 16, 2024

Will do! Thank you for your help and patience!

dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jul 23, 2024
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.

Add limit configuration for number of projects per domain/account and add UI function for configuring limits

5 participants