Search in sources :

Example 36 with RuntimeIdentity

use of org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity in project che-server by eclipse-che.

the class KubernetesInternalRuntime method markStopping.

@Override
protected void markStopping() throws InfrastructureException {
    RuntimeIdentity runtimeId = getContext().getIdentity();
    // Check if runtime is in STARTING phase to actualize state of startSynchronizer.
    Optional<WorkspaceStatus> statusOpt = runtimeStates.getStatus(runtimeId);
    if (statusOpt.isPresent() && statusOpt.get() == WorkspaceStatus.STARTING) {
        startSynchronizer.start();
    }
    if (!runtimeStates.updateStatus(runtimeId, s -> s == WorkspaceStatus.RUNNING || s == WorkspaceStatus.STARTING, WorkspaceStatus.STOPPING)) {
        throw new StateException("The environment must be running or starting");
    }
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) ProbeResult(org.eclipse.che.api.workspace.server.hc.probe.ProbeResult) ServerStatus(org.eclipse.che.api.core.model.workspace.runtime.ServerStatus) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) Assisted(com.google.inject.assistedinject.Assisted) KubernetesObjectUtil.putLabels(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.putLabels) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Collectors.toMap(java.util.stream.Collectors.toMap) PodMerger(org.eclipse.che.workspace.infrastructure.kubernetes.environment.PodMerger) Map(java.util.Map) StateException(org.eclipse.che.api.workspace.server.spi.StateException) KubernetesObjectUtil.putAnnotations(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.putAnnotations) CHECK_SERVERS(org.eclipse.che.workspace.infrastructure.kubernetes.util.TracingSpanConstants.CHECK_SERVERS) Command(org.eclipse.che.api.core.model.workspace.config.Command) WorkspaceProbes(org.eclipse.che.api.workspace.server.hc.probe.WorkspaceProbes) ImmutableMap(com.google.common.collect.ImmutableMap) KubernetesServerResolverFactory(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.KubernetesServerResolverFactory) Collection(java.util.Collection) Set(java.util.Set) KubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache) SidecarToolingProvisioner(org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.SidecarToolingProvisioner) NoOpURLRewriter(org.eclipse.che.api.workspace.server.URLRewriter.NoOpURLRewriter) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) RuntimeStartInterruptedException(org.eclipse.che.api.workspace.server.spi.RuntimeStartInterruptedException) KubernetesObjectUtil.shouldCreateInCheNamespace(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.shouldCreateInCheNamespace) Objects(java.util.Objects) InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) KubernetesSharedPool(org.eclipse.che.workspace.infrastructure.kubernetes.util.KubernetesSharedPool) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) List(java.util.List) WorkspaceVolumesStrategy(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy) CompletionStage(java.util.concurrent.CompletionStage) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) TracingTags(org.eclipse.che.commons.tracing.TracingTags) UnrecoverablePodEventListenerFactory(org.eclipse.che.workspace.infrastructure.kubernetes.util.UnrecoverablePodEventListenerFactory) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) Entry(java.util.Map.Entry) Secret(io.fabric8.kubernetes.api.model.Secret) Span(io.opentracing.Span) Optional(java.util.Optional) Scope(io.opentracing.Scope) WorkspaceProbesFactory(org.eclipse.che.api.workspace.server.hc.probe.WorkspaceProbesFactory) LogWatcher(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.LogWatcher) WAIT_RUNNING_ASYNC(org.eclipse.che.workspace.infrastructure.kubernetes.util.TracingSpanConstants.WAIT_RUNNING_ASYNC) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MachineStatus(org.eclipse.che.api.core.model.workspace.runtime.MachineStatus) InternalEnvironmentProvisioner(org.eclipse.che.api.workspace.server.spi.provision.InternalEnvironmentProvisioner) Container(io.fabric8.kubernetes.api.model.Container) CompletableFuture(java.util.concurrent.CompletableFuture) ServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver) KubernetesMachineImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl) Function(java.util.function.Function) Traced(org.eclipse.che.commons.annotation.Traced) ValidationException(org.eclipse.che.api.core.ValidationException) ArrayList(java.util.ArrayList) CheNamespace(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.CheNamespace) LinkedHashMap(java.util.LinkedHashMap) Inject(javax.inject.Inject) ServersChecker(org.eclipse.che.api.workspace.server.hc.ServersChecker) KubernetesNamespace(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesNamespace) InternalInfrastructureException(org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException) EnvironmentContext(org.eclipse.che.commons.env.EnvironmentContext) BiConsumer(java.util.function.BiConsumer) WAIT_MACHINES_START(org.eclipse.che.workspace.infrastructure.kubernetes.util.TracingSpanConstants.WAIT_MACHINES_START) Service(io.fabric8.kubernetes.api.model.Service) Named(javax.inject.Named) RuntimeEventsPublisher(org.eclipse.che.workspace.infrastructure.kubernetes.util.RuntimeEventsPublisher) PodLogToEventPublisher(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.PodLogToEventPublisher) ProbeScheduler(org.eclipse.che.api.workspace.server.hc.probe.ProbeScheduler) InternalRuntime(org.eclipse.che.api.workspace.server.spi.InternalRuntime) LogWatchTimeouts(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.LogWatchTimeouts) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Executor(java.util.concurrent.Executor) WorkspaceStatus(org.eclipse.che.api.core.model.workspace.WorkspaceStatus) Pod(io.fabric8.kubernetes.api.model.Pod) SecretAsContainerResourceProvisioner(org.eclipse.che.workspace.infrastructure.kubernetes.provision.secret.SecretAsContainerResourceProvisioner) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) KubernetesRuntimeStateCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache) PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) PreviewUrlCommandProvisioner(org.eclipse.che.workspace.infrastructure.kubernetes.provision.PreviewUrlCommandProvisioner) ProbeStatus(org.eclipse.che.api.workspace.server.hc.probe.ProbeResult.ProbeStatus) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ServersCheckerFactory(org.eclipse.che.api.workspace.server.hc.ServersCheckerFactory) WorkspaceStatus(org.eclipse.che.api.core.model.workspace.WorkspaceStatus) StateException(org.eclipse.che.api.workspace.server.spi.StateException)

