Skip to content

realtime re-balance remote agents - #14001

Draft
DaanHoogland wants to merge 2 commits into
mainfrom
ghi9640-agent-lb-indirect-svm
Draft

DaanHoogland wants to merge 2 commits into
mainfrom
ghi9640-agent-lb-indirect-svm

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Description

This PR relates to agent rebalancing on MSses see #9640 but applies to atachees .

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?

verify(clusteredAgentManagerImpl).loadDirectlyConnectedHost(hostVO, false);
}

// https://github.com/apache/cloudstack/issues/9640

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.

Suggested change
// https://github.com/apache/cloudstack/issues/9640

Comment on lines +1042 to +1046
// Indirectly connected agents (KVM hosts, SSVM, CPVM) dial in to a management server rather
// than being loaded directly by it, so this management server can't hand the host to a
// specific future owner the way it can for direct agents. Disconnect it instead: the agent
// reconnects on its own using its indirect agent LB configuration (the "host" global setting
// and indirect.agent.lb.algorithm), which is what actually determines its next owner.

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.

evaluate and redact comment

Comment on lines +158 to +160
// Indirectly connected agents (KVM hosts, SSVM, CPVM) dial in to a management server rather than
// being loaded directly by it, so they must be disconnected (and left to reconnect on their own)
// instead of going through the direct-agent rebalance dance that expects a ClusteredDirectAgentAttache.

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.

Suggested change
// Indirectly connected agents (KVM hosts, SSVM, CPVM) dial in to a management server rather than
// being loaded directly by it, so they must be disconnected (and left to reconnect on their own)
// instead of going through the direct-agent rebalance dance that expects a ClusteredDirectAgentAttache.

Comment on lines +1040 to +1053
final AgentAttache attache = findAttache(hostId);
if (attache != null && !(attache instanceof ClusteredDirectAgentAttache)) {
// Indirectly connected agents (KVM hosts, SSVM, CPVM) dial in to a management server rather
// than being loaded directly by it, so this management server can't hand the host to a
// specific future owner the way it can for direct agents. Disconnect it instead: the agent
// reconnects on its own using its indirect agent LB configuration (the "host" global setting
// and indirect.agent.lb.algorithm), which is what actually determines its next owner.
logger.debug("Host id={} ({}) is an indirectly connected agent; disconnecting it so it reconnects and picks a management server " +
"using its own load balancing configuration", hostId, attache);
result = handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
finishRebalance(hostId, futureOwnerId, result ? Event.RebalanceCompleted : Event.RebalanceFailed);
return result;
}

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.

new method, move comment to javadoc

@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.46154% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.45%. Comparing base (a7a293e) to head (b925636).
⚠️ Report is 135 commits behind head on main.

Files with missing lines Patch % Lines
...cloud/agent/manager/ClusteredAgentManagerImpl.java 50.00% 3 Missing and 2 partials ⚠️
.../agentlb/ClusterBasedAgentLoadBalancerPlanner.java 0.00% 2 Missing ⚠️
...loud/cluster/agentlb/AgentLoadBalancerPlanner.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14001      +/-   ##
============================================
+ Coverage     19.73%   20.45%   +0.71%     
- Complexity    19955    21416    +1461     
============================================
  Files          6371     6488     +117     
  Lines        575784   589311   +13527     
  Branches      70478    72247    +1769     
============================================
+ Hits         113644   120517    +6873     
- Misses       449788   455664    +5876     
- Partials      12352    13130     +778     
Flag Coverage Δ
uitests 3.70% <ø> (+0.29%) ⬆️
unittests 21.75% <38.46%> (+0.73%) ⬆️

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.

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@nvazquez , can you have a look at this and discuss if needed?

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

Metric Value
Line coverage 25.49%
Branch coverage 19.79%

Grade Scale

Grade Line Coverage Meaning
🟢 A ≥ 80% Excellent - this code sleeps well at night 😴
🟡 B 60-79% Good - almost there, don't stop now 😉
🟠 C 40-59% Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D 20-39% Marginal - boldly shipping where no test has gone before 🖖
⛔ F < 20% Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

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: Ready

Development

Successfully merging this pull request may close these issues.

1 participant