KubernetesInternalRuntime extends InternalRuntime<KubernetesRuntimeContext<E>> { @Traced protected void doStartMachine(ServerResolver serverResolver) throws InfrastructureException { final KubernetesEnvironment environment = getContext().getEnvironment(); final Map<String, InternalMachineConfig> machineConfigs = environment.getMachines(); final String workspaceId = getContext().getIdentity().getWorkspaceId(); LOG.debug("Begin pods creation for workspace '{}'", workspaceId); PodMerger podMerger = new PodMerger(); Map<String, Map<String, Pod>> injectablePods = environment.getInjectablePodsCopy(); for (Pod toCreate : environment.getPodsCopy().values()) { ObjectMeta toCreateMeta = toCreate.getMetadata(); List<PodData> injectables = getAllInjectablePods(toCreate, injectablePods); Pod createdPod; if (injectables.isEmpty()) { createdPod = namespace.deployments().deploy(toCreate); } else { try { injectables.add(new PodData(toCreate)); Deployment merged = podMerger.merge(injectables); merged.getMetadata().setName(toCreate.getMetadata().getName()); createdPod = namespace.deployments().deploy(merged); } catch (ValidationException e) { throw new InfrastructureException(e); } } LOG.debug("Creating pod '{}' in workspace '{}'", toCreateMeta.getName(), workspaceId); storeStartingMachine(createdPod, createdPod.getMetadata(), machineConfigs, serverResolver); } for (Deployment toCreate : environment.getDeploymentsCopy().values()) { PodTemplateSpec template = toCreate.getSpec().getTemplate(); List<PodData> injectables = getAllInjectablePods( template.getMetadata(), template.getSpec().getContainers(), injectablePods); Pod createdPod; if (injectables.isEmpty()) { createdPod = namespace.deployments().deploy(toCreate); } else { try { injectables.add(new PodData(toCreate)); Deployment deployment = podMerger.merge(injectables); deployment.getMetadata().setName(toCreate.getMetadata().getName()); createdPod = namespace.deployments().deploy(deployment); } catch (ValidationException e) { throw new InfrastructureException(e); } } LOG.debug( "Creating deployment '{}' in workspace '{}'", createdPod.getMetadata().getName(), workspaceId); storeStartingMachine(createdPod, createdPod.getMetadata(), machineConfigs, serverResolver); } LOG.debug("Pods creation finished in workspace '{}'", workspaceId); } @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 testRepublishContainerOutputAsMachineLogEvents() throws Exception { final MachineLogsPublisher logsPublisher = new MachineLogsPublisher(eventPublisher, machinesCache, IDENTITY); final PodEvent out1 = mockContainerEventWithoutRandomName( WORKSPACE_POD_NAME, "Pulling", "pulling image", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); final PodEvent out2 = mockContainerEventWithoutRandomName( WORKSPACE_POD_NAME, "Pulled", "image pulled", EVENT_CREATION_TIMESTAMP, getCurrentTimestampWithOneHourShiftAhead()); final ArgumentCaptor<RuntimeLogEvent> captor = ArgumentCaptor.forClass(RuntimeLogEvent.class); internalRuntime.doStartMachine(serverResolver); logsPublisher.handle(out1); logsPublisher.handle(out2); verify(eventService, atLeastOnce()).publish(captor.capture()); final ImmutableList<RuntimeLogEvent> machineLogs = ImmutableList.of(asRuntimeLogEvent(out1), asRuntimeLogEvent(out2)); assertTrue(captor.getAllValues().containsAll(machineLogs)); }