martinfr62 commented on Bug JENKINS-26854

Okay - here's what i did in patch form against the pull 131 (so includes your Ximon).

Removed the transient connection object and created a new one every time in connect() and then updated/added some more logging so i could tell when the terminate was about to fire. I also found a typo in the log by doing this in EC2RetentionStrategy - was treating freeSecondsLeft as milliseconds - not seconds - so fixed that also.


src/main/java/hudson/plugins/ec2/EC2Cloud.java | 9 +++++----
src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java | 6 +++++-
2 files changed, 10 insertions, 5 deletions

diff --git a/src/main/java/hudson/plugins/ec2/EC2Cloud.java b/src/main/java/hudson/plugins/ec2/EC2Cloud.java
index 8891999..ca102e6 100644
— a/src/main/java/hudson/plugins/ec2/EC2Cloud.java
+++ b/src/main/java/hudson/plugins/ec2/EC2Cloud.java
@@ -113,7 +113,7 @@ public abstract class EC2Cloud extends Cloud {
private final List<? extends SlaveTemplate> templates;
private transient KeyPair usableKeyPair;

  • protected transient AmazonEC2 connection;
    + // protected transient AmazonEC2 connection;

private static AWSCredentialsProvider awsCredentialsProvider;

@@ -460,9 +460,9 @@ public abstract class EC2Cloud extends Cloud {
*/
public synchronized AmazonEC2 connect() throws AmazonClientException {
try {

  • if (connection == null) { - connection = connect(createCredentialsProvider(), getEc2EndpointUrl()); - }
    + // if (connection == null) { + AmazonEC2 connection = connect(createCredentialsProvider(), getEc2EndpointUrl()); + // }
    return connection;
    } catch (IOException e) {
    throw new AmazonClientException("Failed to retrieve the endpoint",e);
    @@ -476,6 +476,7 @@ public abstract class EC2Cloud extends Cloud {
    public synchronized static AmazonEC2 connect(AWSCredentialsProvider credentialsProvider, URL endpoint) {
    awsCredentialsProvider = credentialsProvider;
    ClientConfiguration config = new ClientConfiguration();
    + config.setSignerOverride("QueryStringSignerType");
    ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
    Proxy proxy = proxyConfig == null ? Proxy.NO_PROXY : proxyConfig.createProxy(endpoint.getHost());
    if (! proxy.equals(Proxy.NO_PROXY) && proxy.address() instanceof InetSocketAddress) {
    diff --git a/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java b/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java
    index 22e185a..52d8f49 100644
      • a/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java
        +++ b/src/main/java/hudson/plugins/ec2/EC2RetentionStrategy.java
        @@ -94,6 +94,8 @@ public class EC2RetentionStrategy extends RetentionStrategy<EC2Computer> {
        final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
        if (idleTerminationMinutes > 0) {
        // TODO: really think about the right strategy here, see JENKINS-23792
        + LOGGER.fine("Test Idle timeout of "+c.getName() + " after " + TimeUnit2.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes");
        +
        if (idleMilliseconds > TimeUnit2.MINUTES.toMillis(idleTerminationMinutes)) {
        LOGGER.info("Idle timeout of "+c.getName() + " after " + TimeUnit2.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes");
        c.getNode().idleTimeout();
        @@ -110,8 +112,10 @@ public class EC2RetentionStrategy extends RetentionStrategy<EC2Computer>
        Unknown macro: { final int freeSecondsLeft = (60*60) - (int)(TimeUnit2.SECONDS.convert(uptime, TimeUnit2.MILLISECONDS) % (60*60)); // if we have less "free" (aka already paid for) time left than our idle time, stop/terminate the instance // See JENKINS-23821+ LOGGER.fine("Test Idle timeout of "+c.getName()+" after " + TimeUnit2.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, with " + TimeUnit2.SECONDS.toMinutes(freeSecondsLeft) + " minutes remaining in billing period");+ if (freeSecondsLeft <= (Math.abs(idleTerminationMinutes*60))) { - LOGGER.info("Idle timeout of "+c.getName()+" after " + TimeUnit2.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, with " + TimeUnit2.MILLISECONDS.toMinutes(freeSecondsLeft) + " minutes remaining in billing period"); + LOGGER.info("Idle timeout of "+c.getName()+" after " + TimeUnit2.MILLISECONDS.toMinutes(idleMilliseconds) + " idle minutes, with " + TimeUnit2.SECONDS.toMinutes(freeSecondsLeft) + " minutes remaining in billing period"); c.getNode().idleTimeout(); } }

    • 1.9.4.msysgit.2
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to