Example 37 with RuntimeIdentity

use of org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity in project che-server by eclipse-che.

the class KubernetesRuntimeContext method getRuntime.

@Override
public KubernetesInternalRuntime getRuntime() throws InfrastructureException {
    Optional<KubernetesRuntimeState> runtimeStateOpt = runtimeStatuses.get(getIdentity());
    String workspaceId = getIdentity().getWorkspaceId();
    if (!runtimeStateOpt.isPresent()) {
        // there is no cached runtime, create a new one
        return runtimeFactory.create(this, namespaceFactory.getOrCreate(getIdentity()));
    }
    // there is cached runtime, restore cached one
    KubernetesRuntimeState runtimeState = runtimeStateOpt.get();
    RuntimeIdentity runtimeId = runtimeState.getRuntimeId();
    LOG.debug("Restoring runtime `{}:{}:{}`", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId());
    KubernetesInternalRuntime runtime = runtimeFactory.create(this, namespaceFactory.access(workspaceId, runtimeState.getNamespace()));
    runtime.scheduleRuntimeStateChecks();
    return runtime;
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState)

Example 38 with RuntimeIdentity

use of org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity in project che-server by eclipse-che.

the class KubernetesInternalRuntime method checkServers.

/**
 * Returns a function, the result of which the completable stage that performs servers checks and
 * start of servers probes.
 */
