/** * Starts a new privilege-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
/** * Starts a new privilege-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
/** * Starts a new priviledge-escalated environment, execute a closure, and * shut it down. */ public static <V, T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
/** * Starts a new priviledge-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
/** * Starts a new priviledge-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
/** * Starts a new priviledge-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
/** * Delete the slave, terminate the instance. Can be called either by doDoDelete() or from MesosRetentionStrategy. * * @throws InterruptedException */ public void deleteSlave() throws IOException, InterruptedException { LOGGER.info("Terminating " + getName() + " slave"); MesosSlave slave = getNode(); // Slave already deleted if (slave == null) return; VirtualChannel channel = slave.getChannel(); if (channel != null) { channel.close(); } slave.terminate(); getJenkins().removeNode(slave); }
/** * Delete the slave, terminate or suspend the instance. * Can be called either by doDoDelete() or from JCloudsRetentionStrategy. * Whether the instance gets terminated or suspended is handled in * {@link JCloudsSlave#_terminate} * * @throws InterruptedException if the deletion gets interrupted. * @throws IOException if an error occurs. */ public void deleteSlave() throws IOException, InterruptedException { if (isIdle()) { // Fixes JENKINS-27471 LOGGER.info("Deleting slave: " + getName()); JCloudsSlave slave = getNode(); if (null != slave ) { final VirtualChannel ch = slave.getChannel(); if (null != ch) { ch.close(); } slave.terminate(); Jenkins.getInstance().removeNode(slave); } } else { LOGGER.info(String.format("Slave %s is not idle, postponing deletion", getName())); // Fixes JENKINS-28403 final JCloudsSlave node = getNode(); if (null != node && !node.isPendingDelete()) { node.setPendingDelete(true); } } }