Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> 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));

}

/**
Expand Down