private Function<Void, CompletionStage<Void>> checkServers(List<CompletableFuture<?>> toCancelFutures, KubernetesMachineImpl machine) {
    // Need to get active span here to allow use in returned function;
    final Span activeSpan = tracer.activeSpan();
    return ignored -> {
        // Span must be created within this lambda block, otherwise the span begins as soon as
        // this function is called (i.e. before the previous steps in the machine boot chain
        // are complete
        final Span tracingSpan = tracer.buildSpan(CHECK_SERVERS).asChildOf(activeSpan).start();
        TracingTags.WORKSPACE_ID.set(tracingSpan, getContext().getIdentity().getWorkspaceId());
        TracingTags.MACHINE_NAME.set(tracingSpan, machine.getName());
        // This completable future is used to unity the servers checks and start of probes
        final CompletableFuture<Void> serversAndProbesFuture = new CompletableFuture<>();
        final String machineName = machine.getName();
        final RuntimeIdentity runtimeId = getContext().getIdentity();
        final ServersChecker serverCheck = serverCheckerFactory.create(runtimeId, machineName, machine.getServers());
        final CompletableFuture<?> serversReadyFuture;
        LOG.debug("Performing servers check for machine '{}' in workspace '{}'", machineName, runtimeId.getWorkspaceId());
        try {
            serversReadyFuture = serverCheck.startAsync(new ServerReadinessHandler(machineName));
            toCancelFutures.add(serversReadyFuture);
            serversAndProbesFuture.whenComplete((ok, ex) -> {
                LOG.debug("Servers checks done for machine '{}' in workspace '{}'", machineName, runtimeId.getWorkspaceId());
                serversReadyFuture.cancel(true);
            });
        } catch (InfrastructureException ex) {
            serversAndProbesFuture.completeExceptionally(ex);
            TracingTags.setErrorStatus(tracingSpan, ex);
            tracingSpan.finish();
            return serversAndProbesFuture;
        }
        serversReadyFuture.whenComplete((BiConsumer<Object, Throwable>) (ok, ex) -> {
            if (ex != null) {
                serversAndProbesFuture.completeExceptionally(ex);
                TracingTags.setErrorStatus(tracingSpan, ex);
                tracingSpan.finish();
                return;
            }
            try {
                probeScheduler.schedule(probesFactory.getProbes(runtimeId, machineName, machine.getServers()), new ServerLivenessHandler());
            } catch (InfrastructureException iex) {
                serversAndProbesFuture.completeExceptionally(iex);
            }
            serversAndProbesFuture.complete(null);
            tracingSpan.finish();
        });
        return serversAndProbesFuture;
    };
}
Also used : ProbeResult(org.eclipse.che.api.workspace.server.hc.probe.ProbeResult) ServerStatus(org.eclipse.che.api.core.model.workspace.runtime.ServerStatus) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) Assisted(com.google.inject.assistedinject.Assisted) KubernetesObjectUtil.putLabels(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.putLabels) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Collectors.toMap(java.util.stream.Collectors.toMap) PodMerger(org.eclipse.che.workspace.infrastructure.kubernetes.environment.PodMerger) Map(java.util.Map) StateException(org.eclipse.che.api.workspace.server.spi.StateException) KubernetesObjectUtil.putAnnotations(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.putAnnotations) CHECK_SERVERS(org.eclipse.che.workspace.infrastructure.kubernetes.util.TracingSpanConstants.CHECK_SERVERS) Command(org.eclipse.che.api.core.model.workspace.config.Command) WorkspaceProbes(org.eclipse.che.api.workspace.server.hc.probe.WorkspaceProbes) ImmutableMap(com.google.common.collect.ImmutableMap) KubernetesServerResolverFactory(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.KubernetesServerResolverFactory) Collection(java.util.Collection) Set(java.util.Set) KubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache) SidecarToolingProvisioner(org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.SidecarToolingProvisioner) NoOpURLRewriter(org.eclipse.che.api.workspace.server.URLRewriter.NoOpURLRewriter) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) RuntimeStartInterruptedException(org.eclipse.che.api.workspace.server.spi.RuntimeStartInterruptedException) KubernetesObjectUtil.shouldCreateInCheNamespace(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesObjectUtil.shouldCreateInCheNamespace) Objects(java.util.Objects) InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) KubernetesSharedPool(org.eclipse.che.workspace.infrastructure.kubernetes.util.KubernetesSharedPool) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) List(java.util.List) WorkspaceVolumesStrategy(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.pvc.WorkspaceVolumesStrategy) CompletionStage(java.util.concurrent.CompletionStage) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) TracingTags(org.eclipse.che.commons.tracing.TracingTags) UnrecoverablePodEventListenerFactory(org.eclipse.che.workspace.infrastructure.kubernetes.util.UnrecoverablePodEventListenerFactory) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) Entry(java.util.Map.Entry) Secret(io.fabric8.kubernetes.api.model.Secret) Span(io.opentracing.Span) Optional(java.util.Optional) Scope(io.opentracing.Scope) WorkspaceProbesFactory(org.eclipse.che.api.workspace.server.hc.probe.WorkspaceProbesFactory) LogWatcher(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.LogWatcher) WAIT_RUNNING_ASYNC(org.eclipse.che.workspace.infrastructure.kubernetes.util.TracingSpanConstants.WAIT_RUNNING_ASYNC) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MachineStatus(org.eclipse.che.api.core.model.workspace.runtime.MachineStatus) InternalEnvironmentProvisioner(org.eclipse.che.api.workspace.server.spi.provision.InternalEnvironmentProvisioner) Container(io.fabric8.kubernetes.api.model.Container) CompletableFuture(java.util.concurrent.CompletableFuture) ServerResolver(org.eclipse.che.workspace.infrastructure.kubernetes.server.resolver.ServerResolver) KubernetesMachineImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl) Function(java.util.function.Function) Traced(org.eclipse.che.commons.annotation.Traced) ValidationException(org.eclipse.che.api.core.ValidationException) ArrayList(java.util.ArrayList) CheNamespace(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.CheNamespace) LinkedHashMap(java.util.LinkedHashMap) Inject(javax.inject.Inject) ServersChecker(org.eclipse.che.api.workspace.server.hc.ServersChecker) KubernetesNamespace(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.KubernetesNamespace) InternalInfrastructureException(org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException) EnvironmentContext(org.eclipse.che.commons.env.EnvironmentContext) BiConsumer(java.util.function.BiConsumer) WAIT_MACHINES_START(org.eclipse.che.workspace.infrastructure.kubernetes.util.TracingSpanConstants.WAIT_MACHINES_START) Service(io.fabric8.kubernetes.api.model.Service) Named(javax.inject.Named) RuntimeEventsPublisher(org.eclipse.che.workspace.infrastructure.kubernetes.util.RuntimeEventsPublisher) PodLogToEventPublisher(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.PodLogToEventPublisher) ProbeScheduler(org.eclipse.che.api.workspace.server.hc.probe.ProbeScheduler) InternalRuntime(org.eclipse.che.api.workspace.server.spi.InternalRuntime) LogWatchTimeouts(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.log.LogWatchTimeouts) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Executor(java.util.concurrent.Executor) WorkspaceStatus(org.eclipse.che.api.core.model.workspace.WorkspaceStatus) Pod(io.fabric8.kubernetes.api.model.Pod) SecretAsContainerResourceProvisioner(org.eclipse.che.workspace.infrastructure.kubernetes.provision.secret.SecretAsContainerResourceProvisioner) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) KubernetesRuntimeStateCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache) PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) PodEvent(org.eclipse.che.workspace.infrastructure.kubernetes.namespace.event.PodEvent) PreviewUrlCommandProvisioner(org.eclipse.che.workspace.infrastructure.kubernetes.provision.PreviewUrlCommandProvisioner) ProbeStatus(org.eclipse.che.api.workspace.server.hc.probe.ProbeResult.ProbeStatus) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ServersCheckerFactory(org.eclipse.che.api.workspace.server.hc.ServersCheckerFactory) RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) CompletableFuture(java.util.concurrent.CompletableFuture) ServersChecker(org.eclipse.che.api.workspace.server.hc.ServersChecker) Span(io.opentracing.Span) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) InternalInfrastructureException(org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException) BiConsumer(java.util.function.BiConsumer)

