Repository navigation
Conversation
An agent whose only configured management server is in its avoid list never tries to reconnect: Agent.reconnect() skips every host in the avoid list, sleeps and picks the same host again, forever, without logging anything (apache#10915). The avoid list comes with every ping answer from ManagementServerHostDaoImpl.listNonUpStateMsIPs(), the service IPs of all management servers that are not Up. A management server that is not Up can share its service IP with one that is Up, for example after a management server was re-installed with a new msid on the same address, or when management servers share an address. The agents then avoid the management server they are connected to and do not come back after the next disconnect. - listNonUpStateMsIPs() no longer returns an address an Up management server uses. - When every configured management server is in the avoid list, the agent ignores the avoid list for that reconnect, and it logs a host it skips because it is in the avoid list. Fixes apache#10915 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes agents that never reconnect after their connection to the management server drops, when the address they connect to is in their avoid list (#10915).
Agent.reconnect()skips every host that is in the avoid list. When every configured host is in it — for examplehost=<one address>— it sleeps and picks the same host again, forever, without logging anything; the agent stays Disconnected until it is restarted.The avoid list comes with every ping answer:
ManagementServerHostDaoImpl.listNonUpStateMsIPs(), the service IPs of all management servers that are notUp. A management server that is notUpcan share its service IP with one that isUp— a management server re-installed with a new msid on the same address, or management servers sharing an address — so the agents are told to avoid the management server they are connected to.Changes:
listNonUpStateMsIPs()no longer returns an address that anUpmanagement server uses.Agent.reconnect(): when every configured management server is in the avoid list, the avoid list is ignored for that reconnect (WARN logged), and a host skipped because it is in the avoid list is logged at INFO. This also covers the graceful-shutdown case described in [4.21/main] CloudStack agent does not reconnect to management server #10915.Fixes: #10915
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests (JDK 17, Maven 3.9.16,
mvn -B -T 32 -Dnoredist -pl agent,framework/cluster -am -Dtest="AgentTest,AgentShellTest,ManagementServerHostDaoImplTest,ClusterManagerImplTest" -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false install, BUILD SUCCESS, 0 checkstyle violations):ManagementServerHostDaoImplTest— 3/3: excludes addresses of Up management servers; keeps addresses no Up server uses; does not query Up servers when all are Up.AgentTest— 26/26, 3 new: avoid list ignored when it holds every configured host (and the WARN is logged); kept when another host is available; no avoid list.AgentShellTest24/24,ClusterManagerImplTest1/1.4.23.0.0builds and passesAgentTest26/26 andManagementServerHostDaoImplTest3/3.On a real cluster (CloudStack 4.23.0.0 RPMs, AlmaLinux 10.3, one management server, four KVM hosts, LINSTOR primary storage). The patched classes were built from this commit cherry-picked onto
4.23.0.0and swapped intocloud-agent-4.23.0.0.jar/cloudstack-4.23.0.0.jar. Setup: the management server'scluster.node.IPis the address in thehostsetting (the agents' only management server). Each scenario: insert a secondmshostrow in stateDownwith that service IP (what a management server re-installed with a new msid on the same address leaves behind), wait one ping round, then cut the agents' connections to 8250 withss -K.Lost connection to host: … Attempting reconnection while we still have 0 commands in progress.and nothing afterWARN … All configured management servers [10.20.20.80] are in the avoid list [10.20.20.80], ignoring the avoid list to reconnect→Reconnecting to host→Connected to the hostsystemctl restart cloudstack-management(the case in #10915)We first hit this with three management servers behind one virtual IP (one active at a time) where every server had the VIP as
cluster.node.IP: after the active server's node was powered off, the agents on the surviving hosts stayed Disconnected for 18 minutes until restarted (thread dump in #10915).How did you try to break this feature and the system with this change?
ManagementServerHostDaoImplTest; only addresses that anUpserver also uses are dropped).🤖 Generated with Claude Code