You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/07/29 21:32:12 UTC
[17/31] git commit: give better error when ssh key with passphrase is
used
give better error when ssh key with passphrase is used
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/a7885b5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/a7885b5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/a7885b5f
Branch: refs/heads/master
Commit: a7885b5feaf20060187d38d2ac2de2f616004977
Parents: c4b2990
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Wed Jul 23 15:24:19 2014 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Jul 29 10:42:08 2014 -0400
----------------------------------------------------------------------
.../brooklyn/location/jclouds/JcloudsLocation.java | 9 +++++----
.../java/brooklyn/location/jclouds/JcloudsUtil.java | 13 ++++++++++++-
.../src/main/java/brooklyn/util/repeat/Repeater.java | 11 ++++++++---
3 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a7885b5f/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index e27e16c..1873244 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -110,6 +110,7 @@ import brooklyn.util.collections.MutableMap;
import brooklyn.util.config.ConfigBag;
import brooklyn.util.exceptions.CompoundRuntimeException;
import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.exceptions.ReferenceWithError;
import brooklyn.util.flags.SetFromFlag;
import brooklyn.util.flags.TypeCoercions;
import brooklyn.util.guava.Maybe;
@@ -1733,16 +1734,16 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
Stopwatch stopwatch = Stopwatch.createStarted();
- boolean reachable = new Repeater()
+ ReferenceWithError<Boolean> reachable = new Repeater()
.every(1,SECONDS)
.until(checker)
.limitTimeTo(delayMs, MILLISECONDS)
- .run();
+ .runKeepingError();
- if (!reachable) {
+ if (!reachable.getIgnoringError()) {
throw new IllegalStateException("SSH failed for "+
user+"@"+vmIp+" ("+setup.getDescription()+") after waiting "+
- Time.makeTimeStringRounded(delayMs));
+ Time.makeTimeStringRounded(delayMs), reachable.getError());
}
LOG.debug("VM {}: is sshable after {} on {}@{}",new Object[] {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a7885b5f/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java
index f3fdb34..2ac077e 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java
@@ -387,7 +387,18 @@ public class JcloudsUtil implements JcloudsLocationConfig {
// jclouds.ssh.max-retries
// jclouds.ssh.retry-auth
- final SshClient client = context.utils().sshForNode().apply(node);
+ SshClient client;
+ try {
+ client = context.utils().sshForNode().apply(node);
+ } catch (Exception e) {
+ /* i've seen: java.lang.IllegalStateException: Optional.get() cannot be called on an absent value
+ * from org.jclouds.crypto.ASN1Codec.createASN1Sequence(ASN1Codec.java:86), if the ssh key has a passphrase, against AWS.
+ *
+ * others have reported: java.lang.IllegalArgumentException: DER length more than 4 bytes
+ * when using a key with a passphrase (perhaps from other clouds?); not sure if that's this callpath or a different one.
+ */
+ throw new IllegalStateException("Unable to connect SshClient to "+node+"; check that the node is accessible and that the SSH key exists and is correctly configured, including any passphrase defined", e);
+ }
return client.getHostAddress();
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a7885b5f/utils/common/src/main/java/brooklyn/util/repeat/Repeater.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/repeat/Repeater.java b/utils/common/src/main/java/brooklyn/util/repeat/Repeater.java
index 71ca099..b2000fa 100644
--- a/utils/common/src/main/java/brooklyn/util/repeat/Repeater.java
+++ b/utils/common/src/main/java/brooklyn/util/repeat/Repeater.java
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.exceptions.ReferenceWithError;
import brooklyn.util.time.CountdownTimer;
import brooklyn.util.time.Duration;
import brooklyn.util.time.Time;
@@ -300,6 +301,10 @@ public class Repeater {
* @return true if the exit condition was satisfied; false if the loop terminated for any other reason.
*/
public boolean run() {
+ return runKeepingError().getIgnoringError();
+ }
+
+ public ReferenceWithError<Boolean> runKeepingError() {
Preconditions.checkState(body != null, "repeat() method has not been called to set the body");
Preconditions.checkState(exitCondition != null, "until() method has not been called to set the exit condition");
Preconditions.checkState(delayOnIteration != null, "every() method (or other delaySupplier() / backoff() method) has not been called to set the loop delay");
@@ -330,7 +335,7 @@ public class Repeater {
}
if (done) {
if (log.isDebugEnabled()) log.debug("{}: condition satisfied", description);
- return true;
+ return ReferenceWithError.newInstanceWithNoError(true);
} else {
if (log.isDebugEnabled()) {
String msg = String.format("%s: unsatisfied during iteration %s %s", description, iterations,
@@ -352,7 +357,7 @@ public class Repeater {
}
if (warnOnUnRethrownException && lastError != null)
log.warn("{}: error caught checking condition: {}", description, lastError.getMessage());
- return false;
+ return ReferenceWithError.newInstanceWithInformativeError(false, lastError);
}
if (timer.isExpired()) {
@@ -362,7 +367,7 @@ public class Repeater {
log.error("{}: error caught checking condition: {}", description, lastError.getMessage());
throw Exceptions.propagate(lastError);
}
- return false;
+ return ReferenceWithError.newInstanceWithInformativeError(false, lastError);
}
Time.sleep(delayThisIteration);