Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement retries using SSH Launcher retry feature. #149

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<version>1.6</version>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.nirima.jenkins.plugins.docker;

import com.google.common.base.Objects;
import hudson.model.*;
import hudson.model.Executor;
import hudson.model.Queue;
import hudson.model.Run;
import hudson.slaves.AbstractCloudComputer;

import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.common.base.Objects;

/**
* Created by magnayn on 09/01/2014.
*/
public class DockerComputer extends AbstractCloudComputer<DockerSlave> {
private static final Logger LOGGER = Logger.getLogger(DockerComputer.class.getName());

private int checked = 0;

public DockerComputer(DockerSlave dockerSlave) {
super(dockerSlave);
}
Expand Down Expand Up @@ -80,16 +81,9 @@ public boolean isAcceptingTasks() {
private void updateAcceptingTasks() {
try {
DockerSlave node = getNode();
int pause = 5000;
if( getOfflineCause() != null) {
if(getOfflineCause().toString().contains("failed to launch the slave agent") && checked < 3) {
LOGGER.log(Level.INFO, "Slave agent not launched after checking " + checked + " time(s). Waiting for any retries...");
checked += 1;
Thread.sleep(pause);
} else {
setAcceptingTasks(false);
LOGGER.log(Level.INFO, " Offline " + this + " due to " + getOfflineCause() );
}
setAcceptingTasks(false);
LOGGER.log(Level.INFO, " Offline " + this + " due to " + getOfflineCause());
} else if( !node.containerExistsInCloud() ) {
setAcceptingTasks(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static SSHLauncher getSSHLauncher(InspectContainerResponse detail, Docke

StandardUsernameCredentials credentials = SSHLauncher.lookupSystemCredentials(template.credentialsId);

return new SSHLauncher(host, port, credentials, template.jvmOptions , template.javaPath, template.prefixStartSlaveCmd, template.suffixStartSlaveCmd, template.getSSHLaunchTimeoutMinutes() * 60);
return new SSHLauncher(host, port, credentials, template.jvmOptions , template.javaPath, template.prefixStartSlaveCmd, template.suffixStartSlaveCmd, template.getSSHLaunchTimeoutMinutes() * 60,3,5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use spaces after coma


} catch(NullPointerException ex) {
throw new RuntimeException("No mapped port 22 in host for SSL. Config=" + detail);
Expand Down