use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.
the class PVCProvisioner method convertCheVolumes.
/**
* Converts {@link Volume} specified in {@link MachineConfig#getVolumes()} to {@link
* PersistentVolumeClaim}s and provision them to {@link KubernetesEnvironment}. The machines
* corresponding pods and containers are updated in accordance.
*
* @param k8sEnv environment to provision
* @param workspaceId identifier of workspace to which the specified environment belongs to
*/
public void convertCheVolumes(KubernetesEnvironment k8sEnv, String workspaceId) {
Map<String, PersistentVolumeClaim> volumeName2PVC = groupByVolumeName(k8sEnv.getPersistentVolumeClaims().values());
for (PodData pod : k8sEnv.getPodsData().values()) {
final PodSpec podSpec = pod.getSpec();
List<Container> containers = new ArrayList<>();
containers.addAll(podSpec.getContainers());
containers.addAll(podSpec.getInitContainers());
for (Container container : containers) {
final String machineName = Names.machineName(pod, container);
InternalMachineConfig machineConfig = k8sEnv.getMachines().get(machineName);
if (machineConfig == null) {
continue;
}
Map<String, Volume> volumes = machineConfig.getVolumes();
addMachineVolumes(workspaceId, k8sEnv, volumeName2PVC, pod, container, volumes);
}
}
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.
the class LogsVolumeMachineProvisionerTest method testProvisionLogsVolumeToAllMachineInEnvironment.
@Test
public void testProvisionLogsVolumeToAllMachineInEnvironment() throws Exception {
logsVolumeProvisioner.provision(openShiftEnvironment, identity);
InternalMachineConfig m1 = openShiftEnvironment.getMachines().get(MACHINE_NAME_1);
InternalMachineConfig m2 = openShiftEnvironment.getMachines().get(MACHINE_NAME_2);
assertTrue(m1.getVolumes().containsKey(LOGS_VOLUME_NAME));
assertEquals(m1.getVolumes().get(LOGS_VOLUME_NAME).getPath(), WORKSPACE_LOGS_ROOT_PATH);
assertTrue(m2.getVolumes().containsKey(LOGS_VOLUME_NAME));
assertEquals(m2.getVolumes().get(LOGS_VOLUME_NAME).getPath(), WORKSPACE_LOGS_ROOT_PATH);
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.
the class BrokerEnvironmentFactoryTest method shouldNotIncludePluginsVolumeInMetadataBroker.
@Test
public void shouldNotIncludePluginsVolumeInMetadataBroker() throws Exception {
// given
Collection<PluginFQN> pluginFQNs = singletonList(new PluginFQN(null, "id"));
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
// when
factory.createForMetadataBroker(pluginFQNs, runtimeId, false);
// then
verify(factory).doCreate(captor.capture());
BrokersConfigs brokersConfigs = captor.getValue();
InternalMachineConfig machine = brokersConfigs.machines.values().iterator().next();
assertFalse(machine.getVolumes().containsKey(PLUGINS_VOLUME_NAME));
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method addsMachineWithVolumeFromChePlugin.
@Test
public void addsMachineWithVolumeFromChePlugin() throws Exception {
// given
ChePlugin chePluginWithNoVolume = createChePlugin();
chePluginWithNoVolume.getContainers().get(0).setVolumes(emptyList());
// when
applier.apply(runtimeIdentity, internalEnvironment, asList(createChePlugin(), chePluginWithNoVolume));
// then
Collection<InternalMachineConfig> machineConfigs = getNonUserMachines(internalEnvironment);
assertEquals(machineConfigs.size(), 2);
verifyNumberOfMachinesWithSpecificNumberOfVolumes(machineConfigs, 2, 0);
}
use of org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method shouldUseContainerNameForMachinesName.
@Test
public void shouldUseContainerNameForMachinesName() throws Exception {
// given
internalEnvironment.getMachines().clear();
ChePlugin chePlugin = createChePlugin("publisher/plugin1/0.2.1", createContainer("container1"));
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
Map<String, InternalMachineConfig> machines = internalEnvironment.getMachines();
assertEquals(machines.size(), 1);
validateContainerNameName(machines.keySet().iterator().next(), "container1");
}
Aggregations