/** same as {@link Tasks#markInessential()} * (but included here for convenience as it is often used in conjunction with {@link DynamicTasks}) */ public static void markInessential() { Tasks.markInessential(); }
while (true) { if (!Entities.isManaged(target)) { Tasks.markInessential(); throw new IllegalStateException("Target "+target+" is no longer managed"); throw Exceptions.propagate(e); } else { Tasks.markInessential(); throw new IllegalStateException("Target "+target+" is no longer managed", e);
.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 run() { Tasks.markInessential(); CountdownTimer timer = Duration.seconds(20).countdownTimer(); boolean hasCreationScript = copyDatabaseCreationScript(); timer.waitForExpiryUnchecked(); changePassword("", getPassword()); if (hasCreationScript) executeScriptFromInstalledFileAsync("creation-script.sql").asTask().getUnchecked(); } });