Example 39 with RuntimeIdentity

use of org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity in project che-server by eclipse-che.

the class KubernetesInternalRuntime method internalStop.

@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()) {
        // runtime is STARTING. Need to wait until start will be interrupted properly
        try {
            if (!startSynchronizer.awaitInterruption(workspaceStartTimeoutMin, TimeUnit.MINUTES)) {
                // Runtime is not interrupted yet. It may occur when start was performing by another
                // Che Server that is crashed so start is hung up in STOPPING phase.
                // Need to clean up runtime resources
                probeScheduler.cancel(identity.getWorkspaceId());
                runtimeCleaner.cleanUp(namespace, identity.getWorkspaceId());
            }
        } catch (InterruptedException e) {
            throw new InfrastructureException("Interrupted while waiting for start task cancellation", e);
        }
    } else {
        // runtime is RUNNING. Clean up used resources
        // Cancels workspace servers probes if any
        probeScheduler.cancel(identity.getWorkspaceId());
        runtimeCleaner.cleanUp(namespace, identity.getWorkspaceId());
    }
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) RuntimeStartInterruptedException(org.eclipse.che.api.workspace.server.spi.RuntimeStartInterruptedException) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) InternalInfrastructureException(org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException) Traced(org.eclipse.che.commons.annotation.Traced)

Example 40 with RuntimeIdentity

use of org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity in project che-server by eclipse-che.

the class InconsistentRuntimesDetector method checkOne.

@VisibleForTesting
void checkOne(String workspaceId) throws InfrastructureException {
    LOG.debug("Checking consistency of runtime for workspace `{}`", workspaceId);
    KubernetesInternalRuntime k8sRuntime = getKubernetesInternalRuntime(workspaceId);
    RuntimeIdentity runtimeId = k8sRuntime.getContext().getIdentity();
    try {
        if (k8sRuntime.isConsistent()) {
            return;
        }
    } catch (InfrastructureException e) {
        throw new InfrastructureException(format("Error occurred during runtime '%s:%s' consistency checking. Cause: %s", runtimeId.getWorkspaceId(), runtimeId.getOwnerId(), e.getMessage()), e);
    }
    // not to initialize abnormal stop for a runtime that is not RUNNING anymore
    if (!isRunning(k8sRuntime)) {
        return;
    }
    LOG.warn("Found runtime `{}:{}` with inconsistent state. It's going to be stopped automatically", runtimeId.getWorkspaceId(), runtimeId.getOwnerId());
    stopAbnormally(k8sRuntime);
    LOG.debug("Checking consistency of runtime for workspace `{}` is finished", workspaceId);
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)128 Test (org.testng.annotations.Test)88 RuntimeIdentityImpl (org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl)70 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)40 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)28 InternalEnvironment (org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironment)24 RuntimeContext (org.eclipse.che.api.workspace.server.spi.RuntimeContext)22 Map (java.util.Map)20 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)18 List (java.util.List)16 Set (java.util.Set)14 ServerException (org.eclipse.che.api.core.ServerException)14 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)14 Traced (org.eclipse.che.commons.annotation.Traced)14 KubernetesMachineImpl (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl)14 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)12 Secret (io.fabric8.kubernetes.api.model.Secret)12 String.format (java.lang.String.format)12 Collectors (java.util.stream.Collectors)12 Named (javax.inject.Named)12