Skip to content

Make AgentConnectTaskPool core and max pool sizes configurable via global config - #13552

Open
nvazquez wants to merge 3 commits into
apache:mainfrom
shapeblue:422-agent-connect-task-pool-configurations
Open

nvazquez wants to merge 3 commits into
apache:mainfrom
shapeblue:422-agent-connect-task-pool-configurations

Conversation

@nvazquez

@nvazquez nvazquez commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR replaces the hardcoded values of 100/500 in initConnectExecutor() with ConfigKeys:

  • agent.connect.executor.core.pool.size (default 100) and
  • agent.connect.executor.max.pool.size (default 500)

In case the pool size > max pool size, the default values 100/500 will be used to prevent exceptions on startup

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@nvazquez

nvazquez commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

codecov Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.78%. Comparing base (98b8f75) to head (a516920).

Files with missing lines Patch % Lines
...java/com/cloud/agent/manager/AgentManagerImpl.java 12.50% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #13552   +/-   ##
=========================================
  Coverage     20.78%   20.78%           
- Complexity    21941    21944    +3     
=========================================
  Files          6496     6496           
  Lines        591822   591837   +15     
  Branches      72615    72617    +2     
=========================================
+ Hits         123017   123028   +11     
- Misses       455450   455453    +3     
- Partials      13355    13356    +1     
Flag Coverage Δ
uitests 3.88% <ø> (ø)
unittests 22.09% <12.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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
Copy Markdown

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


private void initConnectExecutor() {
_connectExecutor = new ThreadPoolExecutor(100, 500, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("AgentConnectTaskPool"));
_connectExecutor = new ThreadPoolExecutor(AgentConnectExecutorCorePoolSize.value(), AgentConnectExecutorMaxPoolSize.value(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("AgentConnectTaskPool"));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why no validation here? If max ends up lower than core, this throws and crashes management server startup. Maybe clamp the values before use so a bad config doesn't break things.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @Damans227 - added a validation. Can you please review?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @nvazquez, looks good. One question: should the max check be agentConnectMaxSize <= 0? ThreadPoolExecutor requires max to be strictly positive, so setting both keys to 0 passes validation but still throws at startup.

@vladimirpetrov vladimirpetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM based on manual testing. Tested with simultaneously restarting all the agents, which are more than the max pool size.

@vladimirpetrov

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@vladimirpetrov a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16525)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 56284 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13552-t16525-kvm-ol8.zip
Smoke tests completed. 148 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_upgrade_kubernetes_cluster Failure 581.82 test_kubernetes_clusters.py

@nvazquez
nvazquez requested a review from Damans227 July 15, 2026 00:22
@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez 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
Copy Markdown

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

@vladimirpetrov

Copy link
Copy Markdown
Contributor

@blueorangutan test

@vladimirpetrov vladimirpetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, tested with core > max and invalid values.

@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16578)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 51192 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13552-t16578-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Pair<Integer, Integer> poolSizeValues = retrieveAgentConnectPoolCoreSizeAndMaxSize();
_connectExecutor = new ThreadPoolExecutor(poolSizeValues.first(), poolSizeValues.second(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("AgentConnectTaskPool"));
// allow core threads to time out even when there are no items in the queue
_connectExecutor.allowCoreThreadTimeOut(true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same issue as before, just with 0 instead of max<core: agentConnectMaxSize < 0 lets 0 through, but ThreadPoolExecutor needs max strictly positive. So core=0, max=0 still passes validation and crashes at startup. Should this be <= 0?

@DaanHoogland DaanHoogland moved this from Backlog to In review in CloudStack Testing Sep 1, 2026
@nvazquez nvazquez modified the milestones: 4.22.2, 4.22.3 Nov 9, 2026
sachindoddaguni and others added 3 commits November 9, 2026 23:52
…obal config (apache#839)

Replaces hardcoded values of 100/500 in initConnectExecutor() with ConfigKeys
agent.connect.executor.core.pool.size (default 100) and
agent.connect.executor.max.pool.size (default 500).
@nvazquez
nvazquez force-pushed the 422-agent-connect-task-pool-configurations branch from f4ec900 to a516920 Compare November 10, 2026 02:53
@nvazquez
nvazquez changed the base branch from 4.22 to main November 10, 2026 02:53
@nvazquez nvazquez modified the milestones: 4.22.3, 24.0 Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

6 participants