Search in sources :

Example 16 with Traced

use of org.eclipse.che.commons.annotation.Traced in project devspaces-images by redhat-developer.

the class ServiceAccountProvisioner method provision.

@Override
@Traced
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    if (!isNullOrEmpty(serviceAccount)) {
        for (PodData pod : k8sEnv.getPodsData().values()) {
            pod.getSpec().setServiceAccountName(serviceAccount);
            pod.getSpec().setAutomountServiceAccountToken(true);
        }
    }
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) Traced(org.eclipse.che.commons.annotation.Traced)

Example 17 with Traced

use of org.eclipse.che.commons.annotation.Traced in project devspaces-images by redhat-developer.

the class OpenShiftInternalRuntime method startMachines.

@Override
@Traced
protected void startMachines() throws InfrastructureException {
    OpenShiftEnvironment osEnv = getContext().getEnvironment();
    String workspaceId = getContext().getIdentity().getWorkspaceId();
    createSecrets(osEnv, workspaceId);
    List<ConfigMap> createdConfigMaps = createConfigMaps(osEnv, getContext().getIdentity());
    List<Service> createdServices = createServices(osEnv, workspaceId);
    List<Route> createdRoutes = createRoutes(osEnv, workspaceId);
    listenEvents();
    doStartMachine(serverResolverFactory.create(createdServices, createdRoutes, createdConfigMaps));
}
Also used : OpenShiftEnvironment(org.eclipse.che.workspace.infrastructure.openshift.environment.OpenShiftEnvironment) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) Route(io.fabric8.openshift.api.model.Route) Traced(org.eclipse.che.commons.annotation.Traced)

Example 18 with Traced

use of org.eclipse.che.commons.annotation.Traced in project devspaces-images by redhat-developer.

the class RouteTlsProvisioner method provision.

@Override
@Traced
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity) {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    if (!isTlsEnabled) {
        return;
    }
    final Set<Route> routes = new HashSet<>(osEnv.getRoutes().values());
    for (Route route : routes) {
        useSecureProtocolForServers(route);
        enableTls(route);
    }
}
Also used : Route(io.fabric8.openshift.api.model.Route) HashSet(java.util.HashSet) Traced(org.eclipse.che.commons.annotation.Traced)

Example 19 with Traced

use of org.eclipse.che.commons.annotation.Traced in project devspaces-images by redhat-developer.

the class TracingInterceptor method getSpanName.

private String getSpanName(MethodInvocation invocation) {
    Class<?> objectType = invocation.getThis().getClass();
    Method method = invocation.getMethod();
    // we assume that there won't be more than 4 traced methods on a type. If there are, we're
    // adding a little bit of runtime overhead of enlarging the hashmap's capacity, but in the usual
    // case we're saving 12 entries in the map (16 is the default capacity).
    String ret = spanNames.computeIfAbsent(objectType, __ -> new WeakHashMap<>(4)).get(method);
    if (ret != null) {
        return ret;
    }
    Traced annotation = method.getAnnotation(Traced.class);
    if (annotation == null) {
        throw new IllegalStateException("Misconfigured Guice interception. Tracing interceptor called on method " + method + " that is not annotated with @Traced.");
    }
    String name = annotation.name();
    if (name.isEmpty()) {
        name = cleanName(objectType) + "#" + method.getName();
    }
    spanNames.get(objectType).put(method, name);
    return name;
}
Also used : Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) Inject(com.google.inject.Inject) LoggerFactory(org.slf4j.LoggerFactory) Tags(io.opentracing.tag.Tags) Supplier(java.util.function.Supplier) Traced(org.eclipse.che.commons.annotation.Traced) Beta(com.google.common.annotations.Beta) MethodInterceptor(org.aopalliance.intercept.MethodInterceptor) MethodInvocation(org.aopalliance.intercept.MethodInvocation) Map(java.util.Map) Span(io.opentracing.Span) Scope(io.opentracing.Scope) Method(java.lang.reflect.Method) WeakHashMap(java.util.WeakHashMap) Traced(org.eclipse.che.commons.annotation.Traced) Method(java.lang.reflect.Method) WeakHashMap(java.util.WeakHashMap)

Example 20 with Traced

use of org.eclipse.che.commons.annotation.Traced in project devspaces-images by redhat-developer.

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)

Aggregations

Traced (org.eclipse.che.commons.annotation.Traced)54 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)14 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)12 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)10 ArrayList (java.util.ArrayList)10 Service (io.fabric8.kubernetes.api.model.Service)8 Map (java.util.Map)8 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)8 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)8 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)8 Beta (com.google.common.annotations.Beta)6 Container (io.fabric8.kubernetes.api.model.Container)6 Route (io.fabric8.openshift.api.model.Route)6 ValidationException (org.eclipse.che.api.core.ValidationException)6 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)6 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)5 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)4 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)4 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4