/** * Adds the given element to this queue. If the queue is currently full, the element at the head * of the queue is evicted to make room. * * @return {@code true} always */ @Override public boolean offer(E e) { return add(e); }
@Override public void finished(StepContext context) { closeQuietly(context, closeables); } }
/** * Add a dynamic pod template. Won't be displayed in UI, and persisted separately from the cloud instance. * @param t the template to add */ public void addDynamicTemplate(PodTemplate t) { PodTemplateMap.get().addTemplate(this, t); }
@Test public void testCommandExecutionFailureHighError() throws Exception { ProcReturn r = execCommand(false, "sh", "-c", "return 127"); assertEquals(127, r.exitCode); assertFalse(r.proc.isAlive()); }
@Override // TODO Revisit for JENKINS-40161 public void onResume() { super.onResume(); LOGGER.log(Level.FINE, "onResume"); try { KubernetesNodeContext nodeContext = new KubernetesNodeContext(getContext()); client = nodeContext.connectToCloud(); decorator.setKubernetesClient(client); } catch (Exception e) { ContainerStepExecution.this.getContext().onFailure(e); } }
@Override public void stop(Throwable cause) throws Exception { new PodTemplateAction(getContext().get(Run.class)).pop(); }
/** * Remove a dynamic pod template. * @param t the template to remove */ public void removeDynamicTemplate(PodTemplate t) { PodTemplateMap.get().removeTemplate(this, t); }
@Override public int join() throws IOException, InterruptedException { return proc.isAlive() ? 0 : -1; }
@Override public void stop(@Nonnull Throwable cause) throws Exception { LOGGER.log(Level.FINE, "Stopping container step."); closeQuietly(getContext(), client, decorator); }
@Override public void stop(Throwable cause) throws Exception { LOGGER.log(Level.FINE, "Stopping container log step."); try { super.stop(cause); } finally { closeQuietly(getContext(), client); } } }
@Override public void onLoad(Run<?, ?> r) { setRun(r); }
/** * Creates and returns a new evicting queue that will hold up to {@code maxSize} elements. * * <p>When {@code maxSize} is zero, elements will be evicted immediately after being added to the * queue. */ public static <E> EvictingQueue<E> create(int maxSize) { return new EvictingQueue<E>(maxSize); }
/** * Returns the number of additional elements that this queue can accept without evicting; * zero if the queue is currently full. * * @since 16.0 */ public int remainingCapacity() { return maxSize - size(); }
PodTemplateStepExecution(PodTemplateStep step, StepContext context) { super(context); this.step = step; this.cloudName = step.getCloud(); }
@Override public StepExecution start(StepContext context) throws Exception { return new ContainerLogStepExecution(this, context); }
@Override public StepExecution start(StepContext context) throws Exception { return new ContainerStepExecution(this, context); }
@Override public StepExecution start(StepContext context) throws Exception { return new PodTemplateStepExecution(this, context); }
@Test public void testCommandExecutionFailure() throws Exception { ProcReturn r = execCommand(false, "false"); assertEquals(1, r.exitCode); assertFalse(r.proc.isAlive()); }
@Override public void onAttached(Run<?, ?> r) { setRun(r); }
@Test public void testCommandExecutionWithNohupAndError() throws Exception { ProcReturn r = execCommand(false, "nohup", "sh", "-c", "sleep 5; return 127"); assertEquals(127, r.exitCode); assertFalse(r.proc.isAlive()); }