.returning(new Function<ProcessTaskWrapper<?>,Boolean>() { @Override public Boolean apply(ProcessTaskWrapper<?> task) { if (task.getExitCode()==0 && task.getStdout().contains("sudo-is-working-"+id)) return true; Entity entity = BrooklynTaskTags.getTargetOrContextEntity(Tasks.current()); if (onFailingTask!=OnFailingTask.IGNORE) { // TODO if in a queueing context can we mark this task inessential and throw? // that way user sees the message... String message = "Error setting up sudo for "+task.getMachine().getUser()+"@"+task.getMachine().getAddress().getHostName()+" "+ " (exit code "+task.getExitCode()+(entity!=null ? ", entity "+entity : "")+")"; DynamicTasks.queueIfPossible(Tasks.warning(message, null)); } Streams.logStreamTail(log, "STDERR of sudo setup problem", Streams.byteArrayOfString(task.getStderr()), 1024); if (onFailingTask==OnFailingTask.WARN_OR_IF_DYNAMIC_FAIL_MARKING_INESSENTIAL) { Tasks.markInessential(); } if (onFailingTask==OnFailingTask.FAIL || onFailingTask==OnFailingTask.WARN_OR_IF_DYNAMIC_FAIL_MARKING_INESSENTIAL) { throw new IllegalStateException("Passwordless sudo is required for "+task.getMachine().getUser()+"@"+task.getMachine().getAddress().getHostName()+ (entity!=null ? " ("+entity+")" : "")); } return false; } }); }
@Override public void undeploy(String targetName) { checkNotNull(targetName, "targetName"); targetName = FILENAME_TO_WEB_CONTEXT_MAPPER.convertDeploymentTargetNameToContext(targetName); // set it up so future nodes get the right wars if (!removeFromWarsByContext(this, targetName)) { DynamicTasks.submit(Tasks.warning("Context "+targetName+" not known at "+this+"; attempting to undeploy regardless", null), this); } log.debug("Undeploying "+targetName+" across cluster "+this+"; WARs now "+getConfig(WARS_BY_CONTEXT)); Iterable<CanDeployAndUndeploy> targets = Iterables.filter(getChildren(), CanDeployAndUndeploy.class); TaskBuilder<Void> tb = Tasks.<Void>builder().parallel(true).displayName("Undeploy "+targetName+" across cluster (size "+Iterables.size(targets)+")"); for (Entity target: targets) { tb.add(whenServiceUp(target, Effectors.invocation(target, UNDEPLOY, MutableMap.of("targetName", targetName)), "Undeploy "+targetName+" at "+target+" when ready")); } DynamicTasks.queueIfPossible(tb.build()).orSubmitAsync(this).asTask().getUnchecked(); // Update attribute Set<String> deployedWars = MutableSet.copyOf(getAttribute(DEPLOYED_WARS)); deployedWars.remove( FILENAME_TO_WEB_CONTEXT_MAPPER.convertDeploymentTargetNameToContext(targetName) ); sensors().set(DEPLOYED_WARS, deployedWars); }
DynamicTasks.queue( Tasks.warning("Check persistence", new IllegalStateException("Persistence does not appear to be enabled at this cluster. " + "Cluster upgrade will not succeed unless a custom launch script enables it.")) );
DynamicTasks.queue( Tasks.warning("Check persistence", new IllegalStateException("Persistence does not appear to be enabled at this cluster. " + "In-place node upgrade will not succeed unless a custom launch script enables it.")) );