Skip to content
This repository
Browse code

Try to stop all instances when running nimbus-admin --shutdown --all

Corrupted instances have shutdown capabilities disabled.  When
--shutdown --all is called, it would stop at the first Corrupted
instance with the following message:

    RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: Shutdown is currently disabled

Catch the exception and continue to the next instance.  A warning is
printing in the logs and a message is returned to the user.

Also add a --force argument to nimbus-admin to activate the trash
operation for instances that didn't shut down properly.
  • Loading branch information...
commit 7b09b7be7110080d474301379a448390efa89686 1 parent 898ea3f
Pierre Riteau priteau authored
2  service-api/java/source/src/org/nimbustools/api/services/admin/RemoteAdminToolsManagement.java
@@ -51,6 +51,6 @@
51 51 public String getAllVMsByGroupName(String groupName) throws RemoteException;
52 52 public String getVMsByState(String state) throws RemoteException;
53 53 public Hashtable<String, String[]> showVMsForAllHosts() throws RemoteException;
54   - public String shutdown(int type, String typeID, String seconds) throws RemoteException;
  54 + public String shutdown(int type, String typeID, String seconds, boolean force) throws RemoteException;
55 55 public String cleanup(int type, String typeID) throws RemoteException;
56 56 }
7 service/service/java/source/src/org/globus/workspace/remoting/admin/client/Opts.java
@@ -52,6 +52,11 @@ public Options getOptions() {
52 52 public final Option CONFIG_OPT =
53 53 OptionBuilder.withLongOpt(CONFIG_LONG).hasArg().create(CONFIG);
54 54
  55 + public static final String FORCE = "f";
  56 + public static final String FORCE_LONG = "force";
  57 + public final Option FORCE_OPT =
  58 + OptionBuilder.withLongOpt(FORCE_LONG).create(FORCE);
  59 +
55 60 public static final String BATCH = "b";
56 61 public static final String BATCH_LONG = "batch";
57 62 public final Option BATCH_OPT =
@@ -218,7 +223,7 @@ public Options getOptions() {
218 223 OptionBuilder.withLongOpt(STATE_LONG).hasArg().create(STATE);
219 224
220 225 public final Option[] ALL_ENABLED_OPTIONS = {
221   - HELP_OPT, DEBUG_OPT, CONFIG_OPT, BATCH_OPT, DELIMITER_OPT,
  226 + HELP_OPT, DEBUG_OPT, CONFIG_OPT, FORCE_OPT, BATCH_OPT, DELIMITER_OPT,
222 227 REPORT_OPT, JSON_OPT, OUTPUT_OPT, ADD_NODES_OPT, LIST_NODES_OPT,
223 228 REMOVE_NODES_OPT, UPDATE_NODES_OPT, POOL_AVAILABILITY_OPT, NETWORKS_OPT, MEMORY_OPT, POOL_OPT,
224 229 ACTIVE_OPT, INACTIVE_OPT, CLEANUP_VMS_OPT, LIST_VMS_OPT, SHUTDOWN_VMS_OPT, USER_OPT, ID_OPT,
24 service/service/java/source/src/org/globus/workspace/remoting/admin/client/RemoteAdminToolsMain.java
@@ -72,6 +72,7 @@
72 72 private List<String> hostList;
73 73 private boolean allVMs = false;
74 74 private int numOpts = 0;
  75 + private boolean force = false;
75 76
76 77 public static void main(String args[]) {
77 78
@@ -310,6 +311,7 @@ else if(this.action == ToolAction.ShutdownVMs ||
310 311
311 312 final boolean batchMode = line.hasOption(Opts.BATCH);
312 313 final boolean json = line.hasOption(Opts.JSON);
  314 + force = line.hasOption(Opts.FORCE);
313 315
314 316 final Reporter.OutputMode mode;
315 317 if (batchMode && json) {
@@ -353,10 +355,10 @@ else if(this.action == ToolAction.ShutdownVMs ||
353 355 }
354 356
355 357 final List leftovers = line.getArgList();
356   - if (leftovers != null && !leftovers.isEmpty()) {
357   - throw new ParameterProblem("There are unrecognized arguments, check -h to make " +
358   - "sure you are doing the intended thing: " + leftovers.toString());
359   - }
  358 + if (leftovers != null && !leftovers.isEmpty()) {
  359 + throw new ParameterProblem("There are unrecognized arguments, check -h to make " +
  360 + "sure you are doing the intended thing: " + leftovers.toString());
  361 + }
360 362
361 363 }
362 364
@@ -460,12 +462,12 @@ private void shutdownVM() {
460 462 }
461 463 if(allVMs) {
462 464 result = this.remoteAdminToolsManagement.shutdown(
463   - RemoteAdminToolsManagement.SHUTDOWN_ALL, null, seconds);
  465 + RemoteAdminToolsManagement.SHUTDOWN_ALL, null, seconds, force);
464 466 }
465 467 else if(vmIDs != null) {
466 468 for(int i = 0; i < vmIDs.size(); i++) {
467 469 feedback = this.remoteAdminToolsManagement.shutdown(
468   - RemoteAdminToolsManagement.SHUTDOWN_ID, vmIDs.get(i), seconds);
  470 + RemoteAdminToolsManagement.SHUTDOWN_ID, vmIDs.get(i), seconds, force);
469 471 if(feedback != null)
470 472 result += feedback + "\n";
471 473 }
@@ -473,7 +475,7 @@ else if(vmIDs != null) {
473 475 else if(userList != null) {
474 476 for(int i = 0; i < userList.size(); i++) {
475 477 feedback = this.remoteAdminToolsManagement.shutdown(
476   - RemoteAdminToolsManagement.SHUTDOWN_UNAME, userList.get(i), seconds);
  478 + RemoteAdminToolsManagement.SHUTDOWN_UNAME, userList.get(i), seconds, force);
477 479 if(feedback != null)
478 480 result += feedback + "\n";
479 481 }
@@ -481,7 +483,7 @@ else if(userList != null) {
481 483 else if(DNList != null) {
482 484 for(int i = 0; i < DNList.size(); i++) {
483 485 feedback = this.remoteAdminToolsManagement.shutdown(
484   - RemoteAdminToolsManagement.SHUTDOWN_DN, DNList.get(i), seconds);
  486 + RemoteAdminToolsManagement.SHUTDOWN_DN, DNList.get(i), seconds, force);
485 487 if(feedback != null)
486 488 result += feedback + "\n";
487 489 }
@@ -489,7 +491,7 @@ else if(DNList != null) {
489 491 else if(gidList != null) {
490 492 for(int i = 0; i < gidList.size(); i++) {
491 493 feedback = this.remoteAdminToolsManagement.shutdown(
492   - RemoteAdminToolsManagement.SHUTDOWN_GID, gidList.get(i), seconds);
  494 + RemoteAdminToolsManagement.SHUTDOWN_GID, gidList.get(i), seconds, force);
493 495 if(feedback != null)
494 496 result += feedback + "\n";
495 497 }
@@ -497,7 +499,7 @@ else if(gidList != null) {
497 499 else if(gnameList != null) {
498 500 for(int i = 0; i < gnameList.size(); i++) {
499 501 feedback = this.remoteAdminToolsManagement.shutdown(
500   - RemoteAdminToolsManagement.SHUTDOWN_GNAME, gnameList.get(i), seconds);
  502 + RemoteAdminToolsManagement.SHUTDOWN_GNAME, gnameList.get(i), seconds, force);
501 503 if(feedback != null)
502 504 result += feedback + "\n";
503 505 }
@@ -505,7 +507,7 @@ else if(gnameList != null) {
505 507 else if(hostList != null) {
506 508 for(int i = 0; i < hostList.size(); i++) {
507 509 feedback = this.remoteAdminToolsManagement.shutdown(
508   - RemoteAdminToolsManagement.SHUTDOWN_HOST, hostList.get(i), seconds);
  510 + RemoteAdminToolsManagement.SHUTDOWN_HOST, hostList.get(i), seconds, force);
509 511 if(feedback != null)
510 512 result += feedback + "\n";
511 513 }
30 ...ce/service/java/source/src/org/globus/workspace/remoting/admin/defaults/DefaultRemoteAdminToolsMgmt.java
@@ -220,9 +220,10 @@ public String getVMsByState(String state) throws RemoteException {
220 220 * typeID is either the id or hostname, depending on if shutting down by id or host, or null if shutting down all
221 221 * seconds is optional
222 222 */
223   - public String shutdown(int type, String typeID, String seconds) throws RemoteException {
  223 + public String shutdown(int type, String typeID, String seconds, boolean force) throws RemoteException {
224 224 try {
225 225 VM[] vms;
  226 + String returnMsg = null;
226 227 vms = typeSet(type, typeID);
227 228
228 229 if(vms == null || vms.length == 0)
@@ -231,7 +232,16 @@ public String shutdown(int type, String typeID, String seconds) throws RemoteExc
231 232 for(int i = 0; i < vms.length; i++) {
232 233 String id = vms[i].getID();
233 234 Caller caller = vms[i].getCreator();
234   - manager.shutdown(id, manager.INSTANCE, null, caller);
  235 + try {
  236 + manager.shutdown(id, manager.INSTANCE, null, caller);
  237 + } catch (OperationDisabledException e) {
  238 + logger.warn("Shutdown is currently disabled for instance " + id);
  239 + if (returnMsg == null) {
  240 + returnMsg = "Shutdown is currently disabled for instance " + id;
  241 + } else {
  242 + returnMsg += "\nShutdown is currently disabled for instance " + id;
  243 + }
  244 + }
235 245 }
236 246
237 247 //checks every 3 seconds to see if one of the vms has entered propagation mode
@@ -263,9 +273,18 @@ public String shutdown(int type, String typeID, String seconds) throws RemoteExc
263 273 for(int i = 0; i < vms.length; i++) {
264 274 String id = vms[i].getID();
265 275 Caller caller = vms[i].getCreator();
266   - manager.trash(id, manager.INSTANCE, caller);
  276 + if (force || vms[i].getState().getState().equals("Propagated")) {
  277 + manager.trash(id, manager.INSTANCE, caller);
  278 + } else {
  279 + if (returnMsg == null) {
  280 + returnMsg = "Instance " + id + " not trashed because it is was not shut down correctly and --force is off";
  281 + } else {
  282 + returnMsg += "\nInstance " + id + " not trashed because it is was not shut down correctly and --force is off";
  283 + }
  284 + }
267 285 }
268   - return null;
  286 +
  287 + return returnMsg;
269 288 }
270 289 catch (ManageException e) {
271 290 throw new RemoteException(e.getMessage());
@@ -273,9 +292,6 @@ public String shutdown(int type, String typeID, String seconds) throws RemoteExc
273 292 catch (DoesNotExistException e) {
274 293 throw new RemoteException(e.getMessage());
275 294 }
276   - catch (OperationDisabledException e) {
277   - throw new RemoteException(e.getMessage());
278   - }
279 295 catch (InterruptedException e) {
280 296 throw new RemoteException(e.getMessage());
281 297 }

0 comments on commit 7b09b7b

Please sign in to comment.
Something went wrong with that request. Please try again.