KubernetesInternalRuntime extends InternalRuntime<KubernetesRuntimeContext<E>> { @Traced @Override protected void internalStop(Map<String, String> stopOptions) throws InfrastructureException { RuntimeIdentity identity = getContext().getIdentity(); TracingTags.WORKSPACE_ID.set(identity.getWorkspaceId()); runtimeHangingDetector.stopTracking(getContext().getIdentity()); if (startSynchronizer.interrupt()) { try { if (!startSynchronizer.awaitInterruption(workspaceStartTimeoutMin, TimeUnit.MINUTES)) { probeScheduler.cancel(identity.getWorkspaceId()); runtimeCleaner.cleanUp(namespace, identity.getWorkspaceId()); } } catch (InterruptedException e) { throw new InfrastructureException( "Interrupted while waiting for start task cancellation", e); } } else { probeScheduler.cancel(identity.getWorkspaceId()); runtimeCleaner.cleanUp(namespace, identity.getWorkspaceId()); } } @Inject  KubernetesInternalRuntime(
      @Named("che.infra.kubernetes.workspace_start_timeout_min") int workspaceStartTimeoutMin,
      @Named("che.infra.kubernetes.ingress_start_timeout_min") int ingressStartTimeoutMin,
      NoOpURLRewriter urlRewriter,
      UnrecoverablePodEventListenerFactory unrecoverableEventListenerFactory,
      ServersCheckerFactory serverCheckerFactory,
      WorkspaceVolumesStrategy volumesStrategy,
      ProbeScheduler probeScheduler,
      WorkspaceProbesFactory probesFactory,
      RuntimeEventsPublisher eventPublisher,
      KubernetesSharedPool sharedPool,
      KubernetesRuntimeStateCache runtimeStates,
      KubernetesMachineCache machines,
      StartSynchronizerFactory startSynchronizerFactory,
      Set<InternalEnvironmentProvisioner> internalEnvironmentProvisioners,
      KubernetesEnvironmentProvisioner<E> kubernetesEnvironmentProvisioner,
      SidecarToolingProvisioner<E> toolingProvisioner,
      RuntimeHangingDetector runtimeHangingDetector,
      PreviewUrlCommandProvisioner previewUrlCommandProvisioner,
      SecretAsContainerResourceProvisioner secretAsContainerResourceProvisioner,
      KubernetesServerResolverFactory kubernetesServerResolverFactory,
      RuntimeCleaner runtimeCleaner,
      CheNamespace cheNamespace,
      Tracer tracer,
      @Assisted KubernetesRuntimeContext<E> context,
      @Assisted KubernetesNamespace namespace); void scheduleRuntimeStateChecks(); CompletableFuture<Void> waitRunningAsync(
      List<CompletableFuture<?>> toCancelFutures, KubernetesMachineImpl machine); @Override Map<String, ? extends KubernetesMachineImpl> getInternalMachines(); @Override List<? extends Command> getCommands(); @Override Map<String, String> getProperties(); @Override WorkspaceStatus getStatus(); void scheduleServersCheckers(); boolean isConsistent();  }
@Test public void stopsKubernetesEnvironment() throws Exception { doNothing().when(namespace).cleanUp(); internalRuntime.internalStop(emptyMap()); verify(runtimeHangingDetector).stopTracking(IDENTITY); verify(runtimeCleaner).cleanUp(namespace, WORKSPACE_ID); }
@Test(expectedExceptions = InfrastructureException.class) public void throwsInfrastructureExceptionWhenKubernetesNamespaceCleanupFailed() throws Exception { doThrow(InfrastructureException.class).when(runtimeCleaner).cleanUp(namespace, WORKSPACE_ID); internalRuntime.internalStop(emptyMap()); }
@Test public void cancelsWsProbesOnRuntimeStop() throws Exception { doNothing().when(namespace).cleanUp(); internalRuntime.internalStop(emptyMap()); verify(probesScheduler).cancel(WORKSPACE_ID); }