diff --git a/concourse-automation/src/main/java/com/cinchapi/concourse/automation/server/ManagedConcourseServer.java b/concourse-automation/src/main/java/com/cinchapi/concourse/automation/server/ManagedConcourseServer.java index b0a52092f..9e652db31 100644 --- a/concourse-automation/src/main/java/com/cinchapi/concourse/automation/server/ManagedConcourseServer.java +++ b/concourse-automation/src/main/java/com/cinchapi/concourse/automation/server/ManagedConcourseServer.java @@ -690,22 +690,53 @@ public boolean hasWritesToTransport(String environment) { /** * Install the plugin(s) contained in the {@code bundle} on this * {@link ManagedConcourseServer}. - * + * * @param bundle the path to the plugin bundle * @return {@code true} if the plugin(s) from the bundle is/are installed */ public boolean installPlugin(Path bundle) { log.info("Attempting to install plugins from {}", bundle); - List out = executeCli("plugin", "install", bundle.toString(), - "--username admin", "--password admin"); - for (String line : out) { - if(line.contains("Successfully installed")) { - return true; + int maxAttempts = 10; + long waitMs = 500; + List out = null; + + for (int attempt = 1; attempt <= maxAttempts; attempt++) { + out = executeCli("plugin", "install", bundle.toString(), + "--username admin", "--password admin"); + + boolean managementServerNotReady = false; + for (String line : out) { + if(line.contains("Successfully installed")) { + return true; + } + if(line.contains( + "Could not connect to the management server")) { + managementServerNotReady = true; + } + } + + if(managementServerNotReady && attempt < maxAttempts) { + log.debug( + "Management server not ready, waiting {}ms before retry (attempt {}/{})", + waitMs, attempt, maxAttempts); + try { + Thread.sleep(waitMs); + waitMs = Math.min(waitMs * 2, 5000); // exponential backoff, + // max 5 seconds + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + break; + } + continue; } + + // Not a management server issue, break and throw + break; } + throw new RuntimeException(AnyStrings .format("Unable to install plugin '{}': {}", bundle, out)); - } /**