Search in sources :

Example 31 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class ServersConverter method provision.

@Override
@Traced
public void provision(T k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
    TracingTags.WORKSPACE_ID.set(identity::getWorkspaceId);
    SecureServerExposer<T> secureServerExposer = secureServerExposerFactoryProvider.get(k8sEnv).create(identity);
    for (PodData podConfig : k8sEnv.getPodsData().values()) {
        final PodSpec podSpec = podConfig.getSpec();
        for (Container containerConfig : podSpec.getContainers()) {
            String machineName = Names.machineName(podConfig, containerConfig);
            InternalMachineConfig machineConfig = k8sEnv.getMachines().get(machineName);
            if (!machineConfig.getServers().isEmpty()) {
                KubernetesServerExposer kubernetesServerExposer = new KubernetesServerExposer<>(externalServerExposer, secureServerExposer, machineName, podConfig, containerConfig, k8sEnv);
                kubernetesServerExposer.expose(machineConfig.getServers());
            }
        }
    }
}
Also used : PodData(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData) InternalMachineConfig(org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig) Container(io.fabric8.kubernetes.api.model.Container) KubernetesServerExposer(org.eclipse.che.workspace.infrastructure.kubernetes.server.KubernetesServerExposer) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) Traced(org.eclipse.che.commons.annotation.Traced)

Example 32 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class KubernetesInternalRuntime method startMachines.

/**
 * Create all machine related objects and start machines.
 *
 * @throws InfrastructureException when any error occurs while creating Kubernetes objects
 */
@Traced
protected void startMachines() throws InfrastructureException {
    KubernetesEnvironment k8sEnv = getContext().getEnvironment();
    String workspaceId = getContext().getIdentity().getWorkspaceId();
    createSecrets(k8sEnv, workspaceId);
    List<ConfigMap> createdConfigMaps = createConfigMaps(k8sEnv, getContext().getIdentity());
    List<Service> createdServices = createServices(k8sEnv, workspaceId);
    // needed for resolution later on, even though n routes are actually created by ingress
    // /workspace{wsid}/server-{port} => service({wsid}):server-port => pod({wsid}):{port}
    List<Ingress> readyIngresses = createIngresses(k8sEnv, workspaceId);
    listenEvents();
    doStartMachine(serverResolverFactory.create(createdServices, readyIngresses, createdConfigMaps));
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) Service(io.fabric8.kubernetes.api.model.Service) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) Traced(org.eclipse.che.commons.annotation.Traced)

Example 33 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class KubernetesInternalRuntime method createServices.

@Traced
// package-private so that interception is possible
@SuppressWarnings("WeakerAccess")
List<Service> createServices(KubernetesEnvironment env, String workspaceId) throws InfrastructureException {
    TracingTags.WORKSPACE_ID.set(workspaceId);
    Collection<Service> servicesToCreate = env.getServices().values();
    List<Service> createdServices = new ArrayList<>(servicesToCreate.size());
    for (Service service : servicesToCreate) {
        createdServices.add(namespace.services().create(service));
    }
    return createdServices;
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Service(io.fabric8.kubernetes.api.model.Service) Traced(org.eclipse.che.commons.annotation.Traced)

Example 34 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class LimitsCheckingWorkspaceManager method createWorkspace.

@Override
@Traced
public WorkspaceImpl createWorkspace(WorkspaceConfig config, String namespace, @Nullable Map<String, String> attributes) throws ServerException, ConflictException, NotFoundException, ValidationException {
    checkMaxEnvironmentRam(config);
    String accountId = accountManager.getByName(namespace).getId();
    try (Unlocker ignored = resourcesLocks.lock(accountId)) {
        checkWorkspaceResourceAvailability(accountId);
        return super.createWorkspace(config, namespace, attributes);
    }
}
Also used : Unlocker(org.eclipse.che.commons.lang.concurrent.Unlocker) Traced(org.eclipse.che.commons.annotation.Traced)

Example 35 with Traced

use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.

the class SidecarToolingProvisioner method provision.

@Traced
@Beta
public void provision(RuntimeIdentity identity, StartSynchronizer startSynchronizer, E environment, Map<String, String> startOptions) throws InfrastructureException {
    Collection<PluginFQN> pluginFQNs = pluginFQNParser.parsePlugins(environment.getAttributes());
    if (pluginFQNs.isEmpty()) {
        return;
    }
    LOG.debug("Started sidecar tooling provisioning workspace '{}'", identity.getWorkspaceId());
    String recipeType = environment.getType();
    ChePluginsApplier pluginsApplier = workspaceNextAppliers.get(recipeType);
    if (pluginsApplier == null) {
        throw new InfrastructureException("Sidecar tooling configuration is not supported with environment type " + recipeType);
    }
    boolean isEphemeral = EphemeralWorkspaceUtility.isEphemeral(environment.getAttributes());
    boolean mergePlugins = shouldMergePlugins(environment.getAttributes());
    List<ChePlugin> chePlugins = pluginBrokerManager.getTooling(identity, startSynchronizer, pluginFQNs, isEphemeral, mergePlugins, startOptions);
    pluginsApplier.apply(identity, environment, chePlugins);
    artifactsBrokerApplier.apply(environment, identity, pluginFQNs, mergePlugins);
    LOG.debug("Finished sidecar tooling provisioning workspace '{}'", identity.getWorkspaceId());
}
Also used : ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) PluginFQN(org.eclipse.che.api.workspace.server.wsplugins.model.PluginFQN) ChePluginsApplier(org.eclipse.che.api.workspace.server.wsplugins.ChePluginsApplier) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) Traced(org.eclipse.che.commons.annotation.Traced) Beta(com.google.common.annotations.Beta)

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