Skip to content

Commit d032a53

Browse files
mprokopchuksureshanaparti
authored andcommitted
Indirect agent connection improvements, includes the following improvements.
- Enhances the Host connecting logic to avoid connecting storm (where Agent opens multiple sockets against Management Server). - Implements HostConnectProcess task where Host upon connection checks whether lock is available, traces Host connecting progress, status and timeout. - Introduces AgentConnectStatusCommand, where Host checks whether lock for the Host is available (i.e. "previous" connect process is finished). - Implementes logic to check whether Management Server has lock against Host (exposed MySQL DB lock presence via API) - Removes synchronization on Host disconnect process, double-disconnect logic in clustered Management Server environment, added early removal from ping map (in case of combination ping timeout delay + synchronized disconnect process the Agent Manager submits more disconnect requests) - Introduces parameterized connection and status check timeouts - Implements backoff algorithm abstraction - can be used either constant backoff timeout or exponential with jitter to wait between connection Host attempts to Management Server - Implements ServerAttache to be used on the Agent side of communication (similar to Attache on Management Server side) - Enhances/Adds logs significantly to Host Agent and Agent Manager logic to trace Host connecting and disconnecting process, including ids, names, context UUIDs and timings (how much time took overall initialization/deinitialization) - Adds logs to communication between Management Servers (PDU requests) - Adds DB indexes to improve search performance, uses IDEMPOTENT_ADD_INDEX for safer DB schema updates
1 parent 82bfa9f commit d032a53

File tree

47 files changed

+4106
-778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4106
-778
lines changed

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 544 additions & 266 deletions
Large diffs are not rendered by default.

agent/src/main/java/com/cloud/agent/AgentShell.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import javax.naming.ConfigurationException;
3434

35+
import com.cloud.utils.backoff.BackoffFactory;
3536
import org.apache.commons.daemon.Daemon;
3637
import org.apache.commons.daemon.DaemonContext;
3738
import org.apache.commons.daemon.DaemonInitException;
@@ -52,7 +53,6 @@
5253
import com.cloud.utils.ProcessUtil;
5354
import com.cloud.utils.PropertiesUtil;
5455
import com.cloud.utils.backoff.BackoffAlgorithm;
55-
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
5656
import com.cloud.utils.exception.CloudRuntimeException;
5757

5858
public class AgentShell implements IAgentShell, Daemon {
@@ -95,6 +95,16 @@ public BackoffAlgorithm getBackoffAlgorithm() {
9595
return _backoff;
9696
}
9797

98+
@Override
99+
public void setBackoffAlgorithm(BackoffAlgorithm backoffAlgorithm) {
100+
this._backoff = backoffAlgorithm;
101+
try {
102+
backoffAlgorithm.getConfiguration().forEach((key, value) -> setPersistentProperty(null, key, value));
103+
} catch (RuntimeException e) {
104+
LOGGER.warn("Failed to persist backoff properties");
105+
}
106+
}
107+
98108
@Override
99109
public int getPingRetries() {
100110
return _pingRetries;
@@ -400,7 +410,7 @@ public void init(String[] args) throws ConfigurationException {
400410
final Class<?> c = this.getClass();
401411
_version = c.getPackage().getImplementationVersion();
402412
if (_version == null) {
403-
throw new CloudRuntimeException("Unable to find the implementation version of this agent");
413+
_version = "unknown";
404414
}
405415
LOGGER.info("Implementation Version is {}", _version);
406416

@@ -410,7 +420,7 @@ public void init(String[] args) throws ConfigurationException {
410420
if (LOGGER.isDebugEnabled()) {
411421
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
412422
for (String property : properties) {
413-
LOGGER.debug("Found property: {}", property);
423+
LOGGER.debug("Found property: {}, value: {}", property, _properties.getProperty(property));
414424
}
415425
}
416426

@@ -424,11 +434,15 @@ public void init(String[] args) throws ConfigurationException {
424434
_properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
425435
}
426436

427-
LOGGER.info("Defaulting to the constant time backoff algorithm");
428-
_backoff = new ConstantTimeBackoff();
429-
Map<String, Object> map = new HashMap<>();
430-
map.put("seconds", _properties.getProperty("backoff.seconds"));
431-
_backoff.configure("ConstantTimeBackoff", map);
437+
try {
438+
LOGGER.info("Creating backoff delay algorithm implementation");
439+
setBackoffAlgorithm(BackoffFactory.create(_properties));
440+
LOGGER.info("Created {} delay algorithm implementation", getBackoffAlgorithm().getClass().getName());
441+
} catch (RuntimeException e) {
442+
String msg = String.format("Failed to create backoff with provided properties %s, failing back to default", _properties);
443+
LOGGER.warn(msg, e);
444+
setBackoffAlgorithm(BackoffFactory.createDefault(_properties));
445+
}
432446
}
433447

434448
private void launchAgent() throws ConfigurationException {
@@ -546,7 +560,7 @@ public void start() {
546560
}
547561

548562
} catch (final Exception e) {
549-
LOGGER.error("Unable to start agent: ", e);
563+
LOGGER.error("Unable to start agent: {}", e.getLocalizedMessage(), e);
550564
System.exit(ExitStatus.Error.value());
551565
}
552566
}
@@ -568,6 +582,7 @@ public static void main(String[] args) {
568582
shell.init(args);
569583
shell.start();
570584
} catch (ConfigurationException e) {
585+
LOGGER.fatal(e.getMessage(), e);
571586
System.out.println(e.getMessage());
572587
}
573588
}

0 commit comments

Comments
 (0)