Skip to content

Commit 124da2b

Browse files
Improve error logging
1 parent ee99263 commit 124da2b

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,8 @@ protected int getTimeoutFromGranularWaitTime(final Commands commands) {
458458
private void initializeCommandTimeouts() {
459459
String commandWaits = GranularWaitTimeForCommands.value().trim();
460460
if (StringUtils.isNotEmpty(commandWaits)) {
461-
try {
462-
_commandTimeouts = getCommandTimeoutsMap(commandWaits);
463-
logger.info(String.format("Timeouts for management server internal commands successfully initialized from global setting commands.timeout: %s", _commandTimeouts));
464-
} catch (Exception e) {
465-
logger.error("Error initializing command timeouts map: " + e.getMessage());
466-
_commandTimeouts = new HashMap<>();
467-
}
461+
_commandTimeouts = getCommandTimeoutsMap(commandWaits);
462+
logger.info(String.format("Timeouts for management server internal commands successfully initialized from global setting commands.timeout: %s", _commandTimeouts));
468463
}
469464
}
470465

@@ -475,11 +470,15 @@ private Map<String, Integer> getCommandTimeoutsMap(String commandWaits) {
475470
for (String commandPair : commandPairs) {
476471
String[] parts = commandPair.trim().split("=");
477472
if (parts.length == 2) {
478-
String commandName = parts[0].trim();
479-
int commandTimeout = Integer.parseInt(parts[1].trim());
480-
commandTimeouts.put(commandName, commandTimeout);
473+
try {
474+
String commandName = parts[0].trim();
475+
int commandTimeout = Integer.parseInt(parts[1].trim());
476+
commandTimeouts.put(commandName, commandTimeout);
477+
} catch (NumberFormatException e) {
478+
logger.error(String.format("Initialising the timeouts using commands.timeout: %s for management server internal commands failed with error %s", commandPair, e.getMessage()));
479+
}
481480
} else {
482-
logger.warn(String.format("Invalid format in commands.timeout global setting: %s", commandPair));
481+
logger.error(String.format("Error initialising the timeouts for management server internal commands. Invalid format in commands.timeout: %s", commandPair));
483482
}
484483
}
485484
return commandTimeouts;

0 commit comments

Comments
 (0)