FlyteAdminClientRunner implements FlyteRunner { @Override public void terminateExecution(RunState runState, FlyteExecutionId flyteExecutionId) { requireNonNull(runState, "runState"); requireNonNull(flyteExecutionId, "flyteExecutionId"); try { flyteAdminClient.terminateExecution( flyteExecutionId.project(), flyteExecutionId.domain(), flyteExecutionId.name(), getCause(runState)); } catch (StatusRuntimeException e) { if (e.getStatus().getCode() == Status.Code.NOT_FOUND) { LOG.warn("Trying to terminate non existent flyte execution: {}", flyteExecutionId); return; } LOG.error("Couldn't terminate flyte execution: {}", flyteExecutionId, e); } catch (Exception e) { LOG.error("Couldn't terminate flyte execution: {}", flyteExecutionId, e); } } @VisibleForTesting  FlyteAdminClientRunner(final String runnerId,
                         final FlyteAdminClient flyteAdminClient,
                         final StateManager stateManager,
                         final Duration terminateDanglingFlyteExecInterval,
                         final ScheduledExecutorService scheduledExecutor,
                         final Time time);   FlyteAdminClientRunner(final String runnerId,
                         final FlyteAdminClient flyteAdminClient,
                         final StateManager stateManager); @Override String createExecution(final RunState runState, final String execName, final FlyteExecConf flyteExecConf,
                                final Map<String, String> annotations); @Override void terminateExecution(RunState runState, FlyteExecutionId flyteExecutionId); @Override void poll(FlyteExecutionId flyteExecutionId, RunState runState); @Override void close();  }
@Test public void testTerminateExecution() { flyteRunner.terminateExecution(RUN_STATE, FLYTE_EXECUTION_ID); verify(flyteAdminClient).terminateExecution( eq(FLYTE_EXECUTION_ID.project()), eq(FLYTE_EXECUTION_ID.domain()), eq(FLYTE_EXECUTION_ID.name()), contains(TERMINATE_CAUSE_PREFIX)); }
@Test @Parameters(method = "terminateExecutionExceptions") public void testNoExceptionThrownFromTerminateExecution(Throwable ex) { doThrow(ex).when(flyteAdminClient).terminateExecution(any(), any(), any(), any()); flyteRunner.terminateExecution(RUN_STATE, FLYTE_EXECUTION_ID); }