Author: asavu
Date: Thu Nov 10 11:25:45 2011
New Revision: 1200272
URL: http://svn.apache.org/viewvc?rev=1200272&view=rev
Log:
WHIRR-414. Wirr can have a non-zero return code and unterminated (orphaned)
host instances (David Alves and asavu)
Modified:
whirr/trunk/CHANGES.txt
whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java
whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
whirr/trunk/src/site/xdoc/configuration-guide.xml
Modified: whirr/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1200272&r1=1200271&r2=1200272&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Thu Nov 10 11:25:45 2011
@@ -77,6 +77,9 @@ Trunk (unreleased changes)
WHIRR-408. Upgrade elasticsearch to 0.18.2 (asavu)
+ WHIRR-414. Wirr can have a non-zero return code and unterminated
+ (orphaned) host instances (David Alves and asavu)
+
BUG FIXES
WHIRR-377. Fix broken CLI logging config. (asavu via tomwhite)
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java?rev=1200272&r1=1200271&r2=1200272&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/ClusterController.java Thu
Nov 10 11:25:45 2011
@@ -99,18 +99,31 @@ public class ClusterController {
*/
public Cluster launchCluster(ClusterSpec clusterSpec)
throws IOException, InterruptedException {
-
- Map<String, ClusterActionHandler> handlerMap = new
HandlerMapFactory().create();
+ try {
+ Map<String, ClusterActionHandler> handlerMap =
HandlerMapFactory.create();
+
+ BootstrapClusterAction bootstrapper = new
BootstrapClusterAction(getCompute(), handlerMap);
+ Cluster cluster = bootstrapper.execute(clusterSpec, null);
+
+ ConfigureClusterAction configurer = new
ConfigureClusterAction(getCompute(), handlerMap);
+ cluster = configurer.execute(clusterSpec, cluster);
- BootstrapClusterAction bootstrapper = new
BootstrapClusterAction(getCompute(), handlerMap);
- Cluster cluster = bootstrapper.execute(clusterSpec, null);
+ getClusterStateStore(clusterSpec).save(cluster);
+ return cluster;
- ConfigureClusterAction configurer = new
ConfigureClusterAction(getCompute(), handlerMap);
- cluster = configurer.execute(clusterSpec, cluster);
+ } catch(Throwable e) {
- getClusterStateStore(clusterSpec).save(cluster);
+ if (clusterSpec.isTerminateAllOnLaunchFailure()) {
+ LOG.error("Unable to start the cluster. Terminating all nodes.", e);
+ destroyCluster(clusterSpec);
- return cluster;
+ } else {
+ LOG.error("*CRITICAL* the cluster failed to launch and the automated
node termination" +
+ " option was not selected, there might be orphaned nodes.", e);
+ }
+
+ throw new RuntimeException(e);
+ }
}
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
URL:
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java?rev=1200272&r1=1200271&r2=1200272&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java Thu Nov 10
11:25:45 2011
@@ -158,7 +158,10 @@ public class ClusterSpec {
VERSION(String.class, false, ""),
RUN_URL_BASE(String.class, false, "The base URL for forming run " +
- "urls from. Change this to host your own set of launch scripts.");
+ "urls from. Change this to host your own set of launch scripts."),
+
+ TERMINATE_ALL_ON_LAUNCH_FAILURE(Boolean.class, false, "Whether or not to "
+
+ "automatically terminate all nodes when cluster launch fails for some
reason.");
private Class<?> type;
private boolean multipleArguments;
@@ -273,6 +276,8 @@ public class ClusterSpec {
private String version;
private String runUrlBase;
+
+ private boolean terminateAllOnLaunchFailure;
private Configuration config;
@@ -330,6 +335,9 @@ public class ClusterSpec {
setBlobStoreLocationId(getString(Property.BLOBSTORE_LOCATION_ID));
setClientCidrs(getList(Property.CLIENT_CIDRS));
+ setTerminateAllOnLaunchFailure(config.getBoolean(
+ Property.TERMINATE_ALL_ON_LAUNCH_FAILURE.getConfigName(),
Boolean.TRUE));
+
Map<String, List<String>> fr = new HashMap<String, List<String>>();
String firewallPrefix = Property.FIREWALL_RULES.getConfigName();
Pattern firewallRuleKeyPattern =
Pattern.compile("^".concat(Pattern.quote(firewallPrefix).concat("(?:\\.(.+))?$")));
@@ -391,6 +399,8 @@ public class ClusterSpec {
r.setVersion(getVersion());
r.setRunUrlBase(getRunUrlBase());
+
+ r.setTerminateAllOnLaunchFailure(isTerminateAllOnLaunchFailure());
return r;
}
@@ -704,6 +714,13 @@ public class ClusterSpec {
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
+
+ public boolean isTerminateAllOnLaunchFailure() {
+ return terminateAllOnLaunchFailure;
+ }
+ public void setTerminateAllOnLaunchFailure(boolean
terminateAllOnLaunchFailure) {
+ this.terminateAllOnLaunchFailure = terminateAllOnLaunchFailure;
+ }
/**
* The rsa public key which is authorized to login to your on the cloud
nodes.
@@ -943,6 +960,7 @@ public class ClusterSpec {
.add("stateStoreContainer", getStateStoreContainer())
.add("stateStoreBlob", getStateStoreBlob())
.add("awsEc2SpotPrice", getAwsEc2SpotPrice())
+ .add("terminateAllOnLauchFailure",isTerminateAllOnLaunchFailure())
.toString();
}
}
Modified: whirr/trunk/src/site/xdoc/configuration-guide.xml
URL:
http://svn.apache.org/viewvc/whirr/trunk/src/site/xdoc/configuration-guide.xml?rev=1200272&r1=1200271&r2=1200272&view=diff
==============================================================================
--- whirr/trunk/src/site/xdoc/configuration-guide.xml (original)
+++ whirr/trunk/src/site/xdoc/configuration-guide.xml Thu Nov 10 11:25:45 2011
@@ -77,6 +77,17 @@ xsi:schemaLocation="http://maven.apache.
<tt>hadoopcluster</tt>. The cluster name is used to tag the instances
in some
cloud-specific way. For example, in Amazon it is used to form the
security group name.</td>
</tr>
+ <tr valign="top">
+ <td>
+ <tt>whirr.terminate-all-on-launch-failure</tt>
+ </td>
+ <td>
+ <tt>--terminate-all-on-launch-failure</tt>
+ </td>
+ <td>true</td>
+ <td>Whether or not to automatically terminate all nodes when cluster
+ launch fails for some reason.</td>
+ </tr>
</table>
<subsection name="Instance Templates Options"></subsection>
<table border="0">
@@ -725,7 +736,7 @@ xsi:schemaLocation="http://maven.apache.
<td>
<tt>boolean</tt>
</td>
- <td>Wether jclouds should retry ssh actions on authentication failed
errors.</td>
+ <td>Whether jclouds should retry ssh actions on authentication failed
errors.</td>
</tr>
<tr valign="top">
<td>